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

Function TEST

test/cpp/phi/core/test_tensor_array.cc:31–90  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

29using pstring = ::phi::dtype::pstring;
30
31TEST(tensor_array, tensor_array_not_init) {
32 const DDim dims({1, 2});
33 const DataType dtype{DataType::INT8};
34 const DataLayout layout{DataLayout::NHWC};
35 const LegacyLoD lod{};
36 DenseTensorMeta meta(dtype, dims, layout, lod);
37 DenseTensor tensor_0;
38 tensor_0.set_meta(meta);
39
40 std::vector<DenseTensor> tensors;
41 tensors.push_back(tensor_0);
42 tensors.push_back(tensor_0);
43 tensors.push_back(tensor_0);
44
45 TensorArray tensor_array(tensors);
46
47 try {
48 tensor_array.dims();
49 } catch (const common::enforce::EnforceNotMet& error) {
50 std::string ex_msg = error.what();
51 EXPECT_TRUE(ex_msg.find("dims") != std::string::npos);
52 }
53
54 try {
55 tensor_array.place();
56 } catch (const common::enforce::EnforceNotMet& error) {
57 std::string ex_msg = error.what();
58 EXPECT_TRUE(ex_msg.find("place") != std::string::npos);
59 }
60
61 try {
62 tensor_array.dtype();
63 } catch (const common::enforce::EnforceNotMet& error) {
64 std::string ex_msg = error.what();
65 EXPECT_TRUE(ex_msg.find("dtype") != std::string::npos);
66 }
67
68 try {
69 tensor_array.layout();
70 } catch (const common::enforce::EnforceNotMet& error) {
71 std::string ex_msg = error.what();
72 EXPECT_TRUE(ex_msg.find("layout") != std::string::npos);
73 }
74
75 try {
76 tensor_array.numel();
77 } catch (const common::enforce::EnforceNotMet& error) {
78 std::string ex_msg = error.what();
79 EXPECT_TRUE(ex_msg.find("numel") != std::string::npos);
80 }
81
82 try {
83 tensor_array.valid();
84 } catch (const common::enforce::EnforceNotMet& error) {
85 std::string ex_msg = error.what();
86 EXPECT_TRUE(ex_msg.find("valid") != std::string::npos);
87 }
88

Callers

nothing calls this directly

Calls 13

set_metaMethod · 0.45
push_backMethod · 0.45
dimsMethod · 0.45
whatMethod · 0.45
findMethod · 0.45
placeMethod · 0.45
dtypeMethod · 0.45
layoutMethod · 0.45
numelMethod · 0.45
validMethod · 0.45
initializedMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected