| 18 | using namespace interpreter; |
| 19 | |
| 20 | TEST(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 | |
| 49 | TEST(TestImperative, InterpreterApplyOp) { |
| 50 | HostTensorGenerator<> gen; |
nothing calls this directly
no test coverage detected