| 49 | ***************/ |
| 50 | |
| 51 | Result<DLDataType> GetDLDataType(const DataType& type) { |
| 52 | auto dtype = DLDataType{}; |
| 53 | dtype.lanes = 1; |
| 54 | dtype.bits = type.bit_width(); |
| 55 | if (is_signed_integer(type.id())) { |
| 56 | dtype.code = DLDataTypeCode::kDLInt; |
| 57 | } else if (is_unsigned_integer(type.id())) { |
| 58 | dtype.code = DLDataTypeCode::kDLUInt; |
| 59 | } else if (is_floating(type.id())) { |
| 60 | dtype.code = DLDataTypeCode::kDLFloat; |
| 61 | } else if (type.id() == Type::BOOL) { |
| 62 | // DLPack supports byte-packed boolean values |
| 63 | return Status::TypeError("Bit-packed boolean data type not supported by DLPack."); |
| 64 | } else { |
| 65 | return Status::TypeError( |
| 66 | "DataType is not compatible with DLPack spec: ", type.ToString(), |
| 67 | ", try converting to a Tensor for multi dimensional data support"); |
| 68 | } |
| 69 | return {dtype}; |
| 70 | } |
| 71 | |
| 72 | template <typename DT, typename Vec> |
| 73 | struct ManagerCtx { |
nothing calls this directly
no test coverage detected