Test for tensor_split with sections
| 32 | |
| 33 | // Test for tensor_split with sections |
| 34 | TEST(TensorSplitTest, TensorSplitWithSections) { |
| 35 | // Create a test tensor [0, 1, 2, ..., 8] (9 elements, evenly divisible by 3) |
| 36 | auto tensor = at::arange(9, at::TensorOptions().dtype(at::kFloat)); |
| 37 | |
| 38 | // Split into 3 sections along dim 0 |
| 39 | auto splits = tensor.tensor_split(3, 0); |
| 40 | |
| 41 | EXPECT_EQ(splits.size(), 3); |
| 42 | EXPECT_EQ(splits[0].numel(), 3); // [0, 1, 2] |
| 43 | EXPECT_EQ(splits[1].numel(), 3); // [3, 4, 5] |
| 44 | EXPECT_EQ(splits[2].numel(), 3); // [6, 7, 8] |
| 45 | |
| 46 | // Verify first split values |
| 47 | EXPECT_FLOAT_EQ(splits[0][0].item<float>(), 0.0f); |
| 48 | EXPECT_FLOAT_EQ(splits[0][2].item<float>(), 2.0f); |
| 49 | } |
| 50 | |
| 51 | // Test for tensor_split with indices (PyTorch semantics: indices are positions) |
| 52 | TEST(TensorSplitTest, TensorSplitWithIndices) { |
nothing calls this directly
no test coverage detected