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

Method _concat_helper

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

Source from the content-addressed store, hash-verified

207 self._add_helper(gpu_dev)
208
209 def _concat_helper(self, dev):
210 X1 = np.random.randn(3, 4, 5).astype(np.float32)
211 X2 = np.random.randn(3, 4, 5).astype(np.float32)
212
213 x1 = tensor.from_numpy(X1)
214 x2 = tensor.from_numpy(X2)
215 x1.to_device(dev)
216 x2.to_device(dev)
217 y = autograd.Concat()(x1, x2)[0]
218
219 # frontend
220 model = sonnx.to_onnx([x1, x2], [y])
221
222 # backend
223 sg_ir = sonnx.prepare(model, device=dev)
224 sg_ir.is_graph = True
225 y_t = sg_ir.run([x1, x2])
226
227 np.testing.assert_array_almost_equal(tensor.to_numpy(y),
228 tensor.to_numpy(y_t[0]),
229 decimal=5)
230
231 def test_concat_cpu(self):
232 self._concat_helper(cpu_dev)

Callers 2

test_concat_cpuMethod · 0.95
test_concat_gpuMethod · 0.95

Calls 3

prepareMethod · 0.80
to_deviceMethod · 0.45
runMethod · 0.45

Tested by

no test coverage detected