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

Function TEST

test/cpp/phi/api/test_slice_api.cc:28–44  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

26namespace tests {
27
28TEST(Tensor, slice) {
29 auto x = paddle::experimental::full({4, 3}, 1, phi::DataType::INT64);
30 auto slice_x = x.slice(1, 2);
31
32 // check slice result
33 ASSERT_EQ(slice_x.dims().size(), 2);
34 ASSERT_EQ(slice_x.dims()[0], 1);
35 ASSERT_EQ(slice_x.dims()[1], 3);
36 ASSERT_EQ(slice_x.numel(), 3);
37 ASSERT_EQ(slice_x.is_cpu(), true);
38 ASSERT_EQ(slice_x.type(), phi::DataType::INT64);
39 ASSERT_EQ(slice_x.layout(), phi::DataLayout::NCHW);
40 ASSERT_EQ(slice_x.initialized(), true);
41 for (int64_t i = 0; i < slice_x.numel(); ++i) {
42 ASSERT_EQ(slice_x.mutable_data<int64_t>()[i], 1);
43 }
44}
45
46} // namespace tests
47} // namespace paddle

Callers

nothing calls this directly

Calls 9

fullFunction · 0.50
sliceMethod · 0.45
sizeMethod · 0.45
dimsMethod · 0.45
numelMethod · 0.45
is_cpuMethod · 0.45
typeMethod · 0.45
layoutMethod · 0.45
initializedMethod · 0.45

Tested by

no test coverage detected