| 42 | np.testing.assert_equal(out.cpu().numpy(), [[1,1,1,1],[2,2,2,2],[3,3,3,3],[4,4,4,4]]) |
| 43 | |
| 44 | def test_reshape(self): |
| 45 | a = torch.Tensor([[1,2],[3,4]]).to(device) |
| 46 | np.testing.assert_equal(a.reshape(4).cpu().numpy(), [1,2,3,4]) |
| 47 | np.testing.assert_equal(a.reshape(2,1,2).cpu().numpy(), [[[1,2]],[[3,4]]]) |
| 48 | np.testing.assert_equal(a.unsqueeze(1).cpu().numpy(), [[[1,2]],[[3,4]]]) |
| 49 | np.testing.assert_equal(a.unsqueeze(1).unsqueeze(1).cpu().numpy(), [[[[1,2]]],[[[3,4]]]]) |
| 50 | np.testing.assert_equal(a.unsqueeze(1).unsqueeze(1).squeeze().cpu().numpy(), [[1,2],[3,4]]) |
| 51 | |
| 52 | def test_permute(self): |
| 53 | a = torch.Tensor([[1,2],[3,4]]).to(device) |