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

Function _ctensor_eq_ndarray

test/python/test_api.py:75–91  ·  view source on GitHub ↗
(t1, np1)

Source from the content-addressed store, hash-verified

73
74
75def _ctensor_eq_ndarray(t1, np1):
76 d = t1.device()
77 t1.ToHost()
78 if t1.data_type() == singa_api.kInt:
79 np.testing.assert_array_almost_equal(t1.GetIntValue(t1.Size()),
80 np1.flatten())
81 elif t1.data_type() == singa_api.kFloat32:
82 np.testing.assert_array_almost_equal(t1.GetFloatValue(t1.Size()),
83 np1.flatten())
84
85 if np1.dtype == np.float32:
86 np.testing.assert_equal(t1.data_type(), singa_api.kFloat32)
87 elif np1.dtype == np.int32:
88 np.testing.assert_equal(t1.data_type(), singa_api.kInt)
89
90 np.testing.assert_array_almost_equal(t1.shape(), np1.shape)
91 t1.ToDevice(d)
92
93
94def print_t(t1):

Callers 1

_as_type2_helperMethod · 0.85

Calls 6

deviceMethod · 0.80
ToHostMethod · 0.80
data_typeMethod · 0.80
shapeMethod · 0.80
SizeMethod · 0.45
ToDeviceMethod · 0.45

Tested by

no test coverage detected