Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
[Object][FFI] Introduce runtime::String::CanConvertFrom #5718
[Object][FFI] Introduce runtime::String::CanConvertFrom #5718
Changes from all commits
8a925e5
77bc23e
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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.
@junrushao1994 : Sorry to bug you on this. I was wondering whether, the first if condition is always true, when the val is String objref type. Please check once. 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.
Thank you for your question! Hmmmm but I am not sure I understand if correctly. Just to confirm, "The first if condition", are you referring to "val.type_code() == kTVMStr" in
CanConvertFrom
? Thank you!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.
The Python frontend is still able to pass
runtime::String
back to C++ via packed function. One case I found in our testcases is: https://github.com/apache/incubator-tvm/pull/5687/files#diff-5243f3909dfa484d85d3d8471f259169R422-R424There 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.
Sorry for confusion.
The first if condition --> if (val.IsObjectRef()) might be true always for String objref, so maybe the condition inside String::CanConvertFrom(val) will not reach.
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 that may be because of implicit conversion of String(Overloaded) to std::string!
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 this is okay because
IsObjectRef
doesn't check the container type forString
.https://github.com/apache/incubator-tvm/blob/4347b41a5e64a2a453297b371232d6e101051b3c/include/tvm/runtime/packed_func.h#L1301
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.
Yah I got what you mean, and thank you for the clarification @ANSHUMAN87! Totally agree with your points, but we want to unify the way we check "FFI -> string" conversion, so that future users won't end up messing them up. This is the reason why I made this change: After this PR, the only places that use raw kTVMStr are RPC and C-API.
Thank you again for the comments @zhiics @ANSHUMAN87!