-
Notifications
You must be signed in to change notification settings - Fork 86
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[aievec] to-llvm flow for aievec.min op (#1519)
- Loading branch information
1 parent
1b933de
commit 5524a8d
Showing
4 changed files
with
270 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
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,80 @@ | ||
// RUN: aie-opt %s -split-input-file -convert-aievec-to-llvm -verify-diagnostics | FileCheck %s | ||
|
||
func.func @i8_min(%arg0 : vector<64xi8>) -> vector<64xi8> { | ||
%0 = aievec.min %arg0, %arg0 : vector<64xi8> | ||
return %0 : vector<64xi8> | ||
} | ||
|
||
// CHECK-LABEL: @i8_min | ||
// CHECK-SAME: %[[ARG0:.*]]: vector<64xi8> | ||
// CHECK: %[[CST:.*]] = llvm.mlir.constant(0 : i32) : i32 | ||
// CHECK-NEXT: %[[VMIN:.*]] = "xllvm.intr.aie2.vmin.ge8"( | ||
// CHECK-SAME: %[[ARG0]], %[[ARG0]], %[[CST]]) : | ||
// CHECK-SAME: (vector<64xi8>, vector<64xi8>, i32) -> !llvm.struct<(vector<64xi8>, vector<2xi32>)> | ||
// CHECK-NEXT: %[[RES:.*]] = llvm.extractvalue %[[VMIN]][0] : !llvm.struct<(vector<64xi8>, vector<2xi32>)> | ||
// CHECK-NEXT: return %[[RES]] : vector<64xi8> | ||
|
||
// ----- | ||
|
||
func.func @i16_min(%arg0 : vector<32xi16>) -> vector<32xi16> { | ||
%0 = aievec.min %arg0, %arg0 : vector<32xi16> | ||
return %0 : vector<32xi16> | ||
} | ||
|
||
// CHECK-LABEL: @i16_min | ||
// CHECK-SAME: %[[ARG0:.*]]: vector<32xi16> | ||
// CHECK: %[[CST:.*]] = llvm.mlir.constant(0 : i32) : i32 | ||
// CHECK-NEXT: %[[VMIN:.*]] = "xllvm.intr.aie2.vmin.ge16"( | ||
// CHECK-SAME: %[[ARG0]], %[[ARG0]], %[[CST]]) : | ||
// CHECK-SAME: (vector<32xi16>, vector<32xi16>, i32) -> !llvm.struct<(vector<32xi16>, i32)> | ||
// CHECK-NEXT: %[[RES:.*]] = llvm.extractvalue %[[VMIN]][0] : !llvm.struct<(vector<32xi16>, i32)> | ||
// CHECK-NEXT: return %[[RES]] : vector<32xi16> | ||
|
||
// ----- | ||
|
||
func.func @i32_min(%arg0 : vector<16xi32>) -> vector<16xi32> { | ||
%0 = aievec.min %arg0, %arg0 : vector<16xi32> | ||
return %0 : vector<16xi32> | ||
} | ||
|
||
// CHECK-LABEL: @i32_min | ||
// CHECK-SAME: %[[ARG0:.*]]: vector<16xi32> | ||
// CHECK: %[[CST:.*]] = llvm.mlir.constant(0 : i32) : i32 | ||
// CHECK-NEXT: %[[VMIN:.*]] = "xllvm.intr.aie2.vmin.ge32"( | ||
// CHECK-SAME: %[[ARG0]], %[[ARG0]], %[[CST]]) : | ||
// CHECK-SAME: (vector<16xi32>, vector<16xi32>, i32) -> !llvm.struct<(vector<16xi32>, i32)> | ||
// CHECK-NEXT: %[[RES:.*]] = llvm.extractvalue %[[VMIN]][0] : !llvm.struct<(vector<16xi32>, i32)> | ||
// CHECK-NEXT: return %[[RES]] : vector<16xi32> | ||
|
||
// ----- | ||
|
||
func.func @bf16_min(%arg0 : vector<32xbf16>) -> vector<32xbf16> { | ||
%0 = aievec.min %arg0, %arg0 : vector<32xbf16> | ||
return %0 : vector<32xbf16> | ||
} | ||
|
||
// CHECK-LABEL: @bf16_min | ||
// CHECK-SAME: %[[ARG0:.*]]: vector<32xbf16> | ||
// CHECK-NEXT: %[[VMIN:.*]] = "xllvm.intr.aie2.vmin.gebf16"( | ||
// CHECK-SAME: %[[ARG0]], %[[ARG0]]) : | ||
// CHECK-SAME: (vector<32xbf16>, vector<32xbf16>) -> !llvm.struct<(vector<32xbf16>, i32)> | ||
// CHECK-NEXT: %[[RES:.*]] = llvm.extractvalue %[[VMIN]][0] : !llvm.struct<(vector<32xbf16>, i32)> | ||
// CHECK-NEXT: return %[[RES]] : vector<32xbf16> | ||
|
||
// ----- | ||
|
||
func.func @invalid_i4_min(%arg0 : vector<128xi4>) -> vector<128xi4> { | ||
// expected-warning @+2 {{aievec.min conversion fails due to unsupported element data type.}} | ||
// expected-error @+1 {{failed to legalize operation 'aievec.min' that was explicitly marked illegal}} | ||
%0 = aievec.min %arg0, %arg0 : vector<128xi4> | ||
return %0 : vector<128xi4> | ||
} | ||
|
||
// ----- | ||
|
||
func.func @invalid_i8_min(%arg0 : vector<128xi8>) -> vector<128xi8> { | ||
// expected-warning @+2 {{aievec.min conversion with 1024-bit result is not supported.}} | ||
// expected-error @+1 {{failed to legalize operation 'aievec.min' that was explicitly marked illegal}} | ||
%0 = aievec.min %arg0, %arg0 : vector<128xi8> | ||
return %0 : vector<128xi8> | ||
} |
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