Skip to content

Commit 716e7e6

Browse files
committed
[mlir][tosa] Finalize profile-based validation for TOSA v1.0
- When the operand type of an operation changes to a profile-dependent type, the compliance metadata must be updated. Update compliance check for the following: - CONV2D, CONV3D, DEPTHWISE_CONV2D, and TRANSPOSE_CONV2D, as zero points have changed to variable inputs. - PAD, because pad_const has been changed to a variable input. - GATHER and SCATTER, as indices has changed to index_t. - Add an int16 extension check for CONCAT. - Add a compliance check for VARIABLE, VARIABLE_READ, and VARIABLE_WRITE. - Correct the profile requirements for IDENTITY, TABLE, MATMUL and LOGICAL-like operations. - Remove unnecessary checks for non-v1.0 operations. - Add condition requirements (anyOf and allOf) to the type mode of metadata for modes that have multiple profile/extension considerations.
1 parent c3f7502 commit 716e7e6

File tree

9 files changed

+359
-176
lines changed

9 files changed

+359
-176
lines changed

mlir/include/mlir/Dialect/Tosa/IR/TosaComplianceData.h.inc

Lines changed: 129 additions & 101 deletions
Large diffs are not rendered by default.

mlir/include/mlir/Dialect/Tosa/IR/TosaOps.td

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -801,7 +801,7 @@ def Tosa_LogicalAndOp : Tosa_ElementwiseOp<"logical_and", [
801801
);
802802

803803
list<Availability> availability = [
804-
Profile<[Tosa_PRO_INT]>,
804+
Profile<[Tosa_PRO_INT, Tosa_PRO_FP]>,
805805
Extension<[]>,
806806
];
807807
}
@@ -828,7 +828,7 @@ def Tosa_LogicalLeftShiftOp : Tosa_ElementwiseOp<"logical_left_shift",
828828
);
829829

830830
list<Availability> availability = [
831-
Profile<[Tosa_PRO_INT]>,
831+
Profile<[Tosa_PRO_INT, Tosa_PRO_FP]>,
832832
Extension<[]>,
833833
];
834834
}
@@ -856,7 +856,7 @@ def Tosa_LogicalRightShiftOp : Tosa_ElementwiseOp<"logical_right_shift",
856856
);
857857

858858
list<Availability> availability = [
859-
Profile<[Tosa_PRO_INT]>,
859+
Profile<[Tosa_PRO_INT, Tosa_PRO_FP]>,
860860
Extension<[]>,
861861
];
862862
}
@@ -884,7 +884,7 @@ def Tosa_LogicalOrOp : Tosa_ElementwiseOp<"logical_or", [
884884
);
885885

886886
list<Availability> availability = [
887-
Profile<[Tosa_PRO_INT]>,
887+
Profile<[Tosa_PRO_INT, Tosa_PRO_FP]>,
888888
Extension<[]>,
889889
];
890890
}
@@ -912,7 +912,7 @@ def Tosa_LogicalXorOp : Tosa_ElementwiseOp<"logical_xor", [
912912
);
913913

914914
list<Availability> availability = [
915-
Profile<[Tosa_PRO_INT]>,
915+
Profile<[Tosa_PRO_INT, Tosa_PRO_FP]>,
916916
Extension<[]>,
917917
];
918918
}
@@ -1108,7 +1108,7 @@ def Tosa_TableOp : Tosa_InferShapedTypeOp<"table"> {
11081108

11091109
list<Availability> availability = [
11101110
Profile<[Tosa_PRO_INT]>,
1111-
Extension<[Tosa_EXT_BF16]>,
1111+
Extension<[Tosa_EXT_INT16]>,
11121112
];
11131113

11141114
let assemblyFormat = [{
@@ -1910,15 +1910,15 @@ def Tosa_PadOp : Tosa_InferShapedTypeOp<"pad"> {
19101910
Example:
19111911

19121912
```mlir
1913-
%0 = tosa.const_shape { value = dense<[1, 2, 3, 4]> : tensor<4xindex> } : () -> !tosa.shape<4>
1914-
tosa.pad %arg0, %0 : (tensor<1x2xf32>, !tosa.shape<4>) -> (tensor<4x9xf32>)
1913+
%padding = tosa.const_shape { value = dense<[1, 2, 3, 4]> : tensor<4xindex> } : () -> !tosa.shape<4>
1914+
tosa.pad %arg0, %padding, %pad_const: (tensor<1x2xf32>, !tosa.shape<4>, tensor<1xi1>) -> (tensor<4x9xf32>)
19151915
```
19161916

19171917
Example 2:
19181918

19191919
```mlir
1920-
%0 = tosa.const_shape { value = dense<[-1, 2, 3, 4]> : tensor<4xindex> } : () -> !tosa.shape<4>
1921-
tosa.pad %arg0, %0 : (tensor<1x2xf32>, !tosa.shape<4>) -> (tensor<?x9xf32>)
1920+
%padding = tosa.const_shape { value = dense<[-1, 2, 3, 4]> : tensor<4xindex> } : () -> !tosa.shape<4>
1921+
tosa.pad %arg0, %padding, %pad_const : (tensor<1x2xf32>, !tosa.shape<4>, tensor<1xi1>) -> (tensor<?x9xf32>)
19221922
```
19231923
}];
19241924

mlir/include/mlir/Dialect/Tosa/IR/TosaProfileCompliance.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,11 @@ typedef struct {
2929
} TypeInfo;
3030

3131
enum CheckCondition {
32+
invalid,
3233
// Valid when any of the profile (extension) requirement is meet.
3334
anyOf,
3435
// Valid when all of the profile (extension) requirement are meet.
35-
allOf,
36-
invalid
36+
allOf
3737
};
3838

3939
template <typename T>
@@ -76,20 +76,20 @@ class ProfileInfoDepot {
7676

7777
LogicalResult populatationDispatch(Operation *op);
7878

79-
void populateProfileInfo(ValueRange operands, Value output);
79+
LogicalResult populateProfileInfo(ValueRange operands, Value output);
8080

8181
// Base
8282
template <typename T>
83-
void populateProfileInfo(T op) {
83+
LogicalResult populateProfileInfo(T op) {
8484
op->emitOpError() << "profile requirement for this op has not been defined";
8585
}
8686
// For conv2d, conv3d, transpose_conv2d, and depthwise_conv2d.
8787
template <typename T>
88-
void populateProfileInfoConv(T op);
88+
LogicalResult populateProfileInfoConv(T op);
8989

90-
// For pad, reshape, slice, tile, and transpose.
90+
// For reshape, slice, tile, and transpose.
9191
template <typename T>
92-
void populateProfileInfoDataLayout(T op);
92+
LogicalResult populateProfileInfoDataLayout(T op);
9393

9494
private:
9595
SmallVector<TypeInfo> tyInfo;

0 commit comments

Comments
 (0)