MCPcopy Create free account
hub / github.com/apache/arrow / GetDLDataType

Function GetDLDataType

cpp/src/arrow/c/dlpack.cc:51–70  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

49 ***************/
50
51Result<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
72template <typename DT, typename Vec>
73struct ManagerCtx {

Callers

nothing calls this directly

Calls 7

is_signed_integerFunction · 0.50
is_unsigned_integerFunction · 0.50
is_floatingFunction · 0.50
TypeErrorFunction · 0.50
bit_widthMethod · 0.45
idMethod · 0.45
ToStringMethod · 0.45

Tested by

no test coverage detected