Why TVMValue does not support uint64?

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. :frowning:

# 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.

Is there any specific use case in your mind?

Hi junru,
As described above, there is a case we have to use tvm.const to represent a unsigned int value. It is ok if the value is small, but got overflow if it is large. In ctypes, values[i].v_int64 = arg implicitly converts the Integral to int64 if it is overflow. But in cython, it is different. I got an error OverflowError: Python int too large to convert to C long.

To simplify the runtime, we use int64 to store ints, it is similar to the Javascript restriction on numbers. Would love to learn more about your use-case