MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / MulNoNanImpl

Function MulNoNanImpl

tensorflow/compiler/tf2xla/kernels/binary_ops.cc:91–99  ·  view source on GitHub ↗

Implementation of MulNoNan. Pseudo-code: if (y == 0) { return 0 } else { return x * y; }

Source from the content-addressed store, hash-verified

89// return x * y;
90// }
91static xla::XlaOp MulNoNanImpl(xla::XlaBuilder* b, DataType dtype, xla::XlaOp x,
92 xla::XlaOp y, const BCast& broadcast_helper) {
93 std::tie(x, y) = XlaBinaryOp::Broadcast(x, y, broadcast_helper);
94 auto zero = XlaHelpers::Zero(b, dtype);
95 auto y_equals_0 = xla::Eq(y, zero);
96 auto zeros = xla::ZerosLike(x);
97 auto result = xla::Select(y_equals_0, zeros, xla::Mul(x, y));
98 return result;
99}
100XLA_MAKE_BINARY(MulNoNan,
101 MulNoNanImpl(b, input_type(0), lhs, rhs, broadcast_helper));
102

Callers 1

binary_ops.ccFile · 0.85

Calls 6

BroadcastFunction · 0.85
ZeroFunction · 0.50
EqClass · 0.50
ZerosLikeFunction · 0.50
SelectFunction · 0.50
MulFunction · 0.50

Tested by

no test coverage detected