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

Method init_output_format

src/core/impl/graph/operator_node.cpp:316–342  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

314}
315
316void OperatorNodeBase::init_output_format() {
317 TensorFormat format, default_;
318 for (auto i : input()) {
319 auto cur = i->format();
320 if (!cur.is_default() && !cur.is_lowbit_aligned()) {
321 if (format == default_) {
322 format = cur;
323 } else {
324 mgb_assert(
325 format == cur,
326 "multiple non-default or non-lowbits aligned "
327 "formats in inputs: %s vs %s",
328 format.to_string().c_str(), cur.to_string().c_str());
329 }
330 }
331 }
332 for (auto i : output()) {
333 if (i->contain_flag(VarNode::Flag::VOLATILE_CONTENT)) {
334 i->format(TensorFormat(i->dtype()));
335 } else {
336 if (!format.is_default())
337 i->format(format);
338 else
339 i->format(TensorFormat(i->dtype()));
340 }
341 }
342}
343
344void OperatorNodeBase::init_output_mem_plan(bool dynamic) {
345 for (auto i : m_output) {

Callers 1

cg_impl.cppFile · 0.45

Calls 6

is_lowbit_alignedMethod · 0.80
formatMethod · 0.45
is_defaultMethod · 0.45
to_stringMethod · 0.45
contain_flagMethod · 0.45
dtypeMethod · 0.45

Tested by

no test coverage detected