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

Method make_from_value

src/opr/impl/io.cpp:634–663  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

632}
633
634SymbolVar ImmutableTensor::make_from_value(
635 ComputingGraph& graph, const Value& val,
636 const std::shared_ptr<Value>& val_refkeep, const OperatorNodeConfig& config) {
637 auto ud = graph.options()
638 .user_data.get_user_data_or_create<DevValueCache::VarNodeCache>(
639 std::make_shared<DevValueCache::VarNodeCache>);
640 SymbolVar& var = ud->val2var[&val];
641
642 if (!var.node()) {
643 var = graph.insert_opr(std::make_unique<ImmutableTensor>(graph, val, config))
644 ->output(0);
645 if (val_refkeep) {
646 auto&& opr = var.node()->owner_opr()->cast_final<ImmutableTensor>();
647 mgb_assert(&opr.m_value == val_refkeep.get() && !opr.m_value_refkeep);
648 opr.m_value_refkeep = val_refkeep;
649 }
650 }
651#if !MGB_BUILD_SLIM_SERVING
652 // FIXME: make() of immutable tensor would return immediately instead of
653 // calling insert_opr() when hitting cache, so we need call it munually.
654 // see MGE-81
655 else {
656 if (graph.options().eager_evaluation) {
657 auto&& opr = var.node()->owner_opr();
658 graph.insert_opr(std::unique_ptr<OperatorNodeBase>(opr));
659 }
660 }
661#endif
662 return var;
663}
664
665void ImmutableTensor::init_output_comp_node() {
666 comp_node(m_value.dev().comp_node());

Callers

nothing calls this directly

Calls 6

ifFunction · 0.50
nodeMethod · 0.45
outputMethod · 0.45
insert_oprMethod · 0.45
owner_oprMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected