Skip to content

Commit

Permalink
fix: fix get_features function (#4328)
Browse files Browse the repository at this point in the history
  • Loading branch information
jackgerrits authored Dec 14, 2022
1 parent 6cbebd6 commit 8bab56d
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions vowpalwabbit/core/src/example.cc
Original file line number Diff line number Diff line change
Expand Up @@ -170,11 +170,13 @@ feature* get_features(VW::workspace& all, example* ec, size_t& feature_map_len)
fs.mask = all.weights.mask() >> all.weights.stride_shift();
GD::foreach_feature<features_and_source, uint64_t, vec_store>(all, *ec, fs);

auto* features_array = new feature[fs.feature_map.size()];
std::memcpy(features_array, fs.feature_map.data(), fs.feature_map.size() * sizeof(feature));
feature_map_len = fs.feature_map.size();
return fs.feature_map.begin();
return features_array;
}

void return_features(feature* f) { free_it(f); }
void return_features(feature* f) { delete[] f; }
} // namespace VW

class full_features_and_source
Expand Down

0 comments on commit 8bab56d

Please sign in to comment.