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

Method _Sin_helper

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

Source from the content-addressed store, hash-verified

506 self._Cosh_helper(gpu_dev)
507
508 def _Sin_helper(self, dev):
509 x = np.array([0.1, -1.0, 0.4, 4.0, -0.9,
510 9.0]).reshape(3, 2).astype(np.float32)
511 x = tensor.from_numpy(x)
512 y = autograd.Sin()(x)[0]
513
514 # frontend
515 model = sonnx.to_onnx([x], [y])
516 # print('The model is:\n{}'.format(model))
517
518 # backend
519 sg_ir = sonnx.prepare(model, device=dev)
520 sg_ir.is_graph = True
521 y_t = sg_ir.run([x])
522
523 np.testing.assert_array_almost_equal(tensor.to_numpy(y),
524 tensor.to_numpy(y_t[0]),
525 decimal=5)
526
527 def test_Sin_cpu(self):
528 self._Sin_helper(cpu_dev)

Callers 2

test_Sin_cpuMethod · 0.95
test_Sin_gpuMethod · 0.95

Calls 3

prepareMethod · 0.80
reshapeMethod · 0.45
runMethod · 0.45

Tested by

no test coverage detected