| 14 | using namespace lite; |
| 15 | |
| 16 | TEST(TestTensor, Basic) { |
| 17 | Layout layout{{1, 3, 224, 224}, 4}; |
| 18 | Tensor tensor1(LiteDeviceType::LITE_CPU); |
| 19 | Tensor tensor2(LiteDeviceType::LITE_CPU, layout); |
| 20 | Tensor tensor3(LiteDeviceType::LITE_CPU, layout); |
| 21 | //! mge tensor has created |
| 22 | ASSERT_TRUE(TensorHelper::implement(&tensor1)); |
| 23 | ASSERT_TRUE(TensorHelper::implement(&tensor2)); |
| 24 | ASSERT_TRUE(TensorHelper::implement(&tensor3)); |
| 25 | //! check member |
| 26 | ASSERT_EQ(tensor2.get_device_type(), LiteDeviceType::LITE_CPU); |
| 27 | ASSERT_EQ(tensor2.get_layout(), layout); |
| 28 | ASSERT_EQ(tensor3.get_layout(), layout); |
| 29 | //! check the real tensor |
| 30 | ASSERT_EQ(tensor2.get_tensor_total_size_in_byte(), 1 * 3 * 224 * 224 * 4); |
| 31 | ASSERT_EQ(tensor3.get_tensor_total_size_in_byte(), 1 * 3 * 224 * 224 * 4); |
| 32 | |
| 33 | ASSERT_TRUE(TensorHelper::implement(&tensor1) |
| 34 | ->cast_final_safe<TensorImplDft>() |
| 35 | .host_tensor()); |
| 36 | |
| 37 | ASSERT_FALSE(TensorHelper::implement(&tensor1) |
| 38 | ->cast_final_safe<TensorImplDft>() |
| 39 | .dev_tensor()); |
| 40 | ASSERT_FALSE(TensorHelper::implement(&tensor1) |
| 41 | ->cast_final_safe<TensorImplDft>() |
| 42 | .dev_tensor()); |
| 43 | ASSERT_TRUE(TensorHelper::implement(&tensor1) |
| 44 | ->cast_final_safe<TensorImplDft>() |
| 45 | .host_tensor()); |
| 46 | } |
| 47 | |
| 48 | TEST(TestTensor, SetLayoutReAlloc) { |
| 49 | Layout layout{{1, 3, 224, 224}, 4}; |
nothing calls this directly
no test coverage detected