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

Method _Greater_helper

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

Source from the content-addressed store, hash-verified

1010 self._Sqrt_helper(gpu_dev)
1011
1012 def _Greater_helper(self, dev):
1013 x0 = np.array([-0.9, -0.3, -0.1, 0.1, 0.5,
1014 0.9]).reshape(3, 2).astype(np.float32)
1015 x1 = np.array([0, -0.3, 0, 0.1, 0, 0.9]).reshape(3,
1016 2).astype(np.float32)
1017 x0 = tensor.from_numpy(x0)
1018 x1 = tensor.from_numpy(x1)
1019 x0.to_device(cpu_dev)
1020 x1.to_device(cpu_dev)
1021
1022 y = autograd.greater(x0, x1)
1023
1024 # frontend
1025 model = sonnx.to_onnx([x0, x1], [y])
1026 # print('The model is:\n{}'.format(model))
1027
1028 # backend
1029 sg_ir = sonnx.prepare(model, device=dev)
1030 sg_ir.is_graph = True
1031 y_t = sg_ir.run([x0, x1])
1032
1033 np.testing.assert_array_almost_equal(tensor.to_numpy(y),
1034 tensor.to_numpy(y_t[0]),
1035 decimal=5)
1036
1037 def test_Greater_cpu(self):
1038 self._Greater_helper(cpu_dev)

Callers 2

test_Greater_cpuMethod · 0.95
test_Greater_gpuMethod · 0.95

Calls 4

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

Tested by

no test coverage detected