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

Method _Tanh_helper

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

Source from the content-addressed store, hash-verified

584 self._Tan_helper(gpu_dev)
585
586 def _Tanh_helper(self, dev):
587 x = np.array([0.1, -1.0, 0.4, 4.0, -0.9,
588 9.0]).reshape(3, 2).astype(np.float32)
589 x = tensor.from_numpy(x)
590 y = autograd.Tanh()(x)[0]
591
592 # frontend
593 model = sonnx.to_onnx([x], [y])
594 # print('The model is:\n{}'.format(model))
595
596 # backend
597 sg_ir = sonnx.prepare(model, device=dev)
598 sg_ir.is_graph = True
599 y_t = sg_ir.run([x])
600
601 np.testing.assert_array_almost_equal(tensor.to_numpy(y),
602 tensor.to_numpy(y_t[0]),
603 decimal=5)
604
605 def test_Tanh_cpu(self):
606 self._Tanh_helper(cpu_dev)

Callers 2

test_Tanh_cpuMethod · 0.95
test_Tanh_gpuMethod · 0.95

Calls 3

prepareMethod · 0.80
reshapeMethod · 0.45
runMethod · 0.45

Tested by

no test coverage detected