@@ -325,8 +325,8 @@ AtanApproximation::matchAndRewrite(math::AtanOp op,
325
325
p = builder.create <arith::MulFOp>(x, p);
326
326
327
327
// Remap the solution for over [0.0, 1.0] to [0.0, inf]
328
- auto half_pi = broadcast (builder, f32Cst (builder, 1 .57079632679f ), shape);
329
- Value sub = builder.create <arith::SubFOp>(half_pi , p);
328
+ auto halfPi = broadcast (builder, f32Cst (builder, 1 .57079632679f ), shape);
329
+ Value sub = builder.create <arith::SubFOp>(halfPi , p);
330
330
Value select = builder.create <SelectOp>(compare, p, sub);
331
331
332
332
// Correct for signing of the input.
@@ -366,40 +366,38 @@ Atan2Approximation::matchAndRewrite(math::Atan2Op op,
366
366
// Determine what the atan would be for a 180 degree rotation.
367
367
auto zero = broadcast (builder, f32Cst (builder, 0 .0f ), shape);
368
368
auto pi = broadcast (builder, f32Cst (builder, 3 .14159265359f ), shape);
369
- auto add_pi = builder.create <arith::AddFOp>(atan, pi);
370
- auto sub_pi = builder.create <arith::SubFOp>(atan, pi);
371
- auto atan_gt =
369
+ auto addPi = builder.create <arith::AddFOp>(atan, pi);
370
+ auto subPi = builder.create <arith::SubFOp>(atan, pi);
371
+ auto atanGt =
372
372
builder.create <arith::CmpFOp>(arith::CmpFPredicate::OGT, atan, zero);
373
- auto flipped_atan = builder.create <SelectOp>(atan_gt, sub_pi, add_pi );
373
+ auto flippedAtan = builder.create <SelectOp>(atanGt, subPi, addPi );
374
374
375
375
// Determine whether to directly use atan or use the 180 degree flip
376
- auto x_gt = builder.create <arith::CmpFOp>(arith::CmpFPredicate::OGT, x, zero);
377
- Value result = builder.create <SelectOp>(x_gt , atan, flipped_atan );
376
+ auto xGt = builder.create <arith::CmpFOp>(arith::CmpFPredicate::OGT, x, zero);
377
+ Value result = builder.create <SelectOp>(xGt , atan, flippedAtan );
378
378
379
379
// Handle x = 0, y > 0
380
- Value x_zero =
380
+ Value xZero =
381
381
builder.create <arith::CmpFOp>(arith::CmpFPredicate::OEQ, x, zero);
382
- Value y_gt =
383
- builder.create <arith::CmpFOp>(arith::CmpFPredicate::OGT, y, zero);
384
- Value is_half_pi = builder.create <arith::AndIOp>(x_zero, y_gt);
385
- auto half_pi = broadcast (builder, f32Cst (builder, 1 .57079632679f ), shape);
386
- result = builder.create <SelectOp>(is_half_pi, half_pi, result);
382
+ Value yGt = builder.create <arith::CmpFOp>(arith::CmpFPredicate::OGT, y, zero);
383
+ Value isHalfPi = builder.create <arith::AndIOp>(xZero, yGt);
384
+ auto halfPi = broadcast (builder, f32Cst (builder, 1 .57079632679f ), shape);
385
+ result = builder.create <SelectOp>(isHalfPi, halfPi, result);
387
386
388
387
// Handle x = 0, y < 0
389
- Value y_lt =
390
- builder.create <arith::CmpFOp>(arith::CmpFPredicate::OLT, y, zero);
391
- Value is_negative_half_pi_pi = builder.create <arith::AndIOp>(x_zero, y_lt);
392
- auto negative_half_pi_pi =
388
+ Value yLt = builder.create <arith::CmpFOp>(arith::CmpFPredicate::OLT, y, zero);
389
+ Value isNegativeHalfPiPi = builder.create <arith::AndIOp>(xZero, yLt);
390
+ auto negativeHalfPiPi =
393
391
broadcast (builder, f32Cst (builder, -1.57079632679 ), shape);
394
- result = builder. create <SelectOp>(is_negative_half_pi_pi, negative_half_pi_pi,
395
- result);
392
+ result =
393
+ builder. create <SelectOp>(isNegativeHalfPiPi, negativeHalfPiPi, result);
396
394
397
395
// Handle x = 0, y = 0;
398
- Value y_zero =
396
+ Value yZero =
399
397
builder.create <arith::CmpFOp>(arith::CmpFPredicate::OEQ, y, zero);
400
- Value is_nan = builder.create <arith::AndIOp>(x_zero, y_zero );
401
- Value cst_nan = broadcast (builder, f32FromBits (builder, 0x7fc00000 ), shape);
402
- result = builder.create <SelectOp>(is_nan, cst_nan , result);
398
+ Value isNan = builder.create <arith::AndIOp>(xZero, yZero );
399
+ Value cstNan = broadcast (builder, f32FromBits (builder, 0x7fc00000 ), shape);
400
+ result = builder.create <SelectOp>(isNan, cstNan , result);
403
401
404
402
rewriter.replaceOp (op, result);
405
403
return success ();
0 commit comments