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

Method Host2DeviceCopy

src/opr/impl/io.cpp:164–188  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

162
163MGB_DYN_TYPE_OBJ_FINAL_IMPL(Host2DeviceCopy);
164Host2DeviceCopy::Host2DeviceCopy(
165 ComputingGraph& graph, const std::shared_ptr<HostTensorND>& host_data,
166 const Param& param, const OperatorNodeConfig& config)
167 : Super{&graph, config, "h2d", {}}, m_param{param}, m_host_data{host_data} {
168 auto out_cn = m_host_data->comp_node();
169 if (config.has_comp_node_set())
170 out_cn = config.get_single_comp_node();
171 mgb_assert(out_cn.valid(), "can not get output comp node");
172
173 if (param.allow_cpu_mem_fwd &&
174 out_cn.mem_node() == CompNode::default_cpu().mem_node() &&
175 host_data->comp_node().mem_node() == out_cn.mem_node()) {
176 m_fwd_host_mem = true;
177 dv_helper::add_output(*this, host_data->dtype());
178 } else {
179 m_fwd_host_mem = false;
180 add_output(None)->dtype(host_data->dtype());
181 }
182 add_equivalence_component<ScalarHash<void*>>(host_data.get());
183 add_equivalence_component<PODHash<Param>>(&m_param);
184
185 this->comp_node(out_cn);
186
187 output(0)->add_flag(VarNode::Flag::ALLOW_EMPTY_SHAPE);
188}
189
190const TensorShape& Host2DeviceCopy::get_output_shape() {
191 return m_host_data->shape();

Callers

nothing calls this directly

Calls 7

has_comp_node_setMethod · 0.80
get_single_comp_nodeMethod · 0.80
comp_nodeMethod · 0.45
validMethod · 0.45
mem_nodeMethod · 0.45
dtypeMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected