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

Method transpose

python/singa/tensor.py:191–211  ·  view source on GitHub ↗

To transpose the tensor Args: axes: axes to transpose Returns: new transposed tensor

(self, axes=None)

Source from the content-addressed store, hash-verified

189 return self.data.transpose()
190
191 def transpose(self, axes=None):
192 ''' To transpose the tensor
193
194 Args:
195 axes: axes to transpose
196
197 Returns:
198 new transposed tensor
199 '''
200 t = Tensor(self.shape, self.device, self.dtype)
201 if axes is None:
202 tshape = [self.shape[x] for x in range(len(t.shape))]
203 t.shape = tuple(tshape)
204 t.data = singa.DefaultTranspose(self.data)
205 else:
206 if (len(axes) != len(self.shape)):
207 raise ValueError('dimensions do not match')
208 tshape = [self.shape[x] for x in axes]
209 t.shape = tuple(tshape)
210 t.data = singa.Transpose(self.data, list(axes))
211 return t
212
213 def size(self): # TODO(wangwei) compute size
214 '''

Callers 15

_testMethod · 0.95
initializeMethod · 0.45
forwardMethod · 0.45
runMethod · 0.45
data.pyFile · 0.45
flipFunction · 0.45
flip_downFunction · 0.45
is_transposeMethod · 0.45
transposeFunction · 0.45
_transpose_helperMethod · 0.45
test_transposeMethod · 0.45
test_gpu_6d_transposeMethod · 0.45

Calls 2

TensorClass · 0.70
tupleFunction · 0.50

Tested by 8

_testMethod · 0.76
_transpose_helperMethod · 0.36
test_transposeMethod · 0.36
test_gpu_6d_transposeMethod · 0.36
_transpose_helperMethod · 0.36
TESTFunction · 0.36