MCPcopy Create free account
hub / github.com/PaddlePaddle/Paddle / TEST

Function TEST

test/cpp/compat/ATen_split_test.cc:34–49  ·  view source on GitHub ↗

Test for tensor_split with sections

Source from the content-addressed store, hash-verified

32
33// Test for tensor_split with sections
34TEST(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)
52TEST(TensorSplitTest, TensorSplitWithIndices) {

Callers

nothing calls this directly

Calls 15

TensorOptionsFunction · 0.85
tensor_splitMethod · 0.80
split_with_sizesMethod · 0.80
unsafe_splitMethod · 0.80
hsplitMethod · 0.80
vsplitMethod · 0.80
dsplitMethod · 0.80
tensor_split_symintMethod · 0.80
split_symintMethod · 0.80
is_cudaMethod · 0.80
arangeFunction · 0.50

Tested by

no test coverage detected