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

Method _pow_helper

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

Source from the content-addressed store, hash-verified

1188 self._mean_helper(gpu_dev)
1189
1190 def _pow_helper(self, dev):
1191 x0 = np.array([7, 5, 0.2, 0.1, 0.3, 4]).reshape(3, 2).astype(np.float32)
1192 x1 = np.array([-1.0, 2.0, -1.0, -2.1, 1.0,
1193 -2.0]).reshape(3, 2).astype(np.float32)
1194 x0 = tensor.from_numpy(x0)
1195 x1 = tensor.from_numpy(x1)
1196 x0.to_device(dev)
1197 x1.to_device(dev)
1198
1199 y = autograd.mean(x0, x1)
1200
1201 # frontend
1202 model = sonnx.to_onnx([x0, x1], [y])
1203 # print('The model is:\n{}'.format(model))
1204
1205 # backend
1206 sg_ir = sonnx.prepare(model, device=dev)
1207 sg_ir.is_graph = True
1208 y_t = sg_ir.run([x0, x1])
1209
1210 np.testing.assert_array_almost_equal(tensor.to_numpy(y),
1211 tensor.to_numpy(y_t[0]),
1212 decimal=5)
1213
1214 def test_pow_cpu(self):
1215 self._pow_helper(cpu_dev)

Callers 2

test_pow_cpuMethod · 0.95
test_pow_gpuMethod · 0.95

Calls 4

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

Tested by

no test coverage detected