Pass DMatrix into metric for caching. (#8790)

This commit is contained in:
Jiaming Yuan
2023-02-13 22:15:05 +08:00
committed by GitHub
parent 31d3ec07af
commit 81b2ee1153
17 changed files with 95 additions and 70 deletions

View File

@@ -32,6 +32,8 @@ class DMatrixCache {
CacheT& Value() { return *value; }
};
static constexpr std::size_t DefaultSize() { return 32; }
protected:
std::unordered_map<DMatrix const*, Item> container_;
std::queue<DMatrix const*> queue_;

View File

@@ -54,12 +54,15 @@ class Metric : public Configurable {
out["name"] = String(this->Name());
}
/*!
* \brief evaluate a specific metric
* \param preds prediction
* \param info information, including label etc.
/**
* \brief Evaluate a metric with DMatrix as input.
*
* \param preds Prediction
* \param p_fmat DMatrix that contains related information like labels.
*/
virtual double Eval(const HostDeviceVector<bst_float>& preds, const MetaInfo& info) = 0;
virtual double Evaluate(HostDeviceVector<bst_float> const& preds,
std::shared_ptr<DMatrix> p_fmat) = 0;
/*! \return name of metric */
virtual const char* Name() const = 0;
/*! \brief virtual destructor */