Browse Source

Not print the tensor python object util it has been initialized

tags/v1.2.0-rc1
yujianfeng 5 years ago
parent
commit
b3a2d4bdaa
1 changed files with 6 additions and 2 deletions
  1. +6
    -2
      mindspore/common/tensor.py

+ 6
- 2
mindspore/common/tensor.py View File

@@ -67,6 +67,7 @@ class Tensor(Tensor_):
"""

def __init__(self, input_data=None, dtype=None, shape=None, init=None):
self.init_finished = False
# If input data is numpy number, convert it to np array
if isinstance(input_data, np_types):
input_data = np.array(input_data)
@@ -109,6 +110,7 @@ class Tensor(Tensor_):
Tensor_.__init__(self, dtype, shape)
self._virtual_flag = False
self.init = init
self.init_finished = True

def __deepcopy__(self, memodict):
new_obj = Tensor(self)
@@ -117,8 +119,10 @@ class Tensor(Tensor_):
return new_obj

def __repr__(self):
Tensor_.data_sync(self, False)
return Tensor_.__repr__(self)
if self.init_finished:
Tensor_.data_sync(self, False)
return Tensor_.__repr__(self)
return ''

def __add__(self, other):
out = tensor_operator_registry.get('__add__')(self, other)


Loading…
Cancel
Save