Skip to content

Commit

Permalink
[CINN] Use trunc instead of fesetround to avoid affect other calc…
Browse files Browse the repository at this point in the history
…ulation precision in same process
  • Loading branch information
SigureMo committed Jan 10, 2025
1 parent dbf9de2 commit 4af71fa
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions paddle/cinn/ir/ir_printer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

#include "paddle/cinn/ir/ir_printer.h"
#include <algorithm>
#include <cfenv>
#include <cmath>
#include <iomanip>
#include <limits>
#include <vector>
Expand Down Expand Up @@ -175,7 +175,7 @@ void IrPrinter::Visit(const FloatImm *x) {
}
} else {
float v = TruncateInfinity<float>(x->value);
if (IsCloseEqualBoundValue<float>(v)) std::fesetround(FE_TOWARDZERO);
if (IsCloseEqualBoundValue<float>(v)) v = std::trunc(v);
ss << std::setprecision(std::numeric_limits<float>::max_digits10);
ss << std::showpoint;
ss << v;
Expand Down
2 changes: 1 addition & 1 deletion test/cpp/pir/cinn/replace_cross_block_reduction_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ TEST(CrossBlockReductionReplacer, RSLayout) {
ScheduleBlock(B__reduce_init)
{
i0, i1 = axis.bind(i, j)
B__reduce_init[i0, i1] = -3.40282346e+38f
B__reduce_init[i0, i1] = -3.40282347e+38f
}
thread_bind[blockIdx.y] for (reduce_k, 0, 8)
{
Expand Down

0 comments on commit 4af71fa

Please sign in to comment.