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

Method _test

test/python/test_api.py:293–310  ·  view source on GitHub ↗
(s1, s2, axis1, axis2, s3, s_op, n_op, dev)

Source from the content-addressed store, hash-verified

291 def _transpose_and_arithmetic_op_broadcast_helper(self, dev):
292
293 def _test(s1, s2, axis1, axis2, s3, s_op, n_op, dev):
294 x_0 = np.random.random(s1).astype(np.float32)
295 y_0 = np.random.random(s2).astype(np.float32)
296
297 x0 = tensor.Tensor(device=dev, data=x_0)
298 y0 = tensor.Tensor(device=dev, data=y_0)
299
300 x1 = x0.transpose(axis1)
301 y1 = y0.transpose(axis2)
302
303 z0 = tensor._call_singa_func(s_op, x1.data, y1.data)
304 z0.to_host()
305
306 np.testing.assert_array_almost_equal(
307 tensor.to_numpy(z0),
308 n_op(x_0.transpose(axis1), y_0.transpose(axis2)))
309 np.testing.assert_array_almost_equal(z0.shape, s3)
310 return
311
312 for s_op, n_op in zip([
313 singa_api.Pow,

Callers

nothing calls this directly

Calls 3

transposeMethod · 0.95
TensorMethod · 0.80
to_hostMethod · 0.45

Tested by

no test coverage detected