/** * Copyright 2021-2023 XGBoost contributors */ #include // for any, any_cast #include "device_adapter.cuh" #include "proxy_dmatrix.h" namespace xgboost::data::cuda_impl { template decltype(auto) Dispatch(DMatrixProxy const* proxy, Fn fn) { if (proxy->Adapter().type() == typeid(std::shared_ptr)) { if constexpr (get_value) { auto value = std::any_cast>(proxy->Adapter())->Value(); return fn(value); } else { auto value = std::any_cast>(proxy->Adapter()); return fn(value); } } else if (proxy->Adapter().type() == typeid(std::shared_ptr)) { if constexpr (get_value) { auto value = std::any_cast>(proxy->Adapter())->Value(); return fn(value); } else { auto value = std::any_cast>(proxy->Adapter()); return fn(value); } } else { LOG(FATAL) << "Unknown type: " << proxy->Adapter().type().name(); if constexpr (get_value) { auto value = std::any_cast>(proxy->Adapter())->Value(); return fn(value); } else { auto value = std::any_cast>(proxy->Adapter()); return fn(value); } } } } // namespace xgboost::data::cuda_impl