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

Method perform

src/opr/impl/basic_arith.cpp:179–212  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

177}
178
179void Elemwise::perform(
180 Mode mode, DeviceTensorND& dest, const SmallVector<DeviceTensorND>& inputs,
181 intl::UniqPtrWithCN<megdnn::Elemwise>& opr) {
182 megdnn::TensorNDArray dnn_inputs(inputs.size());
183 TensorShapeArray inp_shapes(inputs.size());
184 DType out_dt;
185 CompNode out_cn;
186 for (size_t i = 0; i < inputs.size(); ++i) {
187 auto&& t = inputs[i];
188 if (!i) {
189 out_cn = t.comp_node();
190 out_dt = t.dtype();
191 } else {
192 mgb_assert(t.comp_node() == out_cn);
193 mgb_assert(t.dtype() == out_dt);
194 }
195 if (t.shape().is_empty()) {
196 mgb_assert(dest.empty());
197 return;
198 }
199 inp_shapes[i] = t.shape();
200 }
201 if (!opr) {
202 opr = intl::create_megdnn_opr<megdnn::Elemwise>(out_cn);
203 } else {
204 mgb_assert(out_cn == opr.comp_node());
205 }
206 out_cn.activate();
207 for (size_t i = 0; i < inputs.size(); ++i)
208 dnn_inputs[i] = inputs[i].as_megdnn();
209 dest.comp_node(out_cn).dtype(out_dt).resize(get_output_var_shape(mode, inp_shapes));
210 opr->param() = {mode};
211 call_megdnn_opr_exec(out_cn, dnn_inputs, dest.as_megdnn(), opr.get(), nullptr);
212}
213
214void Elemwise::perform_dnn(
215 CompNode cn, const megdnn::TensorND& dest, megdnn::TensorNDArray& inputs,

Callers

nothing calls this directly

Calls 15

as_megdnnMethod · 0.80
resizeMethod · 0.80
comp_node_validMethod · 0.80
storageMethod · 0.80
init_shapesMethod · 0.80
has_actual_computingMethod · 0.80
workspace_sizeMethod · 0.80
update_ptrMethod · 0.80
get_output_var_shapeFunction · 0.50
get_aligned_power2Function · 0.50
sizeMethod · 0.45
comp_nodeMethod · 0.45

Tested by

no test coverage detected