TVM
- TVM的CodeGen仅仅是生成对应的funcion。内存分配则由DeviceAPI负责。以CodeGenCUDA为例,CUDADeviceAPI内部封装了如下功能。
- 各种DeviceAttr的查询,实现则是直接调用了cudaDeviceGetAttribute()函数。
- GPU存储的分配和释放。
- 数据拷贝。分为GPU到GPU(是否同一device),CPU到GPU,GPU到CPU等几种类型。TVMContext给出设备信息。
1
2
3
4
5
6
7typedef struct {
/*! \brief The device type used in the device. */
DLDeviceType device_type;
/*! \brief The device index */
int device_id;
} DLContext;
ypedef DLContext TVMContext;