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

Function TEST

imperative/src/test/interpreter_test.cpp:20–47  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

18using namespace interpreter;
19
20TEST(TestImperative, InterpreterPut) {
21 HostTensorGenerator<> gen;
22 auto h0 = gen({3});
23 auto&& channel = Interpreter::inst().create_channel();
24 auto tensor_handle = channel->put(*h0, true);
25 auto tensor_info = reinterpret_cast<intl::TensorInfo*>(tensor_handle);
26 channel->sync();
27 ASSERT_TRUE(tensor_info->status == intl::TensorInfo::Produced);
28 //! because tensor elems is less than TensorShape::MAX_NDIM, stored it
29 //! directly
30 ASSERT_EQ(tensor_info->ptr->get_value().raw_ptr(), h0->raw_ptr());
31 auto shape = channel->get_shape(tensor_handle);
32 ASSERT_TRUE(shape.ndim == 1);
33 ASSERT_TRUE(shape.total_nr_elems() == 3);
34
35 auto h2 = gen({10});
36 auto tensor_handle2 = channel->put(*h2, false);
37 auto tensor_handle2_once = channel->put(*h2, false);
38 channel->sync();
39 ASSERT_NE(tensor_handle2_once, tensor_handle2);
40 auto finded = MultiCNConstTensorCache::inst().lookup(*h2);
41 ASSERT_TRUE(finded.get());
42 //! Device tensor ptr is not equal host tensor ptr
43 ASSERT_NE(finded->raw_ptr_not_for_readwrite(), h2->raw_ptr());
44 channel->del(tensor_handle);
45 channel->del(tensor_handle2);
46 channel->del(tensor_handle2_once);
47}
48
49TEST(TestImperative, InterpreterApplyOp) {
50 HostTensorGenerator<> gen;

Callers

nothing calls this directly

Calls 15

instFunction · 0.85
create_channelMethod · 0.80
get_shapeMethod · 0.80
delMethod · 0.80
genFunction · 0.50
makeFunction · 0.50
putMethod · 0.45
syncMethod · 0.45
raw_ptrMethod · 0.45
get_valueMethod · 0.45
total_nr_elemsMethod · 0.45
lookupMethod · 0.45

Tested by

no test coverage detected