-
Notifications
You must be signed in to change notification settings - Fork 14.7k
[mlir][tosa] Use typeConverter->convertType<T>
#150578
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Since `resultTy` might be nullptr, we should use `dyn_cast` instead of `cast`. Additionally, `typeConverter->convertType<T>` is more appropriate in this context.
@llvm/pr-subscribers-mlir-linalg @llvm/pr-subscribers-mlir-tosa Author: Longsheng Mou (CoTinker) ChangesSince Full diff: https://github.com/llvm/llvm-project/pull/150578.diff 1 Files Affected:
diff --git a/mlir/lib/Conversion/TosaToLinalg/TosaToLinalgNamed.cpp b/mlir/lib/Conversion/TosaToLinalg/TosaToLinalgNamed.cpp
index 3a205246ddd9e..b7fb7a18c7714 100644
--- a/mlir/lib/Conversion/TosaToLinalg/TosaToLinalgNamed.cpp
+++ b/mlir/lib/Conversion/TosaToLinalg/TosaToLinalgNamed.cpp
@@ -742,7 +742,7 @@ class MaxPool2dConverter : public OpConversionPattern<tosa::MaxPool2dOp> {
bool isUnsigned = op.getType().getElementType().isUnsignedInteger();
ShapedType resultTy =
- cast<ShapedType>(getTypeConverter()->convertType(op.getType()));
+ getTypeConverter()->convertType<ShapedType>(op.getType());
if (!resultTy)
return rewriter.notifyMatchFailure(op, "failed to convert type");
Type resultETy = inputTy.getElementType();
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this really an NFC if we have gone from a static cast to a dynamic one? If not, could we add a test to exercise this change?
Yea, you are right. But can't build a test now for that typeConvert not return nullptr. llvm-project/mlir/lib/Dialect/Tosa/Transforms/TosaTypeConverters.cpp Lines 20 to 33 in d4f9c11
|
typeConverter->convertType<T>
(NFC)typeConverter->convertType<T>
typeConverter->convertType<T>
typeConverter->convertType<T>
Hi @lhutton1 , could you please take a look at this PR? thanks. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks!
Thanks for your review. |
Since
resultTy
might be nullptr, we should usedyn_cast
instead ofcast
. Additionally,typeConverter->convertType<T>
is more appropriate in this context.