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

Method try_infer_tensor_layout

lite/src/mge/network_impl.cpp:678–698  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

676}
677
678void NetworkImplDft::try_infer_tensor_layout(std::shared_ptr<Tensor> tensor, Var var) {
679 using InferType = mgb::cg::static_infer::InferType;
680 auto&& static_infer_mgr = m_load_config.comp_graph->static_infer_manager();
681 if (static_infer_mgr.get_infer_type(var.node()).shape &
682 (InferType::CONST | InferType::RT_STATIC)) {
683 auto shape = static_infer_mgr.infer_shape_fallible(var.node());
684 if (!shape) {
685 LITE_WARN(
686 "Lite infer output shape failed, maybe the model is "
687 "dynamic "
688 "shape.\n");
689 LITE_ASSERT(
690 !m_user_config->options.force_output_use_user_specified_memory,
691 "force_output_use_user_specified_memory can't be used when output "
692 "shape can't be derived.");
693 return;
694 }
695 Layout layout = to_lite_layout(TensorLayout{*shape, var.dtype()});
696 tensor->set_layout(layout);
697 }
698}
699
700void NetworkImplDft::update_io() {
701 update_input();

Callers

nothing calls this directly

Calls 5

get_infer_typeMethod · 0.45
nodeMethod · 0.45
infer_shape_fallibleMethod · 0.45
dtypeMethod · 0.45
set_layoutMethod · 0.45

Tested by

no test coverage detected