217{
218 if (products.size() > static_cast<size_t>(std::numeric_limits<int>::max()))
219 throw std::length_error("too many prediction products");
220 bool device_batch = true;
221 for (const auto* product: products) {
222 if (product == nullptr)
223 throw std::invalid_argument("null prediction product");
224 device_batch =
226 }
227 values.resize(products.size());
228 if (!device_batch) {
229 for (size_t i = 0; i < products.size(); ++i)
230 values[i] = products[i]->
value();
231 return;
232 }
233 std::vector<StoredProduct> operands;
234 operands.reserve(products.size());
235 for (const auto* product: products) {
236 const auto* terms = product->terms_.get();
237 if (!terms) {
238 operands.push_back({nullptr, nullptr, 0});
239 continue;
240 }
241 if (terms->left.size() >
242 static_cast<size_t>(std::numeric_limits<int>::max()))
243 throw std::length_error("prediction product is too long");
244 operands.push_back({terms->left.data(), terms->right.data(),
245 static_cast<int>(terms->left.size())});
246 }
249}
void evaluateStoredProducts(const StoredProduct *products, int count, ProductMode mode, double *values)