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

Method _Sign_helper

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

Source from the content-addressed store, hash-verified

893
894
895 def _Sign_helper(self, dev):
896 x = np.array([0.8, -1.2, 3.3, -3.6, -0.5,
897 0.5]).reshape(3, 2).astype(np.float32)
898 x = tensor.from_numpy(x)
899 y = autograd.sign(x)
900
901 # frontend
902 model = sonnx.to_onnx([x], [y])
903 # print('The model is:\n{}'.format(model))
904
905 # backend
906 sg_ir = sonnx.prepare(model, device=dev)
907 sg_ir.is_graph = True
908 y_t = sg_ir.run([x])
909
910 np.testing.assert_array_almost_equal(tensor.to_numpy(y),
911 tensor.to_numpy(y_t[0]),
912 decimal=5)
913
914 def test_Sign_cpu(self):
915 self._Sign_helper(cpu_dev)

Callers 2

test_Sign_cpuMethod · 0.95
test_Sign_gpuMethod · 0.95

Calls 3

prepareMethod · 0.80
reshapeMethod · 0.45
runMethod · 0.45

Tested by

no test coverage detected