-
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.
Fix legalization of stablehlo.dot_general to TTIR matmul (#1311)
Add batch matmul silicon test
- Loading branch information
Showing
5 changed files
with
96 additions
and
14 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
File renamed without changes.
10 changes: 10 additions & 0 deletions
10
test/ttmlir/Conversion/StableHLOToTTIR/dot_general/dot_general_3d.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,10 @@ | ||
// REQUIRES: stablehlo | ||
// RUN: ttmlir-opt --stablehlo-to-ttir-pipeline %s | FileCheck %s | ||
module { | ||
func.func @main(%arg0: tensor<8x1x920xbf16>, %arg1: tensor<8x100x32xbf16>, %arg2: tensor<8x32x920xbf16>) -> tensor<8x100x920xbf16> { | ||
%0 = stablehlo.broadcast_in_dim %arg2, dims = [0, 1, 2] : (tensor<8x32x920xbf16>) -> tensor<8x32x920xbf16> | ||
// CHECK: %[[C:.*]] = "ttir.matmul"[[C:.*]] | ||
%1 = stablehlo.dot_general %arg1, %0, batching_dims = [0] x [0], contracting_dims = [2] x [1] : (tensor<8x100x32xbf16>, tensor<8x32x920xbf16>) -> tensor<8x100x920xbf16> | ||
return %1 : tensor<8x100x920xbf16> | ||
} | ||
} |
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
21 changes: 21 additions & 0 deletions
21
test/ttmlir/Silicon/StableHLO/dot_general/dot_general_op_batch_matmul.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,21 @@ | ||
// REQUIRES: stablehlo | ||
// RUN: rm -rf %t.ttnn | ||
// RUN: rm -rf %t.mlir | ||
// RUN: ttmlir-opt --stablehlo-to-ttir-pipeline %s | \ | ||
// RUN: ttmlir-opt --ttir-to-ttnn-backend-pipeline="system-desc-path=%system_desc_path%" > %t.mlir | ||
// RUN: ttmlir-translate --ttnn-to-flatbuffer %t.mlir > %t.ttnn | ||
// RUN: FileCheck --input-file=%t.mlir %s | ||
|
||
module @jit_dot_general_4d attributes {} { | ||
func.func public @test_dot_general_4d(%arg0 : tensor<1x128x16x32xf32>, %arg1 : tensor<1x128x32x8xf32>) -> tensor<1x128x16x8xf32> { | ||
// CHECK-LABEL: func.func public @test_dot_general | ||
// CHECK: ttnn.empty | ||
// CHECK: ttnn.matmul | ||
// CHECK-SAME: tensor<1x128x16x32xf32, | ||
// CHECK-SAME: tensor<1x128x32x8xf32, | ||
// CHECK-SAME: tensor<1x128x16x8xf32, | ||
// CHECK-SAME: -> tensor<1x128x16x8xf32 | ||
%0 = stablehlo.dot_general %arg0, %arg1, batching_dims = [0, 1] x [0, 1], contracting_dims = [3] x [2] : (tensor<1x128x16x32xf32>, tensor<1x128x32x8xf32>) -> tensor<1x128x16x8xf32> | ||
return %0 : tensor<1x128x16x8xf32> | ||
} | ||
} |