* \brief Convert a DLDataTypeCode to a string. * \param os The output stream. * \param type_code The DLDataTypeCode to convert. */
| 50 | * \param type_code The DLDataTypeCode to convert. |
| 51 | */ |
| 52 | inline const char* DLDataTypeCodeAsCStr(DLDataTypeCode type_code) { // NOLINT(*) |
| 53 | switch (static_cast<int>(type_code)) { |
| 54 | case kDLInt: { |
| 55 | return "int"; |
| 56 | } |
| 57 | case kDLUInt: { |
| 58 | return "uint"; |
| 59 | } |
| 60 | case kDLFloat: { |
| 61 | return "float"; |
| 62 | } |
| 63 | case kDLOpaqueHandle: { |
| 64 | return "handle"; |
| 65 | } |
| 66 | case kDLBfloat: { |
| 67 | return "bfloat"; |
| 68 | } |
| 69 | case kDLBool: { |
| 70 | return "bool"; |
| 71 | } |
| 72 | case kDLFloat8_e3m4: { |
| 73 | return "float8_e3m4"; |
| 74 | } |
| 75 | case kDLFloat8_e4m3: { |
| 76 | return "float8_e4m3"; |
| 77 | } |
| 78 | case kDLFloat8_e4m3b11fnuz: { |
| 79 | return "float8_e4m3b11fnuz"; |
| 80 | } |
| 81 | case kDLFloat8_e4m3fn: { |
| 82 | return "float8_e4m3fn"; |
| 83 | } |
| 84 | case kDLFloat8_e4m3fnuz: { |
| 85 | return "float8_e4m3fnuz"; |
| 86 | } |
| 87 | case kDLFloat8_e5m2: { |
| 88 | return "float8_e5m2"; |
| 89 | } |
| 90 | case kDLFloat8_e5m2fnuz: { |
| 91 | return "float8_e5m2fnuz"; |
| 92 | } |
| 93 | case kDLFloat8_e8m0fnu: { |
| 94 | return "float8_e8m0fnu"; |
| 95 | } |
| 96 | case kDLFloat6_e2m3fn: { |
| 97 | return "float6_e2m3fn"; |
| 98 | } |
| 99 | case kDLFloat6_e3m2fn: { |
| 100 | return "float6_e3m2fn"; |
| 101 | } |
| 102 | case kDLFloat4_e2m1fn: { |
| 103 | return "float4_e2m1fn"; |
| 104 | } |
| 105 | default: { |
| 106 | if (static_cast<int>(type_code) >= static_cast<int>(DLExtDataTypeCode::kDLExtCustomBegin)) { |
| 107 | return "custom"; |
| 108 | } else { |
| 109 | TVM_FFI_THROW(ValueError) << "DLDataType contains unknown type_code=" |
no outgoing calls
no test coverage detected