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

Function identical_op

src/gopt/impl/basic_arith/inplace.cpp:66–78  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

64// a + 0 => a, a * 1 => a
65template <int id_val>
66SymbolVar identical_op(
67 const SymbolVarArrayView& inp, const OperatorNodeConfig& config) {
68 auto lhs = inp[0], rhs = inp[1];
69 auto k = lhs.as_immutable_scalar();
70 if (!k.valid()) {
71 std::swap(lhs, rhs);
72 k = lhs.as_immutable_scalar();
73 }
74 if (k.valid() && almost_equal(k->get_cast<float>(), static_cast<float>(id_val))) {
75 return broadcast_tshp(rhs, inp);
76 }
77 return {};
78}
79
80template <int zero_val>
81SymbolVar absorbing_element(

Callers

nothing calls this directly

Calls 5

swapFunction · 0.85
almost_equalFunction · 0.85
broadcast_tshpFunction · 0.85
as_immutable_scalarMethod · 0.80
validMethod · 0.45

Tested by

no test coverage detected