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

Method _Sqrt_helper

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

Source from the content-addressed store, hash-verified

983 self._Sub_helper(gpu_dev)
984
985 def _Sqrt_helper(self, dev):
986 X = np.array([0.1, 1.0, 0.4, 4.0, 0.9,
987 9.0]).reshape(3, 2).astype(np.float32)
988 x = tensor.from_numpy(X)
989 x.to_device(dev)
990 y = autograd.sqrt(x)
991
992 # frontend
993 model = sonnx.to_onnx([x], [y])
994 # print('The model is:\n{}'.format(model))
995
996 # backend
997 sg_ir = sonnx.prepare(model, device=dev, init_inputs=X)
998 sg_ir.is_graph = True
999 y_t = sg_ir.run([x])
1000
1001 np.testing.assert_array_almost_equal(tensor.to_numpy(y),
1002 tensor.to_numpy(y_t[0]),
1003 decimal=5)
1004
1005 def test_Sqrt_cpu(self):
1006 self._Sqrt_helper(cpu_dev)

Callers 2

test_Sqrt_cpuMethod · 0.95
test_Sqrt_gpuMethod · 0.95

Calls 4

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

Tested by

no test coverage detected