| 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 | |
| 108 | private: |
| 109 | DeviceTensorND m_static_infer_value; |
nothing calls this directly
no test coverage detected