comaniac opened a new pull request #10430:
URL: https://github.com/apache/tvm/pull/10430
After #10326, we now require the argument type of PackFunc to have a
corresponding template of Type2Str. Otherwise we will get the following error
during compilation (note that my argument type is `DLDataType`).
```
include/tvm/runtime/packed_func.h:1400:22: note: candidate: template<class>
static std::__cxx11::string tvm::runtime::detail::type2str::Type2Str<T>::v()
[with <template-parameter-2-1> = <template-parameter-1-1>; T = DLDataType]
static std::string v() {
^
/include/tvm/runtime/packed_func.h:1400:22: note: template argument
deduction/substitution failed
```
This PR adds a Type2Str template for DLDataType to remove my blocker.
However, this doesn't solve the root problem. Ideally, we should not error out
only if the Type2Str template is missing but the argument type of a PackFunc is
actually supported. A straightforward solution to this issue is adding all
templates for the types supported by TVMArgValue (e.g., intX_t, uintX_t for X
in 8, 16, 32, 64; basically everything covered in
https://github.com/apache/tvm/blob/main/include/tvm/runtime/packed_func.h#L1225).
While it is tedious, I'm wondering if we could have a default template that
simply prints "unknown_type" for non-ObjectRef types. It might be possible to
leverage `std::enable_if_t<!std::is_base_of<ObjectRef, T>::value>`, but I'm not
sure how to achieve it in the case of Type2Str struct.
(nit) In addition, this PR also removes some compiler warnings reported by
Clang:
1. `size_t` is always larger or equal than zero, so no need to check `idx >=
0`.
2. The derived mutator and visitor don't implement all virtual functions.
cc @cyx-6 @junrushao1994
--
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]