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

Method _Cos_helper

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

Source from the content-addressed store, hash-verified

454 self._sum_helper(gpu_dev)
455
456 def _Cos_helper(self, dev):
457 x = np.array([0.1, -1.0, 0.4, 4.0, -0.9,
458 9.0]).reshape(3, 2).astype(np.float32)
459 x = tensor.from_numpy(x)
460 y = autograd.Cos()(x)[0]
461
462 # frontend
463 model = sonnx.to_onnx([x], [y])
464 # print('The model is:\n{}'.format(model))
465
466 # backend
467 sg_ir = sonnx.prepare(model, device=dev)
468 sg_ir.is_graph = True
469 y_t = sg_ir.run([x])
470
471 np.testing.assert_array_almost_equal(tensor.to_numpy(y),
472 tensor.to_numpy(y_t[0]),
473 decimal=5)
474
475 def test_Cos_cpu(self):
476 self._Cos_helper(cpu_dev)

Callers 2

test_Cos_cpuMethod · 0.95
test_Cos_gpuMethod · 0.95

Calls 3

prepareMethod · 0.80
reshapeMethod · 0.45
runMethod · 0.45

Tested by

no test coverage detected