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

Function test_squeeze

imperative/python/test/unit/functional/test_tensor.py:478–498  ·  view source on GitHub ↗
(is_varnode)

Source from the content-addressed store, hash-verified

476
477@pytest.mark.parametrize("is_varnode", [True, False])
478def test_squeeze(is_varnode):
479 if is_varnode:
480 network = Network()
481 saved_symbolic_shape = set_symbolic_shape(False)
482 else:
483 network = None
484
485 x = Tensor(np.array([1, 2], dtype=np.int32).reshape(1, 1, 2, 1))
486 y = F.squeeze(x, -1)
487 np.testing.assert_equal(y.numpy(), np.array([[[1, 2]]]).astype(np.int32))
488
489 x = np.arange(6, dtype="float32").reshape(1, 2, 3, 1)
490 xx = make_tensor(x, network)
491
492 for axis in [None, 3, -4, (3, -4)]:
493 y = np.squeeze(x, axis)
494 yy = F.squeeze(xx, axis)
495 np.testing.assert_equal(y, yy.numpy())
496
497 if is_varnode:
498 set_symbolic_shape(saved_symbolic_shape)
499
500
501@pytest.mark.parametrize("is_varnode", [True, False])

Callers

nothing calls this directly

Calls 9

NetworkClass · 0.90
set_symbolic_shapeFunction · 0.90
TensorClass · 0.90
make_tensorFunction · 0.90
arrayMethod · 0.80
assert_equalMethod · 0.80
reshapeMethod · 0.45
numpyMethod · 0.45
astypeMethod · 0.45

Tested by

no test coverage detected