-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
End to end implementation of logical ops. (#900)
Following ops are added * logical_and * logical_not * logical_or
- Loading branch information
1 parent
21955b4
commit 998c81a
Showing
12 changed files
with
163 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
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
15 changes: 15 additions & 0 deletions
15
test/ttmlir/Dialect/TTNN/eltwise/binary/logical_and/simple_and.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,15 @@ | ||
// 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_and(%arg0: tensor<64x128xf32>, %arg1: tensor<64x128xf32>) -> tensor<64x128xf32> { | ||
%0 = tensor.empty() : tensor<64x128xf32> | ||
// CHECK: {{.*}} = "ttnn.empty"{{.*}} | ||
%1 = "ttir.logical_and"(%arg0, %arg1, %0) <{operandSegmentSizes = array<i32: 2, 1>, operand_constraints = [#any_device, #any_device, #any_device]}> : (tensor<64x128xf32>, tensor<64x128xf32>, tensor<64x128xf32>) -> tensor<64x128xf32> | ||
// CHECK: %[[C:.*]] = "ttnn.logical_and" | ||
// CHECK-SAME: tensor<64x128xf32, | ||
// CHECK-SAME: tensor<64x128xf32, | ||
// CHECK-SAME: tensor<64x128xf32, | ||
return %1 : tensor<64x128xf32> | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
test/ttmlir/Dialect/TTNN/eltwise/binary/logical_or/simple_or.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,15 @@ | ||
// 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_or(%arg0: tensor<64x128xf32>, %arg1: tensor<64x128xf32>) -> tensor<64x128xf32> { | ||
%0 = tensor.empty() : tensor<64x128xf32> | ||
// CHECK: {{.*}} = "ttnn.empty"{{.*}} | ||
%1 = "ttir.logical_or"(%arg0, %arg1, %0) <{operandSegmentSizes = array<i32: 2, 1>, operand_constraints = [#any_device, #any_device, #any_device]}> : (tensor<64x128xf32>, tensor<64x128xf32>, tensor<64x128xf32>) -> tensor<64x128xf32> | ||
// CHECK: %[[C:.*]] = "ttnn.logical_or" | ||
// CHECK-SAME: tensor<64x128xf32, | ||
// CHECK-SAME: tensor<64x128xf32, | ||
// CHECK-SAME: tensor<64x128xf32, | ||
return %1 : tensor<64x128xf32> | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
test/ttmlir/Dialect/TTNN/eltwise/unary/logical_not/simple_not.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,14 @@ | ||
// 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_not(%arg0: tensor<64x128xf32>) -> tensor<64x128xf32> { | ||
%0 = tensor.empty() : tensor<64x128xf32> | ||
// CHECK: {{.*}} = "ttnn.empty"{{.*}} | ||
%1 = "ttir.logical_not"(%arg0, %0) <{operandSegmentSizes = array<i32: 1, 1>, operand_constraints = [#any_device, #any_device]}> : (tensor<64x128xf32>, tensor<64x128xf32>) -> tensor<64x128xf32> | ||
// CHECK: %[[C:.*]] = "ttnn.logical_not" | ||
// CHECK-SAME: tensor<64x128xf32, | ||
// CHECK-SAME: tensor<64x128xf32, | ||
return %1 : tensor<64x128xf32> | ||
} | ||
} |
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,40 @@ | ||
// 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 | ||
|
||
#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_and(%arg0: tensor<64x128xf32>, %arg1: tensor<64x128xf32>) -> tensor<64x128xf32> { | ||
%0 = tensor.empty() : tensor<64x128xf32> | ||
// CHECK: {{.*}} = "ttnn.empty"{{.*}} | ||
%1 = "ttir.logical_and"(%arg0, %arg1, %0) <{operandSegmentSizes = array<i32: 2, 1>, operand_constraints = [#any_device, #any_device, #any_device]}> : (tensor<64x128xf32>, tensor<64x128xf32>, tensor<64x128xf32>) -> tensor<64x128xf32> | ||
// CHECK: %[[C:.*]] = "ttnn.logical_and" | ||
// CHECK-SAME: tensor<64x128xf32, | ||
// CHECK-SAME: tensor<64x128xf32, | ||
// CHECK-SAME: tensor<64x128xf32, | ||
return %1 : tensor<64x128xf32> | ||
} | ||
|
||
func.func @logical_not(%arg0: tensor<64x128xf32>) -> tensor<64x128xf32> { | ||
%0 = tensor.empty() : tensor<64x128xf32> | ||
// CHECK: {{.*}} = "ttnn.empty"{{.*}} | ||
%1 = "ttir.logical_not"(%arg0, %0) <{operandSegmentSizes = array<i32: 1, 1>, operand_constraints = [#any_device, #any_device]}> : (tensor<64x128xf32>, tensor<64x128xf32>) -> tensor<64x128xf32> | ||
// CHECK: %[[C:.*]] = "ttnn.logical_not" | ||
// CHECK-SAME: tensor<64x128xf32, | ||
// CHECK-SAME: tensor<64x128xf32, | ||
return %1 : tensor<64x128xf32> | ||
} | ||
|
||
func.func @logical_or(%arg0: tensor<64x128xf32>, %arg1: tensor<64x128xf32>) -> tensor<64x128xf32> { | ||
%0 = tensor.empty() : tensor<64x128xf32> | ||
// CHECK: {{.*}} = "ttnn.empty"{{.*}} | ||
%1 = "ttir.logical_or"(%arg0, %arg1, %0) <{operandSegmentSizes = array<i32: 2, 1>, operand_constraints = [#any_device, #any_device, #any_device]}> : (tensor<64x128xf32>, tensor<64x128xf32>, tensor<64x128xf32>) -> tensor<64x128xf32> | ||
// CHECK: %[[C:.*]] = "ttnn.logical_or" | ||
// CHECK-SAME: tensor<64x128xf32, | ||
// CHECK-SAME: tensor<64x128xf32, | ||
// CHECK-SAME: tensor<64x128xf32, | ||
return %1 : tensor<64x128xf32> | ||
} | ||
} |