enum size is not guaranteed to be sizeof(int)
Closed this issue · 0 comments
sunwayforever commented
DLDevice definition in dlpack:
typedef struct {
/*! \brief The device type used in the device. */
DLDeviceType device_type;
/*! \brief The device index */
int device_id;
} DLDevice;
t_tvm_device_ definition in codegen_cpu.cc@tvm
t_tvm_device_ = llvm::StructType::create({t_int_, t_int_});
if dlpack was built with gcc -fshort-enums
, then sizeof(DLDeviceType) will be 1 instead of 4, which will cause some errors when accessing device_type from llvm. one case I found is arg_binder.cc@tvm
Bind_(device_type, TVMArrayGet(DataType::Int(32), handle, builtin::kArrDeviceType),
arg_name + ".device_type", true);
add one dummy device type with value 0xffffffff in DLDeviceType should fix this issue