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

Function get_static_infer_value

imperative/src/impl/proxy_graph.cpp:90–106  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

88 }
89
90 const DeviceTensorND* get_static_infer_value(bool may_sync) {
91 if (!m_static_infer_value.empty()) {
92 return &m_static_infer_value;
93 }
94 if (m_tensor && (may_sync || m_tensor->try_get_value())) {
95 auto&& hv = m_tensor->get_value();
96 mgb_assert(!hv.empty());
97 m_static_infer_value = hv.proxy_to_default_cpu();
98 // steal ownership from shared_ptr
99 using SP = std::shared_ptr<dt_byte>;
100 auto& sp = const_cast<SP&>(m_static_infer_value.storage().raw_storage());
101 static auto dummy = std::make_shared<dt_byte>();
102 sp = SP(dummy, sp.get());
103 return &m_static_infer_value;
104 }
105 return nullptr;
106 }
107
108private:
109 DeviceTensorND m_static_infer_value;

Callers

nothing calls this directly

Calls 6

try_get_valueMethod · 0.80
storageMethod · 0.80
emptyMethod · 0.45
get_valueMethod · 0.45
proxy_to_default_cpuMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected