@@ -2118,7 +2118,7 @@ llvm::LogicalResult tosa::ReshapeOp::verify() {
2118
2118
// return failure if val is not a constant
2119
2119
// set zp to -1 if val is non-zero float or val is not integer nor float
2120
2120
// otherwise set zp to val's constant value
2121
- static FailureOr<int64_t > getZeroPoint (Value val) {
2121
+ static FailureOr<int64_t > getZeroPoint (Value val, bool signExtend ) {
2122
2122
ElementsAttr zpAttr;
2123
2123
if (!matchPattern (val, m_Constant (&zpAttr))) {
2124
2124
return failure ();
@@ -2135,7 +2135,10 @@ static FailureOr<int64_t> getZeroPoint(Value val) {
2135
2135
}
2136
2136
2137
2137
if (llvm::isa<IntegerType>(zpElemType)) {
2138
- return zpAttr.getValues <APInt>()[0 ].getSExtValue ();
2138
+ if (signExtend)
2139
+ return zpAttr.getValues <APInt>()[0 ].getSExtValue ();
2140
+ else
2141
+ return zpAttr.getValues <APInt>()[0 ].getZExtValue ();
2139
2142
}
2140
2143
2141
2144
// return non-zero value to trigger error check
@@ -2186,30 +2189,30 @@ static LogicalResult verifyZeroPoint(tosa::RescaleOp op, Value zpVal,
2186
2189
return success ();
2187
2190
}
2188
2191
2189
- #define ZERO_POINT_HELPER (OP, OPERAND_NAME ) \
2192
+ #define ZERO_POINT_HELPER (OP, OPERAND_NAME, SIGN_EXTEND ) \
2190
2193
FailureOr<int64_t > tosa::OP::get##OPERAND_NAME##ZeroPoint() { \
2191
- return getZeroPoint (get##OPERAND_NAME##Zp ()); \
2194
+ return getZeroPoint (get##OPERAND_NAME##Zp (), SIGN_EXTEND); \
2192
2195
} \
2193
2196
LogicalResult tosa::OP::verify##OPERAND_NAME##ZeroPoint(int64_t zp) { \
2194
2197
return verifyZeroPoint (*this , get##OPERAND_NAME##Zp (), zp, #OPERAND_NAME); \
2195
2198
}
2196
2199
2197
- ZERO_POINT_HELPER (Conv2DOp, Input)
2198
- ZERO_POINT_HELPER(Conv2DOp, Weight)
2199
- ZERO_POINT_HELPER(Conv3DOp, Input)
2200
- ZERO_POINT_HELPER(Conv3DOp, Weight)
2201
- ZERO_POINT_HELPER(DepthwiseConv2DOp, Input)
2202
- ZERO_POINT_HELPER(DepthwiseConv2DOp, Weight)
2203
- ZERO_POINT_HELPER(TransposeConv2DOp, Input)
2204
- ZERO_POINT_HELPER(TransposeConv2DOp, Weight)
2205
- ZERO_POINT_HELPER(AvgPool2dOp, Input)
2206
- ZERO_POINT_HELPER(AvgPool2dOp, Output)
2207
- ZERO_POINT_HELPER(MatMulOp, A)
2208
- ZERO_POINT_HELPER(MatMulOp, B)
2209
- ZERO_POINT_HELPER(NegateOp, Input1)
2210
- ZERO_POINT_HELPER(NegateOp, Output)
2211
- ZERO_POINT_HELPER(RescaleOp, Input)
2212
- ZERO_POINT_HELPER(RescaleOp, Output)
2200
+ ZERO_POINT_HELPER (Conv2DOp, Input, true )
2201
+ ZERO_POINT_HELPER(Conv2DOp, Weight, true )
2202
+ ZERO_POINT_HELPER(Conv3DOp, Input, true )
2203
+ ZERO_POINT_HELPER(Conv3DOp, Weight, true )
2204
+ ZERO_POINT_HELPER(DepthwiseConv2DOp, Input, true )
2205
+ ZERO_POINT_HELPER(DepthwiseConv2DOp, Weight, true )
2206
+ ZERO_POINT_HELPER(TransposeConv2DOp, Input, true )
2207
+ ZERO_POINT_HELPER(TransposeConv2DOp, Weight, true )
2208
+ ZERO_POINT_HELPER(AvgPool2dOp, Input, true )
2209
+ ZERO_POINT_HELPER(AvgPool2dOp, Output, true )
2210
+ ZERO_POINT_HELPER(MatMulOp, A, true )
2211
+ ZERO_POINT_HELPER(MatMulOp, B, true )
2212
+ ZERO_POINT_HELPER(NegateOp, Input1, true )
2213
+ ZERO_POINT_HELPER(NegateOp, Output, true )
2214
+ ZERO_POINT_HELPER(RescaleOp, Input, !getInputUnsigned() )
2215
+ ZERO_POINT_HELPER(RescaleOp, Output, !getOutputUnsigned() )
2213
2216
#undef ZERO_POINT_HELPER
2214
2217
2215
2218
LogicalResult tosa::TransposeOp::inferReturnTypeComponents (
0 commit comments