MCPcopy Create free account
hub / github.com/dmlc/xgboost / AssignType

Method AssignType

src/data/array_interface.h:469–504  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

467 explicit ArrayInterface(StringView str) : ArrayInterface{Json::Load(str)} {}
468
469 void AssignType(StringView typestr) {
470 using T = ArrayInterfaceHandler::Type;
471 if (typestr.size() == 4 && typestr[1] == 'f' && typestr[2] == '1' && typestr[3] == '6') {
472 CHECK(sizeof(long double) == 16) << error::NoF128();
473 type = T::kF16;
474 } else if (typestr[1] == 'f' && typestr[2] == '2') {
475#if defined(XGBOOST_USE_CUDA)
476 type = T::kF2;
477#else
478 LOG(FATAL) << "Half type is not supported.";
479#endif // defined(XGBOOST_USE_CUDA)
480 } else if (typestr[1] == 'f' && typestr[2] == '4') {
481 type = T::kF4;
482 } else if (typestr[1] == 'f' && typestr[2] == '8') {
483 type = T::kF8;
484 } else if (typestr[1] == 'i' && typestr[2] == '1') {
485 type = T::kI1;
486 } else if (typestr[1] == 'i' && typestr[2] == '2') {
487 type = T::kI2;
488 } else if (typestr[1] == 'i' && typestr[2] == '4') {
489 type = T::kI4;
490 } else if (typestr[1] == 'i' && typestr[2] == '8') {
491 type = T::kI8;
492 } else if (typestr[1] == 'u' && typestr[2] == '1') {
493 type = T::kU1;
494 } else if (typestr[1] == 'u' && typestr[2] == '2') {
495 type = T::kU2;
496 } else if (typestr[1] == 'u' && typestr[2] == '4') {
497 type = T::kU4;
498 } else if (typestr[1] == 'u' && typestr[2] == '8') {
499 type = T::kU8;
500 } else {
501 LOG(FATAL) << ArrayInterfaceErrors::UnSupportedType(typestr);
502 return;
503 }
504 }
505
506 template <std::size_t i>
507 [[nodiscard]] XGBOOST_DEVICE std::size_t Shape() const {

Callers 1

InitializeMethod · 0.95

Calls 2

NoF128Function · 0.85
sizeMethod · 0.45

Tested by

no test coverage detected