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

Function FloorModImpl

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

Implementation of FloorMod. Pseudo-code: T trunc_mod = std::fmod(x, y); return trunc_mod != 0 && (y < 0 != trunc_mod < 0) ? trunc_mod + y : trunc_mod;

Source from the content-addressed store, hash-verified

164// return trunc_mod != 0 && (y < 0 != trunc_mod < 0) ? trunc_mod + y
165// : trunc_mod;
166static xla::XlaOp FloorModImpl(xla::XlaBuilder* b, DataType dtype, xla::XlaOp x,
167 xla::XlaOp y, const BCast& broadcast_helper) {
168 std::tie(x, y) = XlaBinaryOp::Broadcast(x, y, broadcast_helper);
169 auto zero = XlaHelpers::Zero(b, dtype);
170 auto trunc_mod = xla::Rem(x, y);
171 auto trunc_mod_not_zero = xla::Ne(trunc_mod, zero);
172 auto do_plus = xla::And(xla::Ne(xla::Lt(trunc_mod, zero), xla::Lt(y, zero)),
173 trunc_mod_not_zero);
174 return xla::Select(do_plus, xla::Add(trunc_mod, y), trunc_mod);
175}
176XLA_MAKE_BINARY(FloorMod,
177 FloorModImpl(b, input_type(0), lhs, rhs, broadcast_helper));
178

Callers 1

binary_ops.ccFile · 0.85

Calls 8

BroadcastFunction · 0.85
RemFunction · 0.85
ZeroFunction · 0.50
NeClass · 0.50
AndFunction · 0.50
LtClass · 0.50
SelectFunction · 0.50
AddClass · 0.50

Tested by

no test coverage detected