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

Method _identity_helper

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

Source from the content-addressed store, hash-verified

1072 self._HardSigmoid_helper(gpu_dev)
1073
1074 def _identity_helper(self, dev):
1075 x = np.array([-0.9, -0.3, -0.1, 0.1, 0.5,
1076 0.9]).reshape(3, 2).astype(np.float32)
1077 x = tensor.from_numpy(x)
1078 x.to_device(dev)
1079
1080 y = autograd.identity(x)
1081
1082 # frontend
1083 model = sonnx.to_onnx([x], [y])
1084 # print('The model is:\n{}'.format(model))
1085
1086 # backend
1087 sg_ir = sonnx.prepare(model, device=dev)
1088 sg_ir.is_graph = True
1089 y_t = sg_ir.run([x])
1090
1091 np.testing.assert_array_almost_equal(tensor.to_numpy(y),
1092 tensor.to_numpy(y_t[0]),
1093 decimal=5)
1094
1095 def test_identity_cpu(self):
1096 self._identity_helper(cpu_dev)

Callers 2

test_identity_cpuMethod · 0.95
test_identity_gpuMethod · 0.95

Calls 4

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

Tested by

no test coverage detected