Skip to content

Commit

Permalink
comments
Browse files Browse the repository at this point in the history
  • Loading branch information
bassmang committed Oct 16, 2023
1 parent 58cb44d commit 0205ef3
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
5 changes: 3 additions & 2 deletions vowpalwabbit/core/include/vw/core/array_parameters_dense.h
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,9 @@ class dense_parameters
inline const VW::weight& operator[](size_t i) const { return _begin.get()[i & _weight_mask]; }
inline VW::weight& operator[](size_t i) { return _begin.get()[i & _weight_mask]; }

inline const VW::weight& get(size_t i) const { return _begin.get()[i & _weight_mask]; }
inline VW::weight& get(size_t i) { return _begin.get()[i & _weight_mask]; }
// get() is only needed for sparse_weights, same as operator[] for dense_weights
inline const VW::weight& get(size_t i) const { return operator[](i); }
inline VW::weight& get(size_t i) { return operator[](i); }

VW_ATTR(nodiscard) static dense_parameters shallow_copy(const dense_parameters& input);
VW_ATTR(nodiscard) static dense_parameters deep_copy(const dense_parameters& input);
Expand Down
2 changes: 2 additions & 0 deletions vowpalwabbit/core/include/vw/core/array_parameters_sparse.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,11 @@ class sparse_parameters
const_iterator cbegin() const { return const_iterator(_map.begin()); }
const_iterator cend() const { return const_iterator(_map.end()); }

// operator[] will find weight in _map and return and insert a default value if not found. Does alter _map.
inline VW::weight& operator[](size_t i) { return *(get_or_default_and_get(i)); }
inline const VW::weight& operator[](size_t i) const { return *(get_or_default_and_get(i)); }

// get() will find weight in _map and return a default value if not found. Does not alter _map.
inline VW::weight& get(size_t i) { return *(get_impl(i)); };
inline const VW::weight& get(size_t i) const { return *(get_impl(i)); };

Expand Down
3 changes: 2 additions & 1 deletion vowpalwabbit/core/src/reductions/cb/cb_explore_adf_rnd.cc
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,8 @@ class lazy_gaussian
{
public:
inline float operator[](uint64_t index) const { return VW::details::merand48_boxmuller(index); }
inline float get(uint64_t index) const { return VW::details::merand48_boxmuller(index); }
// get() is only needed for sparse_weights, same as operator[] for lazy_gaussian
inline float get(uint64_t index) const { return operator[](index); }
};

inline void vec_add_with_norm(std::pair<float, float>& p, float fx, float fw)
Expand Down

0 comments on commit 0205ef3

Please sign in to comment.