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

Method _mean_helper

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

Source from the content-addressed store, hash-verified

1156 self._softsign_helper(gpu_dev)
1157
1158 def _mean_helper(self, dev):
1159 x0 = np.array([-0.9, -0.3, -0.1, 0.1, 0.5,
1160 0.9]).reshape(3, 2).astype(np.float32)
1161 x1 = np.array([0, -0.3, 0, 0.1, 0, 0.9]).reshape(3,
1162 2).astype(np.float32)
1163 x0 = tensor.from_numpy(x0)
1164 x1 = tensor.from_numpy(x1)
1165 x0.to_device(dev)
1166 x1.to_device(dev)
1167
1168 y = autograd.mean(x0, x1)
1169
1170 # frontend
1171 model = sonnx.to_onnx([x0, x1], [y])
1172 # print('The model is:\n{}'.format(model))
1173
1174 # backend
1175 sg_ir = sonnx.prepare(model, device=dev)
1176 sg_ir.is_graph = True
1177 y_t = sg_ir.run([x0, x1])
1178
1179 np.testing.assert_array_almost_equal(tensor.to_numpy(y),
1180 tensor.to_numpy(y_t[0]),
1181 decimal=5)
1182
1183 def test_mean_cpu(self):
1184 self._mean_helper(cpu_dev)

Callers 2

test_mean_cpuMethod · 0.95
test_mean_gpuMethod · 0.95

Calls 4

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

Tested by

no test coverage detected