| 226 | } |
| 227 | |
| 228 | void 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 | |
| 273 | void NetworkImplDft::replace_src_discrete_input_opr_pass() { |
| 274 | mgb::ThinHashMap<mgb::SymbolVar, mgb::SymbolVar> out_var_map; |
nothing calls this directly
no test coverage detected