the opr loader should make sure the exist of tensors and the number of tensor, here just assert it.
| 611 | //! the opr loader should make sure the exist of tensors and the number of |
| 612 | //! tensor, here just assert it. |
| 613 | std::shared_ptr<HostTensorND> GraphLoaderOSSV2::OprLoadContextImpl::load_tensor() { |
| 614 | mgb_assert( |
| 615 | m_current_opr->tensors() && |
| 616 | m_cur_opr_tensor_cnt < m_current_opr->tensors()->size()); |
| 617 | auto tensor = m_current_opr->tensors()->Get(m_cur_opr_tensor_cnt++); |
| 618 | auto comp_node = load_comp_node(tensor->comp_node()); |
| 619 | auto layout = load_tensor_layout_without_format(tensor); |
| 620 | auto ret = std::make_shared<HostTensorND>(comp_node, layout); |
| 621 | |
| 622 | auto&& loader = m_loader->m_cur_load_config->tensor_value_loader; |
| 623 | if (tensor->data() && tensor->data()->size() > 0) { |
| 624 | fill_tensor_memory( |
| 625 | *ret, tensor->data()->data(), tensor->data()->size(), |
| 626 | m_loader->m_file->is_shared_memory(), loader); |
| 627 | } |
| 628 | if (tensor->name()) { |
| 629 | m_tensor_map[tensor->name()->str()] = ret; |
| 630 | } |
| 631 | if (auto&& mod = m_loader->m_cur_load_config->tensor_modifier) { |
| 632 | bool has_value = false; |
| 633 | if (tensor && tensor->data()) { |
| 634 | has_value = tensor->data()->size() != 0; |
| 635 | } |
| 636 | mod(tensor->name() ? tensor->name()->str() : "", has_value, *ret); |
| 637 | } |
| 638 | return ret; |
| 639 | } |
| 640 | |
| 641 | std::shared_ptr<DeviceTensorND> GraphLoaderOSSV2::OprLoadContextImpl:: |
| 642 | load_tensor_shared(bool copy_immediatly) { |
nothing calls this directly
no test coverage detected