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

Function infer_output_attrs_fallible

imperative/src/impl/ops/subtensor.cpp:157–174  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

155}
156
157std::tuple<SmallVector<LogicalTensorDesc>, bool> infer_output_attrs_fallible(
158 const OpDef& def, const SmallVector<LogicalTensorDesc>& inputs) {
159 if (inputs.size() >= 2) {
160 return proxy_graph_detail::infer_output_attrs_fallible(def, inputs);
161 }
162 auto&& inp = inputs[0];
163 auto& inp_cn = inp.comp_node;
164 if (inp.layout.ndim == 0) {
165 return {{{TensorLayout{inp.layout.dtype}, inp_cn, {}}}, false};
166 }
167 auto&& op = static_cast<const Subtensor&>(def);
168
169 auto items = op.items;
170 auto slice_itmes = op.slice_items;
171 TensorLayout out_layout = deduce_layout(inp.layout, items, slice_itmes);
172
173 return {{{out_layout, inp_cn, {}}}, true};
174}
175
176SmallVector<TensorPtr> apply_on_physical_tensor(
177 const OpDef& def, const SmallVector<TensorPtr>& inputs,

Callers

nothing calls this directly

Calls 2

deduce_layoutFunction · 0.85
sizeMethod · 0.45

Tested by

no test coverage detected