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

Method _shape_helper

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

Source from the content-addressed store, hash-verified

1407 self._min_helper(gpu_dev)
1408
1409 def _shape_helper(self, dev):
1410 x = np.array([0.1, -1.0, 0.4, 4.0, -0.9,
1411 9.0]).reshape(3, 2).astype(np.float32)
1412 x = tensor.from_numpy(x)
1413 x.to_device(dev)
1414
1415 y = autograd.shape(x)
1416
1417 # frontend
1418 model = sonnx.to_onnx([x], [y])
1419 # print('The model is:\n{}'.format(model))
1420
1421 # backend
1422 sg_ir = sonnx.prepare(model, device=dev)
1423 sg_ir.is_graph = True
1424 y_t = sg_ir.run([x])
1425
1426 np.testing.assert_array_almost_equal(tensor.to_numpy(y),
1427 tensor.to_numpy(y_t[0]),
1428 decimal=5)
1429
1430 def test_shape_cpu(self):
1431 self._shape_helper(cpu_dev)

Callers 2

test_shape_cpuMethod · 0.95
test_shape_gpuMethod · 0.95

Calls 5

shapeMethod · 0.80
prepareMethod · 0.80
reshapeMethod · 0.45
to_deviceMethod · 0.45
runMethod · 0.45

Tested by

no test coverage detected