-
Notifications
You must be signed in to change notification settings - Fork 11.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[mlir][emitc] Arith to EmitC: handle floating-point<->integer convers…
…ions (#87614) Add support for floating-point to integer, integer to floating-point conversions. Floating point conversions to 1-bit integer types are not handled at the moment, as these don't map directly to boolean conversions.
- Loading branch information
1 parent
1d43cdc
commit 18e7dcb
Showing
3 changed files
with
196 additions
and
1 deletion.
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
65 changes: 65 additions & 0 deletions
65
mlir/test/Conversion/ArithToEmitC/arith-to-emitc-unsupported.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,65 @@ | ||
// RUN: mlir-opt -split-input-file -convert-arith-to-emitc -verify-diagnostics %s | ||
|
||
func.func @arith_cast_tensor(%arg0: tensor<5xf32>) -> tensor<5xi32> { | ||
// expected-error @+1 {{failed to legalize operation 'arith.fptosi'}} | ||
%t = arith.fptosi %arg0 : tensor<5xf32> to tensor<5xi32> | ||
return %t: tensor<5xi32> | ||
} | ||
|
||
// ----- | ||
|
||
func.func @arith_cast_vector(%arg0: vector<5xf32>) -> vector<5xi32> { | ||
// expected-error @+1 {{failed to legalize operation 'arith.fptosi'}} | ||
%t = arith.fptosi %arg0 : vector<5xf32> to vector<5xi32> | ||
return %t: vector<5xi32> | ||
} | ||
|
||
// ----- | ||
|
||
func.func @arith_cast_bf16(%arg0: bf16) -> i32 { | ||
// expected-error @+1 {{failed to legalize operation 'arith.fptosi'}} | ||
%t = arith.fptosi %arg0 : bf16 to i32 | ||
return %t: i32 | ||
} | ||
|
||
// ----- | ||
|
||
func.func @arith_cast_f16(%arg0: f16) -> i32 { | ||
// expected-error @+1 {{failed to legalize operation 'arith.fptosi'}} | ||
%t = arith.fptosi %arg0 : f16 to i32 | ||
return %t: i32 | ||
} | ||
|
||
|
||
// ----- | ||
|
||
func.func @arith_cast_to_bf16(%arg0: i32) -> bf16 { | ||
// expected-error @+1 {{failed to legalize operation 'arith.sitofp'}} | ||
%t = arith.sitofp %arg0 : i32 to bf16 | ||
return %t: bf16 | ||
} | ||
|
||
// ----- | ||
|
||
func.func @arith_cast_to_f16(%arg0: i32) -> f16 { | ||
// expected-error @+1 {{failed to legalize operation 'arith.sitofp'}} | ||
%t = arith.sitofp %arg0 : i32 to f16 | ||
return %t: f16 | ||
} | ||
|
||
// ----- | ||
|
||
func.func @arith_cast_fptosi_i1(%arg0: f32) -> i1 { | ||
// expected-error @+1 {{failed to legalize operation 'arith.fptosi'}} | ||
%t = arith.fptosi %arg0 : f32 to i1 | ||
return %t: i1 | ||
} | ||
|
||
// ----- | ||
|
||
func.func @arith_cast_fptoui_i1(%arg0: f32) -> i1 { | ||
// expected-error @+1 {{failed to legalize operation 'arith.fptoui'}} | ||
%t = arith.fptoui %arg0 : f32 to i1 | ||
return %t: i1 | ||
} | ||
|
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