MCPcopy Create free account
hub / github.com/MegEngine/MegEngine / test_format

Function test_format

imperative/python/test/unit/core/test_tensor_wrapper.py:208–219  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

206
207
208def test_format():
209 x_np = np.random.rand(2, 4, 6, 8).astype("float32")
210 x = Tensor(x_np)
211 assert x.format == "default"
212 x.format = "nhwc"
213 assert x.format == "nhwc"
214 x2 = copy.copy(x)
215 assert x2.format == "nhwc"
216 np.testing.assert_allclose(x.numpy(), x2.numpy())
217 x3 = copy.deepcopy(x)
218 assert x3.format == "nhwc"
219 np.testing.assert_allclose(x.numpy(), x3.numpy())
220
221
222def test_name():

Callers

nothing calls this directly

Calls 5

numpyMethod · 0.95
TensorClass · 0.90
astypeMethod · 0.45
copyMethod · 0.45
numpyMethod · 0.45

Tested by

no test coverage detected