Lunderberg commented on PR #16836:
URL: https://github.com/apache/tvm/pull/16836#issuecomment-2077686494
Looks like the re-implemented version has trouble with RPC devices and with
microtvm runtime. In order to compile the metadata function, I needed to add
the ability to return a `tir::StringImm` from a `PrimFunc`, where previously
this was only used to provide `const char*` arguments. There's a difference in
how `TVMArgValue` and `TVMRetValue` represent `kTVMStr`: in `TVMArgValue` it
stores a non-owning `const char*` in `TVMValue::v_str`, while in `TVMRetValue`
it stores an owning `std::string*` in `TVMValue::v_handle`.
There is no straightforward way to perform the equivalent of `rv.v_handle =
new std::string("string literal");` in generated LLVM code, and it would be
very implementation-dependent. Instead, I implemented `T.ret("string
literal")` by delegating to a PackedFunc to allocate the `TVMRetValue`, then
returning that value. This works very nicely for most use cases, but fails for
the microtvm runtime (because the backend helper function is not present) and
for RPC devices (because the string's buffer doesn't seem to be returned).
I think the ability to query a module's contents is too useful to set aside
entirely, but this PR is going on the back burner for me until I can find a
better way to implement it.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]