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

Method _negative_helper

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

Source from the content-addressed store, hash-verified

1561 self._not_helper(gpu_dev)
1562
1563 def _negative_helper(self, dev):
1564 X = np.array([0.1, 0, 0.4, 1. - 4, 0.9,
1565 -2.0]).reshape(3, 2).astype(np.float32)
1566 x = tensor.from_numpy(X)
1567 x.to_device(dev)
1568
1569 y = autograd.negative(x)
1570
1571 # frontend
1572 model = sonnx.to_onnx([x], [y])
1573 # print('The model is:\n{}'.format(model))
1574
1575 # backend
1576 sg_ir = sonnx.prepare(model, device=dev)
1577 sg_ir.is_graph = True
1578 y_t = sg_ir.run([x])
1579
1580 np.testing.assert_array_almost_equal(tensor.to_numpy(y),
1581 tensor.to_numpy(y_t[0]),
1582 decimal=5)
1583
1584 def test_negative_cpu(self):
1585 self._negative_helper(cpu_dev)

Callers 2

test_negative_cpuMethod · 0.95
test_negative_gpuMethod · 0.95

Calls 4

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

Tested by

no test coverage detected