-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add end-to-end implementation of the logical xor op. * Add stablehlo to ttir conversion
- Loading branch information
1 parent
6100428
commit 04e0663
Showing
13 changed files
with
123 additions
and
25 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
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
39 changes: 15 additions & 24 deletions
39
test/ttmlir/Conversion/StableHLOToTTIR/binary/logical_op.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 |
---|---|---|
@@ -1,39 +1,30 @@ | ||
// REQUIRES: stablehlo | ||
// RUN: ttmlir-opt --stablehlo-to-ttir-pipeline %s | FileCheck %s | ||
module @jit_eltwise_compare attributes {} { | ||
module @jit_eltwise_logical attributes {} { | ||
func.func public @logical_and(%arg0: tensor<13x31xi1>, %arg1: tensor<13x31xi1>) -> tensor<13x31xi1> { | ||
%0 = stablehlo.and %arg0, %arg1 : tensor<13x31xi1> | ||
// CHECK: %[[E:.*]] = tensor.empty() : tensor<13x31xbf16> | ||
// CHECK: %[[E:.*]] = tensor.empty() : [[TENSOR:tensor<13x31xbf16>]] | ||
// CHECK: = "ttir.logical_and"(%arg0, %arg1, %[[E]]) | ||
// CHECK-SAME: (tensor<13x31xbf16>, tensor<13x31xbf16>, tensor<13x31xbf16>) -> tensor<13x31xbf16> | ||
// CHECK-SAME: ([[TENSOR]], [[TENSOR]], [[TENSOR]]) -> [[TENSOR]] | ||
%0 = stablehlo.and %arg0, %arg1 : tensor<13x31xi1> | ||
// CHECK: return %1 : [[TENSOR]] | ||
return %0 : tensor<13x31xi1> | ||
// CHECK: return %1 : tensor<13x31xbf16> | ||
} | ||
|
||
func.func public @logical_or(%arg0: tensor<13x31xi1>, %arg1: tensor<13x31xi1>) -> tensor<13x31xi1> { | ||
%0 = stablehlo.or %arg0, %arg1 : tensor<13x31xi1> | ||
// CHECK: %[[E:.*]] = tensor.empty() : tensor<13x31xbf16> | ||
// CHECK: %[[E:.*]] = tensor.empty() : [[TENSOR:tensor<13x31xbf16>]] | ||
// CHECK: = "ttir.logical_or"(%arg0, %arg1, %[[E]]) | ||
// CHECK-SAME: (tensor<13x31xbf16>, tensor<13x31xbf16>, tensor<13x31xbf16>) -> tensor<13x31xbf16> | ||
// CHECK-SAME: ([[TENSOR]], [[TENSOR]], [[TENSOR]]) -> [[TENSOR]] | ||
%0 = stablehlo.or %arg0, %arg1 : tensor<13x31xi1> | ||
// CHECK: return %1 : [[TENSOR]] | ||
return %0 : tensor<13x31xi1> | ||
// CHECK: return %1 : tensor<13x31xbf16> | ||
} | ||
|
||
func.func public @logical_not(%arg0: tensor<13x31xi1>) -> tensor<13x31xi1> { | ||
%0 = stablehlo.not %arg0 : tensor<13x31xi1> | ||
// CHECK: %[[E:.*]] = tensor.empty() : tensor<13x31xbf16> | ||
// CHECK: = "ttir.logical_not"(%arg0, %[[E]]) | ||
// CHECK-SAME: (tensor<13x31xbf16>, tensor<13x31xbf16>) -> tensor<13x31xbf16> | ||
func.func public @logical_xor(%arg0: tensor<13x31xi1>, %arg1: tensor<13x31xi1>) -> tensor<13x31xi1> { | ||
// CHECK: %[[E:.*]] = tensor.empty() : [[TENSOR:tensor<13x31xbf16>]] | ||
// CHECK: = "ttir.logical_xor"(%arg0, %arg1, %[[E]]) | ||
// CHECK-SAME: ([[TENSOR]], [[TENSOR]], [[TENSOR]]) -> [[TENSOR]] | ||
%0 = stablehlo.xor %arg0, %arg1 : tensor<13x31xi1> | ||
// CHECK: return %1 : [[TENSOR]] | ||
return %0 : tensor<13x31xi1> | ||
// CHECK: return %1 : tensor<13x31xbf16> | ||
} | ||
|
||
func.func public @logical_not_scalar(%arg0: tensor<i1>) -> tensor<i1> { | ||
%0 = stablehlo.not %arg0 : tensor<i1> | ||
// CHECK: %[[E:.*]] = tensor.empty() : tensor<1xbf16> | ||
// CHECK: = "ttir.logical_not"(%arg0, %[[E]]) | ||
// CHECK-SAME: (tensor<1xbf16>, tensor<1xbf16>) -> tensor<1xbf16> | ||
return %0 : tensor<i1> | ||
// CHECK: return %1 : tensor<1xbf16> | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
test/ttmlir/Conversion/StableHLOToTTIR/unary/logical_op.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,22 @@ | ||
// REQUIRES: stablehlo | ||
// RUN: ttmlir-opt --stablehlo-to-ttir-pipeline %s | FileCheck %s | ||
module @jit_eltwise_logical attributes {} { | ||
func.func public @logical_not(%arg0: tensor<13x31xi1>) -> tensor<13x31xi1> { | ||
// CHECK: %[[E:.*]] = tensor.empty() : tensor<13x31xbf16> | ||
// CHECK: = "ttir.logical_not"(%arg0, %[[E]]) | ||
// CHECK-SAME: (tensor<13x31xbf16>, tensor<13x31xbf16>) -> tensor<13x31xbf16> | ||
%0 = stablehlo.not %arg0 : tensor<13x31xi1> | ||
// CHECK: return %1 : tensor<13x31xbf16> | ||
return %0 : tensor<13x31xi1> | ||
} | ||
|
||
func.func public @logical_not_scalar(%arg0: tensor<i1>) -> tensor<i1> { | ||
// CHECK: %[[E:.*]] = tensor.empty() : tensor<1xbf16> | ||
// CHECK: = "ttir.logical_not"(%arg0, %[[E]]) | ||
// CHECK-SAME: ([[TENSOR]], [[TENSOR]]) -> [[TENSOR]] | ||
%0 = stablehlo.not %arg0 : tensor<i1> | ||
// CHECK: return %1 : [[TENSOR]] | ||
return %0 : tensor<i1> | ||
|
||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
test/ttmlir/Dialect/TTNN/eltwise/binary/logical_xor/simple_xor.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,16 @@ | ||
// RUN: ttmlir-opt --ttir-to-ttnn-backend-pipeline %s | FileCheck %s | ||
|
||
#any_device = #tt.operand_constraint<dram|l1|scalar|tile|any_device|any_device_tile> | ||
module attributes {} { | ||
func.func @logical_xor(%arg0: tensor<64x128xbf16>, %arg1: tensor<64x128xbf16>) -> tensor<64x128xbf16> { | ||
// CHECK: %{{[0-9]+}} = "ttnn.empty"{{.*}} [[TENSOR:tensor<64x128xbf16]] | ||
%0 = tensor.empty() : tensor<64x128xbf16> | ||
// CHECK: %{{[0-9]+}} = "ttnn.logical_xor" | ||
// CHECK-SAME: [[TENSOR]] | ||
// CHECK-SAME: [[TENSOR]] | ||
// CHECK-SAME: [[TENSOR]] | ||
// CHECK-SAME: -> [[TENSOR]] | ||
%1 = "ttir.logical_xor"(%arg0, %arg1, %0) <{operandSegmentSizes = array<i32: 2, 1>, operand_constraints = [#any_device, #any_device, #any_device]}> : (tensor<64x128xbf16>, tensor<64x128xbf16>, tensor<64x128xbf16>) -> tensor<64x128xbf16> | ||
return %1 : tensor<64x128xbf16> | ||
} | ||
} |
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,19 @@ | ||
// RUN: ttmlir-opt --ttir-to-ttnn-backend-pipeline="system-desc-path=%system_desc_path%" %s > %t.mlir | ||
// RUN: FileCheck %s --input-file=%t.mlir | ||
// RUN: ttmlir-translate --ttnn-to-flatbuffer %t.mlir > %t.ttnn | ||
// REQUIRES: https://github.com/tenstorrent/tt-mlir/issues/1149 | ||
|
||
#any_device = #tt.operand_constraint<dram|l1|scalar|tile|any_device|any_device_tile> | ||
#any_device_tile = #tt.operand_constraint<dram|l1|tile|any_device_tile> | ||
|
||
func.func @logical_xor(%arg0: tensor<64x128xbf16>, %arg1: tensor<64x128xbf16>) -> tensor<64x128xbf16> { | ||
// CHECK: %{{[0-9]+}} = "ttnn.empty"{{.*}} [[TENSOR:tensor<64x128xbf16]] | ||
%0 = tensor.empty() : tensor<64x128xbf16> | ||
// CHECK: %{{[0-9]+}} = "ttnn.logical_xor" | ||
// CHECK-SAME: [[TENSOR]] | ||
// CHECK-SAME: [[TENSOR]] | ||
// CHECK-SAME: [[TENSOR]] | ||
// CHECK-SAME: -> [[TENSOR]] | ||
%1 = "ttir.logical_xor"(%arg0, %arg1, %0) <{operandSegmentSizes = array<i32: 2, 1>, operand_constraints = [#any_device, #any_device, #any_device]}> : (tensor<64x128xbf16>, tensor<64x128xbf16>, tensor<64x128xbf16>) -> tensor<64x128xbf16> | ||
return %1 : tensor<64x128xbf16> | ||
} |
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,21 @@ | ||
// RUN: ttmlir-opt --ttir-to-ttnn-backend-pipeline="system-desc-path=%system_desc_path%" %s > %t.mlir | ||
// RUN: FileCheck %s --input-file=%t.mlir | ||
// RUN: ttmlir-translate --ttnn-to-flatbuffer %t.mlir > %t.ttnn | ||
// REQUIRES: https://github.com/tenstorrent/tt-mlir/issues/1149 | ||
|
||
#any_device = #tt.operand_constraint<dram|l1|scalar|tile|any_device|any_device_tile> | ||
#any_device_tile = #tt.operand_constraint<dram|l1|tile|any_device_tile> | ||
|
||
module attributes {} { | ||
func.func @logical_xor(%arg0: tensor<64x128xbf16>, %arg1: tensor<64x128xbf16>) -> tensor<64x128xbf16> { | ||
// CHECK: %{{[0-9]+}} = "ttnn.empty"{{.*}} [[TENSOR:tensor<64x128xbf16]] | ||
%0 = tensor.empty() : tensor<64x128xbf16> | ||
// CHECK: %{{[0-9]+}} = "ttnn.logical_xor" | ||
// CHECK-SAME: [[TENSOR]] | ||
// CHECK-SAME: [[TENSOR]] | ||
// CHECK-SAME: [[TENSOR]] | ||
// CHECK-SAME: -> [[TENSOR]] | ||
%1 = "ttir.logical_xor"(%arg0, %arg1, %0) <{operandSegmentSizes = array<i32: 2, 1>, operand_constraints = [#any_device, #any_device, #any_device]}> : (tensor<64x128xbf16>, tensor<64x128xbf16>, tensor<64x128xbf16>) -> tensor<64x128xbf16> | ||
return %1 : tensor<64x128xbf16> | ||
} | ||
} |