mamodev opened a new issue, #329:
URL: https://github.com/apache/tvm-ffi/issues/329
# Summary
When attempting to register a constructor that accepts tvm::ffi::Any using
the reflection system (refl::init), compilation fails. The error indicates that
the TypeTraits template for tvm::ffi::Any (specifically TypeTraitsNoCR) is
missing the TypeStr() member function, which is required to generate the
function signature string for Python bindings.
# Steps to Reproduce
the following minimal C++ snippet reproduces the error when compiled against
tvm_ffi:
```cpp
#include <tvm/ffi/reflection/registry.h>
#include <tvm/ffi/any.h>
using namespace tvm::ffi;
struct MyNode : Object {
// Constructor accepting Any
MyNode(Any a) {}
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("mod.MyNode", MyNode, Object);
};
TVM_FFI_STATIC_INIT_BLOCK() {
namespace refl = tvm::ffi::reflection;
refl::ObjectDef<MyNode>()
.def(refl::init<Any>()); // This line triggers the
compilation error
}
```
### Example of error
```
/include/tvm/ffi/any.h: In instantiation of ‘static std::string
tvm::ffi::details::Type2Str<Type>::v() [with Type = tvm::ffi::Any&&;
std::string = std::__cxx11::basic_string<char>]’:
...
/include/tvm/ffi/any.h:506:64: error: ‘TypeStr’ is not a member of
‘tvm::ffi::TypeTraitsNoCR<tvm::ffi::Any&&>’ {aka
‘tvm::ffi::TypeTraits<tvm::ffi::Any, void>’}
506 | static std::string v() { return TypeTraitsNoCR<Type>::TypeStr(); }
```
# Context
**Compiler**: G++ (C++17 standard)
**Package**: standalone tvm_ffi (via PyPI)
**Use Case**: Trying to expose a constructor that accepts either a primitive
(int/float) or an ObjectRef.
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]