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

Function DivNoNanImpl

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

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

Source from the content-addressed store, hash-verified

71// return x / y;
72// }
73static xla::XlaOp DivNoNanImpl(xla::XlaBuilder* b, DataType dtype, xla::XlaOp x,
74 xla::XlaOp y, const BCast& broadcast_helper) {
75 std::tie(x, y) = XlaBinaryOp::Broadcast(x, y, broadcast_helper);
76 auto zero = XlaHelpers::Zero(b, dtype);
77 auto y_equals_0 = xla::Eq(y, zero);
78 auto zeros = xla::ZerosLike(x);
79 auto result = xla::Select(y_equals_0, zeros, xla::Div(x, y));
80 return result;
81}
82XLA_MAKE_BINARY(DivNoNan,
83 DivNoNanImpl(b, input_type(0), lhs, rhs, broadcast_helper));
84

Callers 1

binary_ops.ccFile · 0.85

Calls 6

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

Tested by

no test coverage detected