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

Method _transpose_helper

test/python/test_onnx.py:1316–1336  ·  view source on GitHub ↗
(self, dev)

Source from the content-addressed store, hash-verified

1314 self._mul_helper(gpu_dev)
1315
1316 def _transpose_helper(self, dev):
1317 x = np.random.randn(3, 2, 1)
1318 y = x.transpose(1, 2, 0)
1319
1320 x = tensor.from_numpy(x)
1321 x.to_device(cpu_dev)
1322
1323 y = autograd.transpose(x, (1, 2, 0))
1324
1325 # frontend
1326 model = sonnx.to_onnx([x], [y])
1327 # print('The model is:\n{}'.format(model))
1328
1329 # backend
1330 sg_ir = sonnx.prepare(model, device=dev)
1331 sg_ir.is_graph = True
1332 y_t = sg_ir.run([x])
1333
1334 np.testing.assert_array_almost_equal(tensor.to_numpy(y),
1335 tensor.to_numpy(y_t[0]),
1336 decimal=5)
1337
1338 def test_transpose_cpu(self):
1339 self._transpose_helper(cpu_dev)

Callers 2

test_transpose_cpuMethod · 0.95
test_transpose_gpuMethod · 0.95

Calls 4

prepareMethod · 0.80
transposeMethod · 0.45
to_deviceMethod · 0.45
runMethod · 0.45

Tested by

no test coverage detected