-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[compiler] fix inf/nan convert to i32 on x86_64 arch (#378)
1. on x86_64, [inf, -inf, nan] will be converted to [INT32_MIN, INT32_MIN, INT32_MIN] due to UB. However, on arm_aarch64/nvgpu, [inf, -inf, nan] will be converted to [INT32_MAX, INT32_MIN, 0]. 2. so we add compare and select during HloToLinalg and add target & arch option to control it.
- Loading branch information
1 parent
2fd35eb
commit 473bb38
Showing
9 changed files
with
160 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
// RUN: byteir-opt %s -hlo-fusion-to-linalg="target="cpu" arch="x86_64"" | FileCheck %s | ||
|
||
func.func @mhlo_convert_f32_i32(%arg0: tensor<2x3xf32>) -> tensor<2x3xi32> { | ||
%0 = mhlo.convert %arg0 : (tensor<2x3xf32>) -> tensor<2x3xi32> | ||
return %0 : tensor<2x3xi32> | ||
} | ||
// CHECK-LABEL: mhlo_convert_f32_i32 | ||
// CHECK: linalg.map | ||
// CHECK: arith.cmpf | ||
// CHECK: arith.fptosi | ||
// CHECK: arith.select |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 4 additions & 0 deletions
4
tests/numerical_test/mlir_tests/cpu_ops/convert_f32_i32_special_val.mlir
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
func.func @convert_f32_i32_special_val(%arg0 : tensor<2x3xf32>) -> tensor<2x3xi32> { | ||
%0 = stablehlo.convert %arg0 : (tensor<2x3xf32>) -> tensor<2x3xi32> | ||
func.return %0 : tensor<2x3xi32> | ||
} |