| 29 | using pstring = ::phi::dtype::pstring; |
| 30 | |
| 31 | TEST(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 |
nothing calls this directly
no test coverage detected