| 72 | // ============= Tensor Creation Tests ============= |
| 73 | |
| 74 | TEST_F(TensorBasicTest, EmptyTensorCreation) { |
| 75 | // Create empty tensors |
| 76 | auto tensor_custom = Tensor::empty({2, 3, 4}, Device::CUDA); |
| 77 | auto tensor_torch = torch::empty({2, 3, 4}, |
| 78 | torch::TensorOptions().dtype(torch::kFloat32).device(torch::kCUDA)); |
| 79 | |
| 80 | // Check properties match PyTorch |
| 81 | EXPECT_EQ(tensor_custom.shape().rank(), tensor_torch.dim()); |
| 82 | EXPECT_EQ(tensor_custom.shape()[0], tensor_torch.size(0)); |
| 83 | EXPECT_EQ(tensor_custom.shape()[1], tensor_torch.size(1)); |
| 84 | EXPECT_EQ(tensor_custom.shape()[2], tensor_torch.size(2)); |
| 85 | EXPECT_EQ(tensor_custom.numel(), tensor_torch.numel()); |
| 86 | EXPECT_TRUE(tensor_custom.is_valid()); |
| 87 | EXPECT_FALSE(tensor_custom.is_empty()); |
| 88 | |
| 89 | // Both should be contiguous |
| 90 | EXPECT_TRUE(tensor_custom.is_contiguous()); |
| 91 | EXPECT_TRUE(tensor_torch.is_contiguous()); |
| 92 | } |
| 93 | |
| 94 | TEST_F(TensorBasicTest, ZerosTensorCreation) { |
| 95 | // Create zeros tensors |
nothing calls this directly
no test coverage detected