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

Function absorbing_element

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

Source from the content-addressed store, hash-verified

79
80template <int zero_val>
81SymbolVar absorbing_element(
82 const SymbolVarArrayView& inp, const OperatorNodeConfig& config) {
83 auto lhs = inp[0], rhs = inp[1];
84 auto scalar = lhs.as_immutable_scalar();
85 if (!scalar.valid()) {
86 std::swap(lhs, rhs);
87 scalar = lhs.as_immutable_scalar();
88 }
89 if (scalar.valid() &&
90 almost_equal(scalar->get_cast<float>(), static_cast<float>(zero_val))) {
91 return broadcast_tshp(rhs.make_scalar_dt(zero_val), inp);
92 }
93 return {};
94}
95} // namespace inplace_optimize
96} // anonymous namespace
97

Callers

nothing calls this directly

Calls 6

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

Tested by

no test coverage detected