@@ -382,14 +382,13 @@ pair<uint64_t, int32_t> ThreeLCacheCache::evict_predobj() {
382382
383383void ThreeLCacheCache::prediction (vector<int32_t > sampled_objects) {
384384 int32_t sample_nums = sampled_objects.size ();
385- int32_t indptr[sample_nums + 1 ];
386- indptr[0 ] = 0 ;
387- int32_t indices[sample_nums * n_feature];
388- double data[sample_nums * n_feature];
389- int32_t past_timestamps[sample_nums];
390- int32_t sizes[sample_nums];
391- uint64_t keys[sample_nums];
392- int32_t poses[sample_nums];
385+ std::vector<int32_t > indptr (sample_nums + 1 , 0 );
386+ std::vector<int32_t > indices (sample_nums * n_feature);
387+ std::vector<double > data (sample_nums * n_feature);
388+ std::vector<int32_t > past_timestamps (sample_nums);
389+ std::vector<int32_t > sizes (sample_nums);
390+ std::vector<uint64_t > keys (sample_nums);
391+ std::vector<int32_t > poses (sample_nums);
393392 unsigned int idx_feature = 0 ;
394393 int32_t pos;
395394 unsigned int idx_row = 0 ;
@@ -430,18 +429,19 @@ void ThreeLCacheCache::prediction(vector<int32_t> sampled_objects) {
430429 indptr[idx_row + 1 ] = idx_feature;
431430 }
432431 int64_t len = 0 ;
433- double scores[ sample_nums] ;
432+ std::vector< double > scores ( sample_nums) ;
434433 std::string inference_params_str;
435434 for (const auto ¶m : inference_params) {
436435 inference_params_str += param.first + " =" + param.second + " " ;
437436 }
438437 inference_params_str.pop_back (); // Remove trailing space
439438 const char *inference_params_cstr = inference_params_str.c_str ();
440439 LGBM_BoosterPredictForCSR (
441- booster, static_cast <void *>(indptr), C_API_DTYPE_INT32, indices,
442- static_cast <void *>(data), C_API_DTYPE_FLOAT64, idx_row + 1 , idx_feature,
440+ booster, static_cast <void *>(indptr.data ()), C_API_DTYPE_INT32,
441+ indices.data (), static_cast <void *>(data.data ()), C_API_DTYPE_FLOAT64,
442+ idx_row + 1 , idx_feature,
443443 n_feature, // remove future t
444- C_API_PREDICT_NORMAL, 0 , 0 , inference_params_cstr, &len, scores);
444+ C_API_PREDICT_NORMAL, 0 , 0 , inference_params_cstr, &len, scores. data () );
445445 float _distance;
446446 if (objective == byte_miss_ratio) {
447447 for (int i = 0 ; i < sample_nums; ++i) {
0 commit comments