Skip to content

Commit

Permalink
fix: Windows build warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
lokitoth committed Feb 16, 2024
1 parent 1675c6b commit cfccde1
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 46 deletions.
5 changes: 3 additions & 2 deletions vowpalwabbit/core/include/vw/core/action_score.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include "vw/core/v_array.h"
#include "vw/core/vw_fwd.h"

#include <cstdint>
#include <iterator>
#include <string>

Expand Down Expand Up @@ -46,7 +47,7 @@ class action_scores_score_iterator
public:
using iterator_category = std::random_access_iterator_tag;
using value_type = float;
using difference_type = long;
using difference_type = intptr_t;
using pointer = float*;
using reference = float;

Expand Down Expand Up @@ -104,4 +105,4 @@ inline VW::action_scores_score_iterator begin_scores(VW::action_scores& a_s) { r

VW_DEPRECATED("ACTION_SCORE::end_scores renamed to VW::end_scores. ACTION_SCORE::end_scores will be removed in VW 10.")
inline VW::action_scores_score_iterator end_scores(VW::action_scores& a_s) { return VW::end_scores(a_s); }
} // namespace ACTION_SCORE
} // namespace ACTION_SCORE
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,7 @@ cb_explore_adf_large_action_space<T, S>::cb_explore_adf_large_action_space(uint6
, _impl_type(impl_type)
, spanner_state(c, d)
, shrink_fact_config(apply_shrink_factor)
, _non_degenerate_singular_values(0)
, impl(all, d, _seed, total_size, thread_pool_size, block_size, action_cache_slack, use_explicit_simd)
{
}
Expand Down Expand Up @@ -294,7 +295,7 @@ std::shared_ptr<VW::LEARNER::learner> make_las_with_impl(VW::setup_base_i& stack
bool apply_shrink_factor, size_t thread_pool_size, size_t block_size, size_t action_cache_slack,
bool use_explicit_simd)
{
float seed = (all.get_random_state()->get_random() + 1) * 10.f;
uint64_t seed = (all.get_random_state()->get_random() + 1) * (uint64_t)10;

auto data = VW::make_unique<cb_explore_adf_large_action_space<T, S>>(d, c, apply_shrink_factor, &all, seed,
1 << all.initial_weights_config.num_bits, thread_pool_size, block_size, action_cache_slack, use_explicit_simd,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,6 @@ class cb_explore_adf_large_action_space

~cb_explore_adf_large_action_space() = default;

void save_load(io_buf& io, bool read, bool text);
void predict(VW::LEARNER::learner& base, multi_ex& examples);
void learn(VW::LEARNER::learner& base, multi_ex& examples);

Expand Down
2 changes: 1 addition & 1 deletion vowpalwabbit/core/src/reductions/topk.cc
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ void print_update_topk(VW::workspace& all, VW::shared_data& sd, const topk& /* d

if (should_print_driver_update)
{
size_t num_features = std::accumulate(ec_seq.begin(), ec_seq.end(), 0,
size_t num_features = std::accumulate(ec_seq.begin(), ec_seq.end(), (size_t)0,
[](size_t features_so_far, VW::example* ex) { return features_so_far + ex->get_num_features(); });

std::ostringstream label_ss;
Expand Down
78 changes: 39 additions & 39 deletions vowpalwabbit/core/tests/eigen_memory_tree_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -218,17 +218,17 @@ TEST(EigenMemoryTree, Inner)

EXPECT_EQ(emt_inner(v1, v2), 0);

v1.push_back(std::make_pair(1, 2));
v2.push_back(std::make_pair(2, 2));
v1.push_back(std::make_pair(1, 2.));
v2.push_back(std::make_pair(2, 2.));

EXPECT_EQ(emt_inner(v1, v2), 0);

v1.push_back(std::make_pair(2, 3));
v1.push_back(std::make_pair(2, 3.));

EXPECT_EQ(emt_inner(v1, v2), 6);

v1.push_back(std::make_pair(3, 2));
v2.push_back(std::make_pair(3, 5));
v1.push_back(std::make_pair(3, 2.));
v2.push_back(std::make_pair(3, 5.));

EXPECT_EQ(emt_inner(v1, v2), 16);
}
Expand All @@ -241,20 +241,20 @@ TEST(EigenMemoryTree, ScaleAdd)

EXPECT_EQ(emt_scale_add(1, v1, 1, v2), v3);

v1.push_back(std::make_pair(1, 2));
v3.push_back(std::make_pair(1, 2));
v1.push_back(std::make_pair(1, 2.));
v3.push_back(std::make_pair(1, 2.));

EXPECT_EQ(emt_scale_add(1, v1, 1, v2), v3);

v3.clear();
v3.push_back(std::make_pair(1, -1));
v3.push_back(std::make_pair(1, -1.));

EXPECT_EQ(emt_scale_add(-.5, v1, 1, v2), v3);

v1.clear();
v2.clear();
v3.clear();
v1.push_back(std::make_pair(1, 2));
v1.push_back(std::make_pair(1, 2.));
v2.push_back(std::make_pair(1, 2.5));
v3.push_back(std::make_pair(1, -.5));

Expand All @@ -263,34 +263,34 @@ TEST(EigenMemoryTree, ScaleAdd)
v1.clear();
v2.clear();
v3.clear();
v1.push_back(std::make_pair(1, 2));
v1.push_back(std::make_pair(1, 2.));
v2.push_back(std::make_pair(1, 2.5));
v2.push_back(std::make_pair(5, 1));
v2.push_back(std::make_pair(5, 1.));
v3.push_back(std::make_pair(1, -4.5));
v3.push_back(std::make_pair(5, -1));
v3.push_back(std::make_pair(5, -1.));

EXPECT_EQ(emt_scale_add(-1, v1, -1, v2), v3);

v1.clear();
v2.clear();
v3.clear();
v1.push_back(std::make_pair(1, 2));
v1.push_back(std::make_pair(5, 1));
v1.push_back(std::make_pair(1, 2.));
v1.push_back(std::make_pair(5, 1.));
v2.push_back(std::make_pair(1, 2.5));
v3.push_back(std::make_pair(1, -4.5));
v3.push_back(std::make_pair(5, -1));
v3.push_back(std::make_pair(5, -1.));

EXPECT_EQ(emt_scale_add(-1, v1, -1, v2), v3);

v1.clear();
v2.clear();
v3.clear();
v1.push_back(std::make_pair(1, 2));
v1.push_back(std::make_pair(5, 1));
v1.push_back(std::make_pair(1, 2.));
v1.push_back(std::make_pair(5, 1.));
v2.push_back(std::make_pair(1, 2.5));
v2.push_back(std::make_pair(5, -1));
v2.push_back(std::make_pair(5, -1.));
v3.push_back(std::make_pair(1, -4.5));
v3.push_back(std::make_pair(5, 0));
v3.push_back(std::make_pair(5, 0.));

EXPECT_EQ(emt_scale_add(-1, v1, -1, v2), v3);
}
Expand All @@ -303,8 +303,8 @@ TEST(EigenMemoryTree, Normalize)
emt_normalize(v1);
EXPECT_EQ(v1, v2);

v1.push_back(std::make_pair(1, -3));
v1.push_back(std::make_pair(5, 4));
v1.push_back(std::make_pair(1, -3.));
v1.push_back(std::make_pair(5, 4.));

v2.push_back(std::make_pair(1, -.6));
v2.push_back(std::make_pair(5, .8));
Expand All @@ -317,17 +317,17 @@ TEST(EigenMemoryTree, Median)
{
std::vector<float> v1;

v1.push_back(3);
v1.push_back(1);
v1.push_back(2);
v1.push_back(3.);
v1.push_back(1.);
v1.push_back(2.);

EXPECT_EQ(emt_median(v1), 2);

v1.clear();
v1.push_back(8);
v1.push_back(2);
v1.push_back(6);
v1.push_back(4);
v1.push_back(8.);
v1.push_back(2.);
v1.push_back(6.);
v1.push_back(4.);

EXPECT_EQ(emt_median(v1), 5);
}
Expand All @@ -340,14 +340,14 @@ TEST(EigenMemoryTree, RouterEigen)
emt_feats v2;
emt_feats v3;

v1.push_back(std::make_pair(1, 2));
v1.push_back(std::make_pair(3, 3));
v1.push_back(std::make_pair(5, 2));
v1.push_back(std::make_pair(1, 2.));
v1.push_back(std::make_pair(3, 3.));
v1.push_back(std::make_pair(5, 2.));

v2.push_back(std::make_pair(2, 5));
v2.push_back(std::make_pair(2, 5.));

v3.push_back(std::make_pair(1, 4));
v3.push_back(std::make_pair(2, 10));
v3.push_back(std::make_pair(1, 4.));
v3.push_back(std::make_pair(2, 10.));

std::vector<emt_feats> f;

Expand Down Expand Up @@ -384,11 +384,11 @@ TEST(EigenMemoryTree, ScorerInitial)
emt_normalize(v1);
EXPECT_EQ(v1, v2);

v1.push_back(std::make_pair(1, -2));
v1.push_back(std::make_pair(5, 3));
v1.push_back(std::make_pair(1, -2.));
v1.push_back(std::make_pair(5, 3.));

v2.push_back(std::make_pair(1, 1));
v2.push_back(std::make_pair(5, -1));
v2.push_back(std::make_pair(1, 1.));
v2.push_back(std::make_pair(5, -1.));

EXPECT_EQ(emt_initial(emt_initial_type::NONE, v1, v2), 0);
EXPECT_EQ(emt_initial(emt_initial_type::EUCLIDEAN, v1, v2), 5);
Expand Down Expand Up @@ -447,4 +447,4 @@ TEST(EigenMemoryTree, SaveLoad)
EXPECT_EQ(ex->pred.multiclass, i);
vw_load->finish_example(*ex);
}
}
}
4 changes: 2 additions & 2 deletions vowpalwabbit/explore/include/vw/explore/explore_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ int enforce_minimum_probability(float uniform_epsilon, bool consider_zero_valued

if (uniform_epsilon < 0.f || uniform_epsilon > 1.f) { return E_EXPLORATION_BAD_EPSILON; }

const auto num_actions = std::distance(pmf_first, pmf_last);
const size_t num_actions = std::distance(pmf_first, pmf_last);

size_t support_size = num_actions;
if (!consider_zero_valued_elements) { support_size -= std::count(pmf_first, pmf_last, 0.f); }
Expand Down Expand Up @@ -439,4 +439,4 @@ int sample_pdf(uint64_t* p_seed, It pdf_first, It pdf_last, float& chosen_value,
return details::sample_pdf(p_seed, pdf_first, pdf_last, chosen_value, pdf_value, pdf_category());
}
} // namespace explore
} // namespace VW
} // namespace VW

0 comments on commit cfccde1

Please sign in to comment.