mirror of
https://github.com/ROCm/jax.git
synced 2025-04-17 12:26:07 +00:00
[Mosaic TPU] Optimize clipping impelmentation in arith.fptosi
We can use maxf/minf to avoid extra comparisons PiperOrigin-RevId: 720601304
This commit is contained in:
parent
f504d32492
commit
29b658b358
@ -597,12 +597,8 @@ LogicalResult canonicalize_fptosi(const CanonicalizeContext &ctx,
|
||||
}
|
||||
// Need to clip values to match XLA
|
||||
auto clip = [&](Value x, Value low, Value high) {
|
||||
auto is_small =
|
||||
builder.create<arith::CmpFOp>(arith::CmpFPredicate::OLT, x, low);
|
||||
x = builder.create<arith::SelectOp>(is_small, low, x);
|
||||
auto is_large =
|
||||
builder.create<arith::CmpFOp>(arith::CmpFPredicate::OGT, x, high);
|
||||
x = builder.create<arith::SelectOp>(is_large, high, x);
|
||||
x = builder.create<arith::MaximumFOp>(x, low);
|
||||
x = builder.create<arith::MinimumFOp>(x, high);
|
||||
return x;
|
||||
};
|
||||
auto minval = builder.getF32FloatAttr(
|
||||
|
Loading…
x
Reference in New Issue
Block a user