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

Method test_transpose_then_reshape

test/python/test_tensor.py:339–351  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

337 a.reshape((2, 6)))
338
339 def test_transpose_then_reshape(self):
340 a = np.array([[[1.1, 1.1], [1.1, 1.1], [1.4, 1.3]],
341 [[1.1, 1.6], [1.1, 1.1], [1.1, 1.2]]])
342 TRANSPOSE_AXES = (2, 0, 1)
343 RESHAPE_DIMS = (2, 6)
344
345 ta = tensor.from_numpy(a)
346 ta = ta.transpose(TRANSPOSE_AXES)
347 ta = ta.reshape(RESHAPE_DIMS)
348
349 np.testing.assert_array_almost_equal(
350 tensor.to_numpy(ta),
351 np.reshape(a.transpose(TRANSPOSE_AXES), RESHAPE_DIMS))
352
353 def _concatenate_helper(self, dev):
354 np1 = np.random.random([5, 6, 7, 8]).astype(np.float32)

Callers

nothing calls this directly

Calls 2

transposeMethod · 0.45
reshapeMethod · 0.45

Tested by

no test coverage detected