Skip to content
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

[Query] The refback-munge-calling-conventions pass employed in the backend from linalg to llvm, causes runtime error #3682

Open
Abhishek-TyRnT opened this issue Sep 1, 2024 · 6 comments

Comments

@Abhishek-TyRnT
Copy link
Contributor

I was running the Conv1d_transpose op test case, lowering it to the llvm IR from linalg-from-tensors Dialect. I notice that this test is marked as crashing test case in x_fail test cases

# Runtime op verification: subview is out-of-bounds of the base memref
"Conv_Transpose1dModule_basic",
"Conv_Transpose1dStaticModule_basic",
"Conv_Transpose2dModule_basic",
"Conv_Transpose2dStaticModule_basic",

I tried to debug this issue.
Upon investigating I noticed that there is an following Runtime Error from llvm

"ERROR: Runtime op verification failed\0A%9 = \22memref.cast\22(%arg0) : (memref<*xf32>) -> memref<?x?x?xf32>\0A^ rank mismatch\0ALocation: loc(unknown)"

You can see that the memref is trying to cast an unranked tensor to ranked tensor, which is not allowed in the generate-runtime- verification pass , called here

]
if generate_runtime_verification:
passes += ["generate-runtime-verification"]
passes += [

The above casting operation is called after refback-munge-calling-conventions which gets rid of the ranked memrefs. My question is why is this pass necessary, this pass will clearly fail runtime verification since there is no way one could know at runtime what input we are getting and what is it's rank. Am I missing here something ? Please let me know

@vivekkhandelwal1
Copy link
Collaborator

Hi @Abhishek-TyRnT, the support for this was added here #3615 by @mgehre-amd. Please refer to this PR and ask the author if you have any issues.

@mgehre-amd
Copy link
Contributor

Is the question about refback-munge-calling-conventions or generate-runtime- verification?

@Abhishek-TyRnT
Copy link
Contributor Author

@mgehre-amd , the question was originally about refback-munge-calling-conventions, but since generate-runtime-verification was added later on, I am curious as to why that pass was added, since refback-munge-calling-conventions will eliminate rank data for the above operation, which generate-runtime-verification pass doesn't allow?

@mgehre-amd
Copy link
Contributor

generate-runtime-verification does allow memref.cast from unranked to ranked tensors, but it checks that the rank of the destination matches the dynamic rank of the input tensor (at runtime).

Otherwise the memref.cast op is invalid (see https://mlir.llvm.org/docs/Dialects/MemRef/#memrefcast-memrefcastop), which seems to be happening for this test case.

generate-runtime-verification doesn't complain about other test cases, and those also run refback-munge-calling-conventions.

I think the Conv_Transpose1d lowering needs to be fixed, but I have not looked into the details of it.

@vivekkhandelwal1
Copy link
Collaborator

generate-runtime-verification does allow memref.cast from unranked to ranked tensors, but it checks that the rank of the destination matches the dynamic rank of the input tensor (at runtime).

Otherwise the memref.cast op is invalid (see https://mlir.llvm.org/docs/Dialects/MemRef/#memrefcast-memrefcastop), which seems to be happening for this test case.

generate-runtime-verification doesn't complain about other test cases, and those also run refback-munge-calling-conventions.

I think the Conv_Transpose1d lowering needs to be fixed, but I have not looked into the details of it.

If the issue is with Conv_Transpose1d lowering then it would be better to file an issue for the same. @Abhishek-TyRnT, if you need that support then maybe file an issue.

@Abhishek-TyRnT
Copy link
Contributor Author

I was hoping to fix it myself and send as a contribution,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants