25 #ifndef TVM_RUNTIME_SERIALIZER_H_
26 #define TVM_RUNTIME_SERIALIZER_H_
29 #include <dmlc/serializer.h>
34 namespace serializer {
37 struct Handler<DLDataType> {
38 inline static void Write(Stream* strm,
const DLDataType& dtype) {
39 Handler<uint8_t>::Write(strm, dtype.code);
40 Handler<uint8_t>::Write(strm, dtype.bits);
41 Handler<uint16_t>::Write(strm, dtype.lanes);
43 inline static bool Read(Stream* strm, DLDataType* dtype) {
44 if (!Handler<uint8_t>::Read(strm, &(dtype->code)))
return false;
45 if (!Handler<uint8_t>::Read(strm, &(dtype->bits)))
return false;
46 if (!Handler<uint16_t>::Read(strm, &(dtype->lanes)))
return false;
52 struct Handler<DLDevice> {
53 inline static void Write(Stream* strm,
const DLDevice& dev) {
54 int32_t
device_type =
static_cast<int32_t
>(dev.device_type);
56 Handler<int32_t>::Write(strm, dev.device_id);
58 inline static bool Read(Stream* strm, DLDevice* dev) {
60 if (!Handler<int32_t>::Read(strm, &(
device_type)))
return false;
61 dev->device_type =
static_cast<DLDeviceType
>(
device_type);
62 if (!Handler<int32_t>::Read(strm, &(dev->device_id)))
return false;
Definition: executable.h:222
constexpr const char * device_type
The device type.
Definition: stmt.h:1422
A device-independent managed NDArray abstraction.
static void Write(Stream *strm, const DLDataType &dtype)
Definition: serializer.h:38
static bool Read(Stream *strm, DLDataType *dtype)
Definition: serializer.h:43
static bool Read(Stream *strm, DLDevice *dev)
Definition: serializer.h:58
static void Write(Stream *strm, const DLDevice &dev)
Definition: serializer.h:53