-
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.
* Add end-to-end support for typecast op * Add stablehlo.convert conversion to typecast op * Add required test cases
- Loading branch information
1 parent
5856bb6
commit 641ef7f
Showing
11 changed files
with
96 additions
and
3 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 |
---|---|---|
|
@@ -64,6 +64,7 @@ enum EltwiseOpType: uint32 { | |
Abs = 11, | ||
Neg = 12, | ||
Rsqrt = 13, | ||
Typecast = 14, | ||
} | ||
|
||
table EltwiseOp { | ||
|
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 | ||
#any_device = #tt.operand_constraint<dram|l1|scalar|tile|any_device|any_device_tile> | ||
module @jit_eltwise_convert attributes {} { | ||
func.func public @test_convert(%arg0: tensor<2x4xf32>) -> tensor<2x4xbf16> { | ||
%0 = stablehlo.convert %arg0 : (tensor<2x4xf32>) -> tensor<2x4xbf16> | ||
// CHECK: %[[C:.*]] = tensor.empty[[C:.*]] | ||
// CHECK: %[[C:.*]] = "ttir.typecast" | ||
// CHECK-SAME: (tensor<2x4xf32>, tensor<2x4xbf16>) -> tensor<2x4xbf16> | ||
return %0 : tensor<2x4xbf16> | ||
} | ||
} | ||
|
||
module @jit_eltwise_add attributes {} { | ||
func.func public @test_add(%arg0: tensor<13x21x3xf32>, %arg1: tensor<13x21x3xf32>) -> tensor<13x21x3xf32> { | ||
%0 = stablehlo.convert %arg0 : tensor<13x21x3xf32> | ||
// CHECK: %[[C:.*]] = tensor.empty[[C:.*]] | ||
// CHECK: %[[ARG1:.*]] = "ttir.typecast"[[C:.*]] | ||
%1 = stablehlo.convert %arg1 : tensor<13x21x3xf32> | ||
// CHECK: %[[C:.*]] = tensor.empty[[C:.*]] | ||
// CHECK: %[[ARG2:.*]] = "ttir.typecast"[[C:.*]] | ||
%2 = stablehlo.add %0, %1 : tensor<13x21x3xf32> | ||
// CHECK: %[[C:.*]] = "ttir.add"(%[[ARG1]], %[[ARG2]], | ||
return %2 : tensor<13x21x3xf32> | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
test/ttmlir/Dialect/TTNN/eltwise/unary/cast/simple_cast.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,13 @@ | ||
// 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 @forward(%arg0: tensor<64x128xf32>) -> tensor<64x128xbf16> { | ||
%0 = tensor.empty() : tensor<64x128xbf16> | ||
// CHECK: {{.*}} = "ttnn.empty"{{.*}} | ||
%1 = "ttir.typecast"(%arg0, %0) <{operandSegmentSizes = array<i32: 1, 1>, operand_constraints = [#any_device, #any_device]}> : (tensor<64x128xf32>, tensor<64x128xbf16>) -> tensor<64x128xbf16> | ||
// CHECK: %[[C:.*]] = "ttnn.typecast" | ||
// CHECK-SAME: tensor<64x128xf32, | ||
// CHECK-SAME: 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