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

Function assertTensorEqual

test/python/test_opt.py:32–44  ·  view source on GitHub ↗
(x,y,decimal=6)

Source from the content-addressed store, hash-verified

30from cuda_helper import gpu_dev, cpu_dev
31
32def assertTensorEqual(x,y,decimal=6):
33 assert x.shape == y.shape
34 assert x.dtype == y.dtype
35 assert x.device.id() == y.device.id()
36 d = x.device
37 x.to_host()
38 y.to_host()
39 np.testing.assert_array_almost_equal(
40 x.data.GetFloatValue(int(x.size())),
41 y.data.GetFloatValue(int(y.size())),
42 decimal)
43 x.to_device(d)
44 y.to_device(d)
45
46def on_cpu_gpu(func):
47 @functools.wraps(func)

Calls 4

idMethod · 0.45
to_hostMethod · 0.45
sizeMethod · 0.45
to_deviceMethod · 0.45

Tested by

no test coverage detected