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

Method apply_op_impl

imperative/src/impl/interpreter/interpreter_impl.cpp:448–485  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

446}
447
448SmallVector<Handle> ChannelImpl::apply_op_impl(
449 std::shared_ptr<OpDef> op, const SmallVector<Handle>& inputs) {
450 auto& state = get_channel_state();
451 for (auto i : inputs) {
452 mgb_assert(
453 m_valid_handle.find(i) != m_valid_handle.end(), "invalid handle: %p",
454 i);
455 }
456 SmallVector<TensorInfo*> input_infos;
457 SmallVector<LogicalTensorDesc> input_descs;
458 {
459 MGB_LOCK_GUARD(m_info_spin);
460 for (auto i : inputs) {
461 auto info = reinterpret_cast<TensorInfo*>(i);
462 mgb_assert(
463 !info->invalid,
464 "an input tensor is unusable due to previous error");
465 input_infos.push_back(info);
466 input_descs.push_back(info->desc);
467 }
468 }
469
470 SmallVector<Handle> outputs;
471 DispatchMode dispatch_mode = state.options.enable_host_compute
472 ? OpDef::decide_dispatch_mode(*op, input_descs)
473 : DispatchMode::KERNEL;
474 switch (dispatch_mode) {
475 case DEFAULT_CPU: {
476 dispatch_default_cpu(op, input_infos, input_descs, &outputs);
477 break;
478 }
479 case KERNEL: {
480 dispatch_kernel(op, input_infos, input_descs, &outputs);
481 break;
482 }
483 }
484 return outputs;
485}
486
487HostTensorND ChannelImpl::get_value(Handle handle) {
488 MGB_LOCK_GUARD(m_spin);

Callers

nothing calls this directly

Calls 5

decide_dispatch_modeFunction · 0.50
dispatch_kernelFunction · 0.50
findMethod · 0.45
endMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected