-
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.
Additional verifications of TTIR dialect ops
- Refactoring of ElementwiseOpInteface to better reflect intention, with fix of broadcast shape calculation, considering that operand that represetnts destination shouldn't affect output shape. - Check number of operands for AttrSizedOperandSegments ops with simple traits. - Minor refactoring of TTIR_GenericOp. Addresses #1289, but I would leave it as open to track further progress with similar traits and interfaces needed in the TTNN dialect.
- Loading branch information
1 parent
4083e98
commit c169963
Showing
6 changed files
with
115 additions
and
61 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// RUN: not ttmlir-opt --split-input-file %s 2>&1 | FileCheck %s | ||
// Negative tests for Broadcastable interface | ||
|
||
// CHECK: 'ttir.abs' op Result shape must match operand shapes after broadcasting | ||
#any_device_tile = #tt.operand_constraint<dram|l1|tile|any_device_tile> | ||
func.func @eltwise_unary(%arg0: tensor<1x64xbf16>) -> tensor<2x64xbf16> { | ||
%0 = tensor.empty() : tensor<2x64xbf16> | ||
%1 = "ttir.abs"(%arg0, %0) <{operandSegmentSizes = array<i32: 1, 1>, operand_constraints = [#any_device_tile, #any_device_tile]}> : (tensor<1x64xbf16>, tensor<2x64xbf16>) -> tensor<2x64xbf16> | ||
return %1 : tensor<2x64xbf16> | ||
} | ||
|
||
// ----- | ||
// CHECK: error: 'ttir.add' op Result shape must match operand shapes after broadcasting | ||
#any_device_tile = #tt.operand_constraint<dram|l1|tile|any_device_tile> | ||
func.func @eltwise_binary(%arg0: tensor<2x3x64xf32>, %arg1: tensor<64xf32>) -> tensor<4x2x3x64xf32> { | ||
%0 = tensor.empty() : tensor<4x2x3x64xf32> | ||
%1 = "ttir.add"(%arg0, %arg1, %0) <{operandSegmentSizes = array<i32: 2, 1>, operand_constraints = [#any_device_tile, #any_device_tile, #any_device_tile]}> : (tensor<2x3x64xf32>, tensor<64xf32>, tensor<4x2x3x64xf32>) -> tensor<4x2x3x64xf32> | ||
return %1 : tensor<4x2x3x64xf32> | ||
} | ||
|
||
// ----- | ||
// CHECK: error: 'ttir.where' op Result shape must match operand shapes after broadcasting | ||
#any_device_tile = #tt.operand_constraint<dram|l1|tile|any_device_tile> | ||
func.func @eltwise_ternary(%arg0: tensor<3x64xf32>, %arg1: tensor<1x3x64xf32>, %arg2: tensor<2x1x64xf32>) -> tensor<1x2x3x64xf32> { | ||
%0 = tensor.empty() : tensor<1x2x3x64xf32> | ||
%1 = "ttir.where"(%arg0, %arg1, %arg2, %0) <{operandSegmentSizes = array<i32: 3, 1>, operand_constraints = [#any_device_tile, #any_device_tile, #any_device_tile, #any_device_tile]}> : (tensor<3x64xf32>, tensor<1x3x64xf32>, tensor<2x1x64xf32>, tensor<1x2x3x64xf32>) -> tensor<1x2x3x64xf32> | ||
return %1 : tensor<1x2x3x64xf32> | ||
} |
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,37 @@ | ||
// RUN: not ttmlir-opt --split-input-file %s 2>&1 | FileCheck %s | ||
// Negative tests for NOperands trait | ||
|
||
// CHECK: error: 'ttir.abs' op expected 2 operands, but found 3 | ||
#any_device_tile = #tt.operand_constraint<dram|l1|tile|any_device_tile> | ||
func.func @eltwise_unary(%arg0: tensor<64x64xbf16>) -> tensor<64x64xbf16> { | ||
%0 = tensor.empty() : tensor<64x64xbf16> | ||
%1 = "ttir.abs"(%arg0, %arg0, %0) <{operandSegmentSizes = array<i32: 2, 1>, operand_constraints = [#any_device_tile, #any_device_tile, #any_device_tile]}> : (tensor<64x64xbf16>, tensor<64x64xbf16>, tensor<64x64xbf16>) -> tensor<64x64xbf16> | ||
return %1 : tensor<64x64xbf16> | ||
} | ||
|
||
// ----- | ||
// CHECK: error: 'ttir.add' op expected 3 operands, but found 4 | ||
#any_device_tile = #tt.operand_constraint<dram|l1|tile|any_device_tile> | ||
func.func @eltwise_binary(%arg0: tensor<64x64xf32>, %arg1: tensor<64x64xf32>) -> tensor<64x64xf32> { | ||
%0 = tensor.empty() : tensor<64x64xf32> | ||
%1 = "ttir.add"(%arg0, %arg1, %arg1, %0) <{operandSegmentSizes = array<i32: 3, 1>, operand_constraints = [#any_device_tile, #any_device_tile, #any_device_tile, #any_device_tile]}> : (tensor<64x64xf32>, tensor<64x64xf32>, tensor<64x64xf32>, tensor<64x64xf32>) -> tensor<64x64xf32> | ||
return %1 : tensor<64x64xf32> | ||
} | ||
|
||
// ----- | ||
// CHECK: error: 'ttir.add' op expected 3 operands, but found 2 | ||
#any_device_tile = #tt.operand_constraint<dram|l1|tile|any_device_tile> | ||
func.func @eltwise_binary(%arg0: tensor<64x64xf32>) -> tensor<64x64xf32> { | ||
%0 = tensor.empty() : tensor<64x64xf32> | ||
%1 = "ttir.add"(%arg0, %0) <{operandSegmentSizes = array<i32: 1, 1>, operand_constraints = [#any_device_tile, #any_device_tile]}> : (tensor<64x64xf32>, tensor<64x64xf32>) -> tensor<64x64xf32> | ||
return %1 : tensor<64x64xf32> | ||
} | ||
|
||
// ----- | ||
// CHECK: error: 'ttir.where' op expected 4 operands, but found 5 | ||
#any_device_tile = #tt.operand_constraint<dram|l1|tile|any_device_tile> | ||
func.func @eltwise_ternary(%arg0: tensor<64x64xf32>, %arg1: tensor<64x64xf32>, %arg2: tensor<64x64xf32>) -> tensor<64x64xf32> { | ||
%0 = tensor.empty() : tensor<64x64xf32> | ||
%1 = "ttir.where"(%arg0, %arg1, %arg2, %arg2, %0) <{operandSegmentSizes = array<i32: 4, 1>, operand_constraints = [#any_device_tile, #any_device_tile, #any_device_tile, #any_device_tile, #any_device_tile]}> : (tensor<64x64xf32>, tensor<64x64xf32>, tensor<64x64xf32>, tensor<64x64xf32>, tensor<64x64xf32>) -> tensor<64x64xf32> | ||
return %1 : tensor<64x64xf32> | ||
} |