-
Notifications
You must be signed in to change notification settings - Fork 3.8k
[Target] Add target_device_type attribute to override default device_type #12509
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
|
I tried to start a discussion on the forum, but it's not attracting a lot of attention... |
Mousius
left a comment
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.
This doesn't seem controversial, using a getter seems better than direct access in either case - the one thing I would suggest is using device_type and GetDeviceType rather than GetTargetDeviceType given the entity on which the property is placed is Target
|
It started the way you described, but the Vulkan target defines a property "device_type", which is unrelated to the TVM's device type. I'd actually prefer to avoid the extra "target" word, but I'm not sure how do deal with the Vulkan name conflict. "Device type" is actually the term used by Vulkan docs, but maybe we can rename it in TVM... |
Mousius
left a comment
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.
It started the way you described, but the Vulkan target defines a property "device_type", which is unrelated to the TVM's device type. I'd actually prefer to avoid the extra "target" word, but I'm not sure how do deal with the Vulkan name conflict. "Device type" is actually the term used by Vulkan docs, but maybe we can rename it in TVM...
Ahhh, makes sense to disambiguate it then 😸
areusch
left a comment
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.
thanks @kparzysz-quic and sorry i missed your original thread.
| TVM_REGISTER_GLOBAL("target.TargetCurrent").set_body_typed(Target::Current); | ||
| TVM_REGISTER_GLOBAL("target.TargetExport").set_body_typed(TargetInternal::Export); | ||
| TVM_REGISTER_GLOBAL("target.WithHost").set_body_typed(TargetInternal::WithHost); | ||
| TVM_REGISTER_GLOBAL("target.TargetGetDeviceType").set_body_typed([](const Target& target) { |
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.
do we need this or can we just use the node attr accessor?
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.
This function will check the attribute first, and if it's not set, it will return the default. It also shortens the invocation of GetAttr. Let me know what you'd prefer.
| void VisitAttrs(AttrVisitor* v) { | ||
| v->Visit("name", &name); | ||
| v->Visit("device_type", &device_type); | ||
| v->Visit("default_device_type", &default_device_type); |
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.
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.
sounds like a good idea that would make generating coherent release notes a lot easier (at least to highlight big changes). line items like this should be enough:
* #<pr number>: <description>
* #12509: this does X changes API A from Y to Z
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 think it's a good idea to create the PRERELEASE.md, the one question I have is why under tests? It doesn't seem related to testing 🤔
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.
that's where we have other release scripts (for now: https://github.com/apache/tvm/tree/main/tests/scripts/release and https://discuss.tvm.apache.org/t/establishing-a-home-for-tvm-dev-tools/13212), but we could also just put it at the top level
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.
@Mousius yeah it's more like just keeping everything together right now. when i get a moment i'll do the tvm dev tools refactor and move it somewhere more sensible :)
| .add_attr_option<Target>("host") \ | ||
| .add_attr_option<Integer>("from_device") | ||
| .add_attr_option<Integer>("from_device") \ | ||
| .add_attr_option<Integer>("target_device_type") |
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.
wondering if we should be producing this from e.g. processing -mcpu rather than allowing it to be explicitly set by the user?
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.
TargetKind doesn't have "mcpu", so it would be limited to specific kinds.
|
for context for the Community Meeting tomorrow: There are a few different options at least for how we could resolve this:
|
|
We discussed this in the TVM Community Meeting this morning. Here are notes:
|
|
Hi @areusch ... So what should we do with this PR? I don't think there was any opposition to this, but we didn't really reach the final decision in the community meeting either... |
Mousius
left a comment
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.
Hi @areusch ... So what should we do with this PR? I don't think there was any opposition to this, but we didn't really reach the final decision in the community meeting either...
My suggestion is that in lieu of a better solution, we land this and move forwards - we'll likely have to do a fair amount of breaking changes if we want to clean up the Target conundrum in future anyway.
areusch
left a comment
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.
on second read I am good with this PR. sorry to hold it up.
| void VisitAttrs(AttrVisitor* v) { | ||
| v->Visit("name", &name); | ||
| v->Visit("device_type", &device_type); | ||
| v->Visit("default_device_type", &default_device_type); |
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.
@Mousius yeah it's more like just keeping everything together right now. when i get a moment i'll do the tvm dev tools refactor and move it somewhere more sensible :)
|
@tvm-bot rerun |
|
can you sync this one though and get it through CI again? usually we break main by submitting a test that passed CI weeks ago |
…type Implement Target::GetTargetDeviceType (C++) or get_target_device_type (python) to get the device type (kDL...) for a given target. The attribute "target_device_type" can be used to override the default device type associated with the target kind.
…type (apache#12509) Implement Target::GetTargetDeviceType (C++) or get_target_device_type (python) to get the device type (kDL...) for a given target. The attribute "target_device_type" can be used to override the default device type associated with the target kind.
Implement
Target::GetTargetDeviceType(C++) orget_target_device_type(python) to get the device type (kDL...) for a given target.The attribute "target_device_type" can be used to override the default device type associated with the target kind.