-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for isfinite and floor op. (#956)
* Add end-to-end implementation of the ops * Add stablehlo to ttir conversion
- Loading branch information
1 parent
6988418
commit 3dbf089
Showing
15 changed files
with
178 additions
and
8 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
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,11 @@ | ||
// REQUIRES: stablehlo | ||
// RUN: ttmlir-opt --stablehlo-to-ttir-pipeline %s | FileCheck %s | ||
#any_device = #tt.operand_constraint<dram|l1|scalar|tile|any_device|any_device_tile> | ||
module @jit_eltwise_floor attributes {} { | ||
func.func public @test_floor(%arg0: tensor<32x32x3xf32>) -> tensor<32x32x3xf32> { | ||
%0 = stablehlo.floor %arg0 : tensor<32x32x3xf32> | ||
// CHECK: %[[C:.*]] = tensor.empty[[C:.*]] | ||
// CHECK: %[[C:.*]] = "ttir.floor"[[C:.*]] | ||
return %0 : tensor<32x32x3xf32> | ||
} | ||
} |
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,13 @@ | ||
// REQUIRES: stablehlo | ||
// RUN: ttmlir-opt --stablehlo-to-ttir-pipeline %s | FileCheck %s | ||
#any_device = #tt.operand_constraint<dram|l1|scalar|tile|any_device|any_device_tile> | ||
module @jit_eltwise_isfinite attributes {} { | ||
func.func public @test_isfinite(%arg0: tensor<32x32x3xf32>) -> tensor<32x32x3xi1> { | ||
// CHECK: %[[E:.*]] = tensor.empty() : tensor<32x32x3xbf16> | ||
// CHECK: %[[C:.*]] = "ttir.isfinite"(%arg0, %[[E]]) | ||
// CHECK-SAME: (tensor<32x32x3xf32>, tensor<32x32x3xbf16>) -> tensor<32x32x3xbf16> | ||
%0 = stablehlo.is_finite %arg0 : (tensor<32x32x3xf32>) -> tensor<32x32x3xi1> | ||
// CHECK: return %[[C]] : tensor<32x32x3xbf16> | ||
return %0 : tensor<32x32x3xi1> | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
test/ttmlir/Dialect/TTNN/eltwise/unary/floor/simple_floor.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 @floor(%arg0: tensor<64x128xf32>) -> tensor<64x128xf32> { | ||
// CHECK: %{{[0-9]+}} = "ttnn.empty" | ||
// CHECK-SAME: [[TENSOR:tensor<64x128xf32,]] | ||
%0 = tensor.empty() : tensor<64x128xf32> | ||
// CHECK: %{{[0-9]+}} = "ttnn.floor" | ||
// CHECK-SAME: [[TENSOR]] | ||
// CHECK-SAME: [[TENSOR]] | ||
// CHECK-SAME: -> [[TENSOR]] | ||
%1 = "ttir.floor"(%arg0, %0) <{operandSegmentSizes = array<i32: 1, 1>, operand_constraints = [#any_device, #any_device]}> : (tensor<64x128xf32>, tensor<64x128xf32>) -> tensor<64x128xf32> | ||
return %1 : tensor<64x128xf32> | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
test/ttmlir/Dialect/TTNN/eltwise/unary/isfinite/simple_isfinite.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 @is_finite(%arg0: tensor<64x128xf32>) -> tensor<64x128xbf16> { | ||
// CHECK: %[[C:.*]] = "ttnn.empty" | ||
// CHECK-SAME: [[TENSOR:tensor<64x128xbf16,]] | ||
%0 = tensor.empty() : tensor<64x128xbf16> | ||
// CHECK: %[[C:.*]] = "ttnn.isfinite" | ||
// CHECK-SAME: tensor<64x128xf32, | ||
// CHECK-SAME: [[TENSOR]] | ||
// CHECK-SAME: -> [[TENSOR]] | ||
%1 = "ttir.isfinite"(%arg0, %0) <{operandSegmentSizes = array<i32: 1, 1>, operand_constraints = [#any_device, #any_device]}> : (tensor<64x128xf32>, 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,17 @@ | ||
// 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> | ||
|
||
func.func @floor(%arg0: tensor<64x128xf32>) -> tensor<64x128xf32> { | ||
// CHECK: %{{[0-9]+}} = "ttnn.empty" | ||
// CHECK-SAME: [[TENSOR:tensor<64x128xf32,]] | ||
%0 = tensor.empty() : tensor<64x128xf32> | ||
// CHECK: %{{[0-9]+}} = "ttnn.floor" | ||
// CHECK-SAME: [[TENSOR]] | ||
// CHECK-SAME: [[TENSOR]] | ||
// CHECK-SAME: -> [[TENSOR]] | ||
%1 = "ttir.floor"(%arg0, %0) <{operandSegmentSizes = array<i32: 1, 1>, operand_constraints = [#any_device, #any_device]}> : (tensor<64x128xf32>, tensor<64x128xf32>) -> tensor<64x128xf32> | ||
return %1 : tensor<64x128xf32> | ||
} |
17 changes: 17 additions & 0 deletions
17
test/ttmlir/Silicon/TTNN/perf_unit/test_perf_isfinite.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,17 @@ | ||
// 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> | ||
|
||
func.func @is_finite(%arg0: tensor<64x128xf32>) -> tensor<64x128xbf16> { | ||
// CHECK: %[[C:.*]] = "ttnn.empty" | ||
// CHECK-SAME: [[TENSOR:tensor<64x128xbf16,]] | ||
%0 = tensor.empty() : tensor<64x128xbf16> | ||
// CHECK: %[[C:.*]] = "ttnn.isfinite" | ||
// CHECK-SAME: tensor<64x128xf32, | ||
// CHECK-SAME: [[TENSOR]] | ||
// CHECK-SAME: -> [[TENSOR]] | ||
%1 = "ttir.isfinite"(%arg0, %0) <{operandSegmentSizes = array<i32: 1, 1>, operand_constraints = [#any_device, #any_device]}> : (tensor<64x128xf32>, 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