-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Output shape verification for reduce ops (#2374)
### Ticket Closes #2369 ### Problem description Some erroneous shapes would pass verification and only fail in the runtime due to wrong interpretation of `dim_arg` when its value is `nullopt`. There is an example in the linked issue. ### What's changed - Added verification when `dim_arg` is nullopt in TTNN - Added a shape verification in TTIR - Added negative tests ### Checklist - [x] New/Existing tests provide coverage for changes
- Loading branch information
1 parent
c7655a5
commit 7598a95
Showing
6 changed files
with
151 additions
and
74 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
2 changes: 1 addition & 1 deletion
2
test/ttmlir/Dialect/TTIR/reduction/negative_invalid_dim_high.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
2 changes: 1 addition & 1 deletion
2
test/ttmlir/Dialect/TTIR/reduction/negative_invalid_dim_low.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
41 changes: 41 additions & 0 deletions
41
test/ttmlir/Dialect/TTIR/reduction/negative_shape_mismatch.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,41 @@ | ||
// RUN: not ttmlir-opt --split-input-file %s 2>&1 | FileCheck %s | ||
// Negative tests for reduce ops expected shape mismatch. | ||
|
||
module { | ||
// CHECK: error: 'ttir.sum' op Expected output shape (128, 16), got (128, 16, 1) | ||
func.func public @shape_mismatch_0(%arg0: tensor<128x16x32xf32>) -> tensor<128x16x1xf32> { | ||
%0 = tensor.empty() : tensor<128x16x1xf32> | ||
%1 = "ttir.sum"(%arg0, %0) <{dim_arg = [2 : i32], keep_dim = false}> : (tensor<128x16x32xf32>, tensor<128x16x1xf32>) -> tensor<128x16x1xf32> | ||
return %1 : tensor<128x16x1xf32> | ||
} | ||
} | ||
|
||
// ----- | ||
module { | ||
// CHECK: error: 'ttir.sum' op Expected output shape (128, 16, 1), got (128, 16) | ||
func.func public @shape_mismatch_1(%arg0: tensor<128x16x32xf32>) -> tensor<128x16xf32> { | ||
%0 = tensor.empty() : tensor<128x16xf32> | ||
%1 = "ttir.sum"(%arg0, %0) <{dim_arg = [2 : i32], keep_dim = true}> : (tensor<128x16x32xf32>, tensor<128x16xf32>) -> tensor<128x16xf32> | ||
return %1 : tensor<128x16xf32> | ||
} | ||
} | ||
|
||
// ----- | ||
module { | ||
// CHECK: error: 'ttir.sum' op Expected output shape (1, 1, 1), got (128, 16, 1) | ||
func.func public @shape_mismatch_2(%arg0: tensor<128x16x32xf32>) -> tensor<128x16x1xf32> { | ||
%0 = tensor.empty() : tensor<128x16x1xf32> | ||
%1 = "ttir.sum"(%arg0, %0) <{keep_dim = true}> : (tensor<128x16x32xf32>, tensor<128x16x1xf32>) -> tensor<128x16x1xf32> | ||
return %1 : tensor<128x16x1xf32> | ||
} | ||
} | ||
|
||
// ----- | ||
module { | ||
// CHECK: error: 'ttir.sum' op Expected output shape (1), got (128, 16, 1) | ||
func.func public @shape_mismatch_3(%arg0: tensor<128x16x32xf32>) -> tensor<128x16x1xf32> { | ||
%0 = tensor.empty() : tensor<128x16x1xf32> | ||
%1 = "ttir.sum"(%arg0, %0) <{keep_dim = false}> : (tensor<128x16x32xf32>, tensor<128x16x1xf32>) -> tensor<128x16x1xf32> | ||
return %1 : tensor<128x16x1xf32> | ||
} | ||
} |
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