| 147 | } |
| 148 | |
| 149 | TensorInfo* 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 | |
| 182 | Handle ChannelImpl::put(const DeviceTensorND& data, const HostTensorND& hvalue) { |
| 183 | MGB_LOCK_GUARD(m_spin); |
nothing calls this directly
no test coverage detected