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

Method make_output_spec

lite/src/mge/network_impl.cpp:228–271  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

226}
227
228void NetworkImplDft::make_output_spec() {
229 m_output_spec.clear();
230 for (auto&& out : m_network_io->outputs) {
231 if (m_load_result.output_var_map.count(out.name)) {
232 auto&& load_out = m_load_result.output_var_map[out.name];
233 auto cb = [&out, this](const mgb::DeviceTensorND& dv) mutable {
234 mgb::CompNode comp_node = dv.comp_node();
235 if (out.io_type == LiteIOType::LITE_IO_SHAPE) {
236 auto mgb_layout = dv.layout();
237 out.lite_tensor->set_layout(to_lite_layout(mgb_layout));
238 } else {
239 TensorHelper::implement(out.lite_tensor)
240 ->cast_final_safe<TensorImplDft>()
241 .copy_from_mge_tensor(dv);
242 out.lite_tensor->update_from_implement();
243 }
244 if (m_async) {
245 out.have_sync = true;
246 bool need_exec_cb = true;
247 for (auto&& j : m_network_io->outputs) {
248 if (!j.have_sync) {
249 need_exec_cb = false;
250 }
251 }
252 if (need_exec_cb) {
253 for (auto&& j : m_network_io->outputs) {
254 j.have_sync = false;
255 }
256 comp_node.add_callback([this]() { finish(); });
257 }
258 }
259 };
260 //! if write to user-specified memory, the CallbackCaller must be nullptr.
261 if (m_user_config->options.force_output_use_user_specified_memory ||
262 m_user_config->options.force_output_dynamic_alloc) {
263 m_output_spec.emplace_back(load_out, nullptr);
264 } else {
265 m_output_spec.emplace_back(load_out, std::move(cb));
266 }
267 } else {
268 LITE_THROW(ssprintf("no output named : %s in the mode", out.name.c_str()));
269 }
270 }
271}
272
273void NetworkImplDft::replace_src_discrete_input_opr_pass() {
274 mgb::ThinHashMap<mgb::SymbolVar, mgb::SymbolVar> out_var_map;

Callers

nothing calls this directly

Calls 9

copy_from_mge_tensorMethod · 0.80
emplace_backMethod · 0.80
clearMethod · 0.45
countMethod · 0.45
comp_nodeMethod · 0.45
layoutMethod · 0.45
set_layoutMethod · 0.45
update_from_implementMethod · 0.45
add_callbackMethod · 0.45

Tested by

no test coverage detected