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

Method apply_op

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

Source from the content-addressed store, hash-verified

428}
429
430SmallVector<Handle> ChannelImpl::apply_op(
431 std::shared_ptr<OpDef> op, const SmallVector<Handle>& inputs) {
432 MGB_LOCK_GUARD(m_spin);
433 assert_available();
434 auto* input = reinterpret_cast<TensorInfo*>(inputs[0]);
435 if (op->same_type<GetVarShape>() && input->shape_valid()) {
436 size_t ndim = input->desc.layout.ndim;
437 auto& gvs = op->cast_final_safe<GetVarShape>();
438 if (gvs.axis == MEGDNN_MAX_NDIM) {
439 HostTensorND shape_tensor{input->desc.comp_node, {ndim}, dtype::Int32()};
440 DeviceTensorND shape_tensor_device = shape_tensor.proxy_to_default_cpu();
441 cg::copy_shape_to_tensor_value(shape_tensor_device, input->desc.layout);
442 return {reinterpret_cast<Handle>(put_impl(shape_tensor, false))};
443 }
444 }
445 return apply_op_impl(std::move(op), inputs);
446}
447
448SmallVector<Handle> ChannelImpl::apply_op_impl(
449 std::shared_ptr<OpDef> op, const SmallVector<Handle>& inputs) {

Callers

nothing calls this directly

Calls 2

shape_validMethod · 0.45
proxy_to_default_cpuMethod · 0.45

Tested by

no test coverage detected