(self)
| 2849 | helper_test_op([(45,65), (45,65), (45,65)], lambda x,y,z: torch.cat((x,y,z), dim), lambda x,y,z: x.cat(y, z, dim=dim)) |
| 2850 | |
| 2851 | def test_stack(self): |
| 2852 | for dim in range(-1, 3): |
| 2853 | helper_test_op([(5,6,3), (5,6,3), (5,6,3)], lambda x, y, z: torch.stack((x, y, z), dim), lambda x, y, z: Tensor.stack(x, y, z, dim=dim)) |
| 2854 | helper_test_op([(5,6,3), (5,6,3), (5,6,3)], lambda x, y, z: torch.stack((x, y, z), dim), lambda x, y, z: Tensor.stack((x, y, z), dim=dim)) |
| 2855 | |
| 2856 | with self.assertRaises(IndexError): |
| 2857 | Tensor.stack(Tensor.randn(45, 65, 3), dim=77) |
| 2858 | with self.assertRaises(ValueError): |
| 2859 | Tensor.stack((Tensor([1, 2]), Tensor([3, 4])), Tensor([5, 6])) |
| 2860 | |
| 2861 | a = Tensor(3.14) |
| 2862 | np.testing.assert_allclose(Tensor.stack(a, a).numpy(), Tensor([3.14, 3.14]).numpy()) |
| 2863 | |
| 2864 | def test_stack_max(self): |
| 2865 | helper_test_op(None, lambda x, y: torch.stack((x, y)).max(axis=0)[0], lambda x, y: Tensor.stack(x, y).max(axis=0), vals=[[1.], [2.]]) |
nothing calls this directly
no test coverage detected