-
Notifications
You must be signed in to change notification settings - Fork 641
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[VectorExt] Add folders for to_simt and to_simd (#15997)
This patch adds folders for forward operand of one operation to result of another operation if it sees them in a chain.
- Loading branch information
Showing
3 changed files
with
67 additions
and
0 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
49 changes: 49 additions & 0 deletions
49
llvm-external-projects/iree-dialects/test/Dialect/iree_vector_ext/canonicalize.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,49 @@ | ||
// RUN: iree-dialects-opt --canonicalize --split-input-file %s | FileCheck %s | ||
|
||
// CHECK-LABEL: @to_simt_to_simd_fold | ||
// CHECK-SAME: (%[[SIMD:.*]]: vector<64x64xf32>) -> vector<64x64xf32> | ||
func.func @to_simt_to_simd_fold(%simd: vector<64x64xf32>) -> vector<64x64xf32> { | ||
// Both to_simt and to_simd should be dce-ed after folding. | ||
// CHECK-NOT: iree_vector_ext.to_simt | ||
%simt = iree_vector_ext.to_simt %simd : vector<64x64xf32> -> vector<4x4x4xf32> | ||
// CHECK-NOT: iree_vector_ext.to_simd | ||
%simd_out = iree_vector_ext.to_simd %simt : vector<4x4x4xf32> -> vector<64x64xf32> | ||
// CHECK: return %[[SIMD]] | ||
func.return %simd_out : vector<64x64xf32> | ||
} | ||
|
||
// ----- | ||
|
||
// CHECK-LABEL: @to_simd_to_simt_fold | ||
// CHECK-SAME: (%[[SIMT:.*]]: vector<4x4x4xf32>) -> vector<4x4x4xf32> | ||
func.func @to_simd_to_simt_fold(%simt: vector<4x4x4xf32>) -> vector<4x4x4xf32> { | ||
// Both to_simt and to_simd should be dce-ed after folding. | ||
// CHECK-NOT: iree_vector_ext.to_simt | ||
%simd = iree_vector_ext.to_simd %simt : vector<4x4x4xf32> -> vector<64x64xf32> | ||
// CHECK-NOT: iree_vector_ext.to_simd | ||
%simt_out = iree_vector_ext.to_simt %simd : vector<64x64xf32> -> vector<4x4x4xf32> | ||
// CHECK: return %[[SIMT]] | ||
func.return %simt_out : vector<4x4x4xf32> | ||
} | ||
|
||
// ----- | ||
|
||
// CHECK-LABEL: @to_simd_to_simt_multi_use | ||
// CHECK-SAME: (%[[SIMT:.*]]: vector<4x4x4xf32>) | ||
func.func @to_simd_to_simt_multi_use(%simt: vector<4x4x4xf32>) -> (vector<4x4x4xf16>, vector<64x64xf32>) { | ||
// The to_simd operation should not be dce-ed after folding because it is returned. | ||
// CHECK: %[[SIMD:.*]] = iree_vector_ext.to_simd %[[SIMT]] : vector<4x4x4xf32> -> vector<64x64xf32> | ||
%simd = iree_vector_ext.to_simd %simt : vector<4x4x4xf32> -> vector<64x64xf32> | ||
// The to_simt operation should be dce-ed after folding. | ||
// CHECK-NOT: iree_vector_ext.to_simt | ||
%simt_out = iree_vector_ext.to_simt %simd : vector<64x64xf32> -> vector<4x4x4xf32> | ||
|
||
// Check if the folding happened correctly. | ||
// CHECK: %[[TRUNCED:.*]] = arith.truncf %[[SIMT]] | ||
%trunced = arith.truncf %simt_out : vector<4x4x4xf32> to vector<4x4x4xf16> | ||
|
||
// CHECK: return %[[TRUNCED]], %[[SIMD]] | ||
func.return %trunced, %simd : vector<4x4x4xf16>, vector<64x64xf32> | ||
} | ||
|
||
// ----- |