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

Method update_output

lite/src/mge/network_impl.cpp:845–931  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

843}
844
845void NetworkImplDft::update_output() {
846 auto device_type = m_user_config->device_type;
847 auto device_id = m_compnode_locator.device;
848 auto stream_id = m_compnode_locator.stream;
849 if (device_type == LiteDeviceType::LITE_CPU) {
850 for (auto&& out : m_network_io->outputs) {
851 out.is_host = true;
852 }
853 }
854 //! delete the output that is not the network
855 for (auto out_it = m_network_io->outputs.begin();
856 out_it != m_network_io->outputs.end();) {
857 if (std::find_if(
858 m_load_result.output_var_list.begin(),
859 m_load_result.output_var_list.end(), [out_it](const SymbolVar var) {
860 return var.node()->name() == out_it->name;
861 }) == m_load_result.output_var_list.end()) {
862 LITE_LOG("%s is not the network output, ignore it.", out_it->name.c_str());
863 out_it = m_network_io->outputs.erase(out_it);
864 } else {
865 out_it++;
866 }
867 }
868 //! user config the output tensor, so only compute the config output
869 if (m_compute_configured_output_only) {
870 LITE_ASSERT(
871 m_network_io->outputs.size() > 0,
872 "compute configured output only with no configure output.");
873 for (auto out_it = m_network_io->outputs.begin();
874 out_it != m_network_io->outputs.end(); out_it++) {
875 //! use pinned memory to copy form device
876 if (out_it->is_host) {
877 out_it->lite_tensor = std::make_shared<Tensor>(
878 device_id, stream_id, device_type, true);
879 } else {
880 out_it->lite_tensor =
881 std::make_shared<Tensor>(device_id, stream_id, device_type);
882 }
883 SymbolVar var;
884 for (auto&& out_var : m_load_result.output_var_list) {
885 if (out_var.node()->name() == out_it->name) {
886 var = out_var;
887 break;
888 }
889 }
890 try_infer_tensor_layout(out_it->lite_tensor, var);
891 output_tensor_copy_optimize(var, out_it->lite_tensor);
892 TensorHelper::implement(out_it->lite_tensor)
893 ->cast_final_safe<TensorImplDft>()
894 .m_record_reset =
895 m_user_config->options.comp_node_seq_record_level > 0;
896 }
897 //! user not set, use default output
898 } else {
899 for (auto&& out : m_load_result.output_var_list) {
900 std::shared_ptr<Tensor> lite_tensor = nullptr;
901 auto device = get_device_from_locator(out.node()->comp_node().locator());
902 auto it = std::find_if(

Callers

nothing calls this directly

Calls 9

beginMethod · 0.45
endMethod · 0.45
nameMethod · 0.45
nodeMethod · 0.45
eraseMethod · 0.45
sizeMethod · 0.45
locatorMethod · 0.45
comp_nodeMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected