-
Notifications
You must be signed in to change notification settings - Fork 10
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 ops. * Add stablehlo to ttir conversion for clamp op.
- Loading branch information
1 parent
6bad515
commit 669e8a0
Showing
13 changed files
with
274 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
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,26 @@ | ||
// REQUIRES: stablehlo | ||
// RUN: ttmlir-opt --stablehlo-to-ttir-pipeline %s | FileCheck %s | ||
module @jit_transpose attributes {} { | ||
func.func public @test_clamp_constant(%arg0: tensor<4xf32>) -> tensor<4xf32> { | ||
%cst = stablehlo.constant dense<2.000000e+00> : tensor<4xf32> | ||
%cst_0 = stablehlo.constant dense<3.000000e+00> : tensor<4xf32> | ||
// CHECK: %[[EMPTY:.*]] = tensor.empty() : [[TENSOR:tensor<4xf32>]] | ||
// CHECK: "ttir.clamp"(%arg0, %[[EMPTY]]) | ||
// CHECK-SAME: max = 3.000000e+00 : f32, min = 2.000000e+00 : f32, | ||
// CHECK-SMAE: ([[TENSOR]], [[TENSOR]]) -> [[TENSOR]] | ||
%0 = stablehlo.clamp %cst, %arg0, %cst_0 : tensor<4xf32> | ||
return %0 : tensor<4xf32> | ||
} | ||
|
||
func.func public @test_clamp_tensor(%arg0: tensor<4xf32>, %arg1: tensor<4xf32>, %arg2: tensor<4xf32>) -> tensor<4xf32> { | ||
// CHECK: %[[EMPTY0:.*]] = tensor.empty() : [[TENSOR:tensor<4xf32>]] | ||
// CHECK: %[[MAX:.*]] = "ttir.maximum"(%arg1, %arg0, %[[EMPTY0]]) | ||
// CHECK-SAME: ([[TENSOR]], [[TENSOR]], [[TENSOR]]) -> [[TENSOR]] | ||
// CHECK: %[[EMPTY1:.*]] = tensor.empty() : [[TENSOR]] | ||
// CHECK: %[[MIN:.*]] = "ttir.minimum"(%[[MAX]], %arg2, %[[EMPTY1]]) | ||
// CHECK-SAME: ([[TENSOR]], [[TENSOR]], [[TENSOR]]) -> [[TENSOR]] | ||
%0 = stablehlo.clamp %arg1, %arg0, %arg2 : tensor<4xf32> | ||
// CHECK: return %[[MIN]] : [[TENSOR]] | ||
return %0 : tensor<4xf32> | ||
} | ||
} |
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_tile = #tt.operand_constraint<dram|l1|tile|any_device_tile> | ||
module attributes {} { | ||
func.func @clamp(%arg0: tensor<64x128xbf16>) -> tensor<64x128xbf16> { | ||
%0 = tensor.empty() : tensor<64x128xbf16> | ||
// CHECK: %[[DEVICE:.*]] = "ttnn.to_device"(%arg0, | ||
// CHECK: %[[LAYOUT:.*]] = "ttnn.to_layout"(%[[DEVICE]]) | ||
// CHECK: = "ttnn.clamp"(%[[LAYOUT]]) | ||
// CHECK-SAME: {max = 3.000000e+00 : f32, min = 2.000000e+00 : f32} | ||
// CHECK-SAME: [[TENSOR:tensor<64x128xbf16]], #layout{{[0-9]+}}>) -> [[TENSOR]] | ||
%1 = "ttir.clamp"(%arg0, %0) <{max = 3.000000e+00 : f32, min = 2.000000e+00 : f32, operand_constraints = [#any_device_tile, #any_device_tile, #any_device_tile, #any_device_tile]}> : (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,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 @clamp(%arg0: tensor<64x128xbf16>) -> tensor<64x128xbf16> { | ||
%0 = tensor.empty() : tensor<64x128xbf16> | ||
// CHECK: %[[DEVICE:.*]] = "ttnn.to_device"(%arg0, | ||
// CHECK: %[[LAYOUT:.*]] = "ttnn.to_layout"(%[[DEVICE]]) | ||
// CHECK: = "ttnn.clamp"(%[[LAYOUT]]) | ||
// CHECK-SAME: {max = 3.000000e+00 : f32, min = 2.000000e+00 : f32} | ||
// CHECK-SAME: [[TENSOR:tensor<64x128xbf16]], #layout{{[0-9]+}}>) -> [[TENSOR]] | ||
%1 = "ttir.clamp"(%arg0, %0) <{max = 3.000000e+00 : f32, min = 2.000000e+00 : f32, operand_constraints = [#any_device_tile, #any_device_tile, #any_device_tile, #any_device_tile]}> : (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