-
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
[Target] Allow spaces in target attributes #8587
Conversation
@zxybazh Long-term, I'd like to switch to using JSON exclusively for |
Thanks for the contribution! Json-style target string parsing is supported as the canonical way for target creation and json export is supported using the Meanwhile, IIRC we are using the current cc @junrushao1994 . |
Definitely agreed, long-term it's better to go through a standard format. I played around a bit with converting the tvm
Yeah, the compatibility was what I was most concerned about. I wanted to update the |
Yes, it's more than a little work to make the Map 100% compatible to json. A c++ Json parser is ok to me but not necessary if there is nothing the current parser cannot do -- just to save time and as least the python parser is guaranteed to be correct right : )
I think the |
@@ -76,6 +76,14 @@ def test_target_string_parse(): | |||
assert tvm.target.arm_cpu().device_name == "arm_cpu" | |||
|
|||
|
|||
def test_target_string_with_spaces(): | |||
target = tvm.target.Target( | |||
"vulkan -device_name=Name\ of\ GPU\ with\ spaces -device_type=discrete" |
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.
In tvmc we faced this challenge of having substrings within target(s) (see relevant tests), one example is llvm
arguments. The decision there was to go with nested quotes, similar to Python. Have you explored this possibility in here?
That would make it look like:
"vulkan -device_name='Name of GPU with spaces' -device_type=discrete"
I feel that is looks a bit more natural to type in nested quotes rather than preceding everything with a backslash. Also, I think it would be aspirational to offer a similar experience (where possible), when using API and command line.
What do you think?
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'd be down for either, and agree that the nested quotes are an easier way to read it. Consistency with how tvmc handles spaces is also something that I want to maintain, so I'll update this PR to use the same convention.
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.
And updated.
Some target parameters, such as the device_name on vulkan, have spaces in them. This prevented round-trips between string and Target objects, which can occur in some cases.
Instead of -attr=value\ with\ spaces, will instead be written as -attr='value with spaces'.
716e506
to
37b79ae
Compare
@Lunderberg
|
Thanks @Lunderberg, please take a look at the issue of #8602 above. |
Thank you. I can reproduce the issue, and will have a PR shortly to resolve it. I had tested the new behavior during development, but it looks like the final version was broken on intel CPUs as well. |
* [Target] Allow for spaces in target attributes. Some target parameters, such as the device_name on vulkan, have spaces in them. This prevented round-trips between string and Target objects, which can occur in some cases. * [Vulkan] Fixed "device_name" property querying. * [Target] Switched from escaped spaces to quoted spaces. Instead of -attr=value\ with\ spaces, will instead be written as -attr='value with spaces'. Co-authored-by: Eric Lunderberg <[email protected]>
* [Target] Allow for spaces in target attributes. Some target parameters, such as the device_name on vulkan, have spaces in them. This prevented round-trips between string and Target objects, which can occur in some cases. * [Vulkan] Fixed "device_name" property querying. * [Target] Switched from escaped spaces to quoted spaces. Instead of -attr=value\ with\ spaces, will instead be written as -attr='value with spaces'. Co-authored-by: Eric Lunderberg <[email protected]>
* [Target] Allow for spaces in target attributes. Some target parameters, such as the device_name on vulkan, have spaces in them. This prevented round-trips between string and Target objects, which can occur in some cases. * [Vulkan] Fixed "device_name" property querying. * [Target] Switched from escaped spaces to quoted spaces. Instead of -attr=value\ with\ spaces, will instead be written as -attr='value with spaces'. Co-authored-by: Eric Lunderberg <[email protected]>
Some target parameters, such as the device_name on vulkan, have spaces in them. This prevented round-trips between string and Target objects, which can occur in some cases (e.g. AOT codegen).
vulkan -from_device=0
, was missing device name from device query.