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

Method update_input

lite/src/mge/network_impl.cpp:705–794  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

703}
704
705void NetworkImplDft::update_input() {
706 auto device_type = m_user_config->device_type;
707 auto device_id = m_compnode_locator.device;
708 auto stream_id = m_compnode_locator.stream;
709 //! if cpu all input and output are host
710 if (device_type == LiteDeviceType::LITE_CPU) {
711 for (auto&& in : m_network_io->inputs) {
712 in.is_host = true;
713 }
714 }
715 //! if cross compnode model, modify the device input if it is not valid
716 if (m_nr_device_type > 1) {
717 for (auto&& in_tensor_iter : m_load_result.tensor_map) {
718 for (auto&& config_in : m_network_io->inputs) {
719 //! if tensor is set to device input
720 if (in_tensor_iter.first == config_in.name && !config_in.is_host) {
721 //! if the origin compnode of the tensor is not the device,
722 //! set the input to host
723 if (get_device_from_locator(
724 in_tensor_iter.second->comp_node().locator()) ==
725 LiteDeviceType::LITE_CPU) {
726 config_in.is_host = true;
727 LITE_WARN(
728 "The input tensor %s of the cross device model "
729 "should not from device.",
730 config_in.name.c_str());
731 }
732 }
733 }
734 }
735 }
736 for (auto&& in_tensor_iter : m_load_result.tensor_map) {
737 bool found = false;
738 for (auto&& config_in : m_network_io->inputs) {
739 if (in_tensor_iter.first == config_in.name) {
740 found = true;
741 if (config_in.is_host) {
742 config_in.lite_tensor = std::make_shared<Tensor>(
743 device_id, stream_id, device_type, true);
744 TensorHelper::implement(config_in.lite_tensor)
745 ->cast_final_safe<TensorImplDft>()
746 .m_host_tensor = in_tensor_iter.second;
747 config_in.lite_tensor->update_from_implement();
748 } else {
749 config_in.lite_tensor =
750 std::make_shared<Tensor>(device_id, stream_id, device_type);
751 config_in.lite_tensor->set_layout(
752 to_lite_layout(in_tensor_iter.second->layout()));
753 }
754 TensorHelper::implement(config_in.lite_tensor)
755 ->cast_final_safe<TensorImplDft>()
756 .m_record_reset =
757 m_user_config->options.comp_node_seq_record_level > 0;
758 if (config_in.config_layout.ndim &&
759 !(config_in.config_layout == config_in.lite_tensor->get_layout())) {
760 config_in.lite_tensor->set_layout(config_in.config_layout);
761 }
762 }

Callers

nothing calls this directly

Calls 11

locatorMethod · 0.45
comp_nodeMethod · 0.45
update_from_implementMethod · 0.45
set_layoutMethod · 0.45
layoutMethod · 0.45
get_layoutMethod · 0.45
push_backMethod · 0.45
emptyMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
eraseMethod · 0.45

Tested by

no test coverage detected