MCPcopy Create free account
hub / github.com/MegEngine/MegEngine / TEST

Function TEST

lite/test/test_tensor.cpp:16–46  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

14using namespace lite;
15
16TEST(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
48TEST(TestTensor, SetLayoutReAlloc) {
49 Layout layout{{1, 3, 224, 224}, 4};

Callers

nothing calls this directly

Calls 15

get_device_countFunction · 0.85
host_tensorMethod · 0.80
get_elem_sizeMethod · 0.80
checkFunction · 0.50
concatFunction · 0.50
powFunction · 0.50
get_device_typeMethod · 0.45
get_layoutMethod · 0.45
dev_tensorMethod · 0.45
get_memory_ptrMethod · 0.45
set_layoutMethod · 0.45

Tested by

no test coverage detected