Hi everyone,
I just wander why union TVMValue does not support uint64
? I think uint64
is very useful in some cases like create a large const value tvm.const(value, 'uint64')
. It seems TVMValue does not have uint64
at all. But, accually, DLDataTypeCode
has kDLUint
. May i know why it is designed?
# _ffi/_ctypes/types.py
class TVMValue(ctypes.Union):
"""TVMValue in C API"""
_fields_ = [("v_int64", ctypes.c_int64),
("v_float64", ctypes.c_double),
("v_handle", ctypes.c_void_p),
("v_str", ctypes.c_char_p)]
# _ffi/_cython/base.pxi
ctypedef struct TVMValue:
int64_t v_int64
double v_float64
void* v_handle
const char* v_str
DLDataType v_type
DLContext v_ctx
// dlpack/include/dlpack/dlpack.h
/*!
* \brief The type code options DLDataType.
*/
typedef enum {
kDLInt = 0U,
kDLUInt = 1U,
kDLFloat = 2U,
} DLDataTypeCode;
Also anthor doubt about _const
, tvm.const
has the type option, but it appears useless.
# src/api/api_lang.cc
TVM_REGISTER_API("_const")
.set_body([](TVMArgs args, TVMRetValue* ret) {
if (args[0].type_code() == kDLInt) {
*ret = make_const(args[1], args[0].operator int64_t());
} else if (args[0].type_code() == kDLFloat) {
*ret = make_const(args[1], args[0].operator double());
} else {
LOG(FATAL) << "only accept int or float";
}
});
Many thanks.