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

Function apply_on_physical_tensor

imperative/src/impl/ops/fill.cpp:43–58  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

41}
42
43SmallVector<TensorPtr> apply_on_physical_tensor(
44 const OpDef& def, const SmallVector<TensorPtr>& inputs,
45 SmallVector<LogicalTensorDesc>& output_descs, const bool& validated) {
46 auto&& op = def.cast_final_safe<Fill>();
47 auto comp_node = inputs[0]->comp_node();
48 TensorShape tshp;
49 cg::copy_tensor_value_to_shape(tshp, inputs[0]->get_value().proxy_to_default_cpu());
50 TensorLayout oup_layout = TensorLayout{tshp, op.dtype};
51 auto output = Tensor::make(oup_layout, comp_node);
52
53 if (oup_layout.total_nr_elems() != 0) { // empty tensor like Tensor([])
54 DnnOprCaller<megdnn::Fill> caller(comp_node, megdnn::Fill::Param{op.value});
55 caller.exec_with_ws(output);
56 }
57 return {output};
58}
59
60SmallVector<VarNode::LayoutConstraintCallback> get_input_layout_constraint(
61 const OpDef& def, const SmallVector<TensorPtr>& inputs) {

Callers

nothing calls this directly

Calls 8

exec_with_wsMethod · 0.80
makeFunction · 0.70
comp_nodeMethod · 0.45
proxy_to_default_cpuMethod · 0.45
get_valueMethod · 0.45
total_nr_elemsMethod · 0.45
sizeMethod · 0.45
layoutMethod · 0.45

Tested by

no test coverage detected