MCPcopy Create free account
hub / github.com/apache/singa / reshape

Method reshape

python/singa/tensor.py:232–248  ·  view source on GitHub ↗

Return a new tensor with the given shape, and the original tensor is not changed. Args: shape (list ): new shape, which should have the same volumn as the original shape. Returns: new tensor reshaped

(self, shape)

Source from the content-addressed store, hash-verified

230 return t
231
232 def reshape(self, shape):
233 '''Return a new tensor with the given shape, and the original
234 tensor is not changed.
235
236 Args:
237 shape (list<int>): new shape, which should have the same
238 volumn as the original shape.
239
240 Returns:
241 new tensor reshaped
242 ''&#x27;
243 t = Tensor(self.shape, self.device, self.dtype)
244 assert product(self.shape) == product(shape), \
245 'product of shape should be equal'
246 t.shape = shape
247 t.data = singa.Reshape(self.data, shape)
248 return t
249
250 def reset_like(self, t):
251 ''&#x27;Reset the shape, dtype and device as the given tensor.

Callers 15

_astype_helperMethod · 0.95
back_broadcastFunction · 0.45
ctensor2numpyFunction · 0.45
forwardMethod · 0.45
forwardMethod · 0.45
forwardMethod · 0.45
forwardMethod · 0.45
backwardMethod · 0.45
forwardMethod · 0.45
to_numpyFunction · 0.45
einsumFunction · 0.45
tensordotFunction · 0.45

Calls 2

TensorClass · 0.70
productFunction · 0.70

Tested by 15

_astype_helperMethod · 0.76
_relu_helperMethod · 0.36
_reshape_helperMethod · 0.36
_sum_helperMethod · 0.36
_Cos_helperMethod · 0.36
_Cosh_helperMethod · 0.36
_Sin_helperMethod · 0.36
_Sinh_helperMethod · 0.36
_Tan_helperMethod · 0.36
_Tanh_helperMethod · 0.36
_Acos_helperMethod · 0.36
_Acosh_helperMethod · 0.36