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

Method put_impl

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

Source from the content-addressed store, hash-verified

147}
148
149TensorInfo* ChannelImpl::put_impl(const HostTensorND& value, bool no_cache) {
150 if (value.empty()) {
151 auto layout = value.layout();
152 layout.init_contiguous_stride();
153 const_cast<HostTensorND&>(value).reset(value.storage(), layout);
154 }
155 auto info = alloc();
156 constexpr int size_threshold = TensorShape::MAX_NDIM;
157 init(info, {value.layout(), value.comp_node()});
158 if (value.layout().total_nr_elems() <= size_threshold) {
159 info->h_value = value;
160 info->desc.value = value.proxy_to_default_cpu();
161 }
162 if (Profiler::is_profiling()) {
163 m_worker.add_task(
164 {Profiler::next_id(), Put{info, value, no_cache},
165 get_channel_state().stack_manager.dump()});
166 } else {
167 m_worker.add_task({
168 Profiler::next_id(),
169 Put{info, value, no_cache},
170 });
171 }
172
173 if (get_channel_state().options.async_level == 0) {
174 sync_impl();
175 info->desc.comp_node.sync();
176 auto err = info->desc.comp_node.check_async_error();
177 mgb_assert(!err, "%s", err->what());
178 }
179 return info;
180}
181
182Handle ChannelImpl::put(const DeviceTensorND& data, const HostTensorND& hvalue) {
183 MGB_LOCK_GUARD(m_spin);

Callers

nothing calls this directly

Calls 15

allocFunction · 0.85
is_profilingFunction · 0.85
storageMethod · 0.80
check_async_errorMethod · 0.80
initFunction · 0.50
makeFunction · 0.50
emptyMethod · 0.45
layoutMethod · 0.45
resetMethod · 0.45
comp_nodeMethod · 0.45
total_nr_elemsMethod · 0.45

Tested by

no test coverage detected