-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
[TVMScript] Distinguish between void* and handle #14488
[TVMScript] Distinguish between void* and handle #14488
Conversation
Thanks for contributing to TVM! Please refer to the contributing guidelines https://tvm.apache.org/docs/contribute/ for useful information and tips. Please request code reviews from Reviewers by @-ing them in a comment.
Generated by tvm-bot |
At some point, it may make sense to have |
07dfd61
to
cbd086b
Compare
cbd086b
to
ad97955
Compare
Yeah I made the change a while ago to unify |
Certainly! This occurs in any PrimFunc that is after |
The original intention there is to make the |
I do think allow possibility to express two different handle types will give developers more opportunities, so I would prefer merging this PR in, as well as updating MakePackedAPI. That would be nice if we could document a bit more about in |
From some quick tests, either representation could be removed without much difficulty. If we were getting rid of one of the two representations, I'd lean toward keeping the That said, having a distinction between a pointer to a value and an opaque handle is probably a good one to keep around, so I'd lean toward @junrushao's suggestion. |
happy to go with @junrushao @Lunderberg what you suggest |
* \param is_unknown_type Used to distinguish between | ||
* `PrimType(DataType::Handle())` and | ||
* `PointerType(PrimType(DataType::Void()))`. If true, resolve dtype | ||
* of `Void()` as `PrimType`, and if false resolve dtype of `Void()` |
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.
Void
is defined as DataType(kHandle, 0, 0)
, while a legitimate handle has non-zero bits and lanes. Do we need an additional parameter here instead of passing the right thing in dtype
?
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.
I believe so, because the dtype
is providing the type of the pointed-to object, not the type of the pointer itself. While we could special-case passing of a DataType(kHandle, 0, 0)
to produce PrimType(DataType::Handle())
, that would give unexpected results if somebody tries to write a pointer-to-pointer as T.handle("handle")
and accidentally hits the special-case.
@tvm-bot rerun |
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.
Let's get it in!
Prior to this PR, the type annotations
PrimType(DataType::Handle())
andPointerType(PrimType(DataType::Void()))
are both represented asT.handle
in TVMScript, which can cause failures to round-trip between TIR and TVMScript. This PR keepsPrimType(DataType::Handle())
asT.handle
, but updates the representation ofPointerType(PrimType(DataType::Void()))
toT.handle("void")
in order to distinguish between these two cases.This is part of changes described in #14486, to improve round-trip failures that occur in lowering.