Vowpal Wabbit
|
#include <float.h>
#include <cassert>
#include "gd.h"
#include "accumulate.h"
#include "reductions.h"
#include "vw.h"
#include "vw_allreduce.h"
Go to the source code of this file.
Classes | |
struct | sort_data |
struct | stagewise_poly |
Functions | |
uint64_t | stride_shift (const stagewise_poly &poly, uint64_t idx) |
uint64_t | stride_un_shift (const stagewise_poly &poly, uint64_t idx) |
uint64_t | do_ft_offset (const stagewise_poly &poly, uint64_t idx) |
uint64_t | un_ft_offset (const stagewise_poly &poly, uint64_t idx) |
uint64_t | wid_mask (const stagewise_poly &poly, uint64_t wid) |
uint64_t | wid_mask_un_shifted (const stagewise_poly &poly, uint64_t wid) |
uint64_t | constant_feat (const stagewise_poly &poly) |
uint64_t | constant_feat_masked (const stagewise_poly &poly) |
size_t | depthsbits_sizeof (const stagewise_poly &poly) |
void | depthsbits_create (stagewise_poly &poly) |
bool | parent_get (const stagewise_poly &poly, uint64_t wid) |
void | parent_toggle (stagewise_poly &poly, uint64_t wid) |
bool | cycle_get (const stagewise_poly &poly, uint64_t wid) |
void | cycle_toggle (stagewise_poly &poly, uint64_t wid) |
uint8_t | min_depths_get (const stagewise_poly &poly, uint64_t wid) |
void | min_depths_set (stagewise_poly &poly, uint64_t wid, uint8_t depth) |
void | sanity_check_state (stagewise_poly &poly) |
uint64_t | child_wid (const stagewise_poly &poly, uint64_t wi_atomic, uint64_t wi_general) |
void | sort_data_create (stagewise_poly &poly) |
void | sort_data_ensure_sz (stagewise_poly &poly, size_t len) |
int | sort_data_compar_heap (sort_data &a_v, sort_data &b_v) |
void | sort_data_update_support (stagewise_poly &poly) |
void | synthetic_reset (stagewise_poly &poly, example &ec) |
void | synthetic_decycle (stagewise_poly &poly) |
void | synthetic_create_rec (stagewise_poly &poly, float v, uint64_t findex) |
void | synthetic_create (stagewise_poly &poly, example &ec, bool training) |
void | predict (stagewise_poly &poly, single_learner &base, example &ec) |
void | learn (stagewise_poly &poly, single_learner &base, example &ec) |
void | reduce_min (uint8_t &v1, const uint8_t &v2) |
void | reduce_min_max (uint8_t &v1, const uint8_t &v2) |
void | end_pass (stagewise_poly &poly) |
void | finish_example (vw &all, stagewise_poly &poly, example &ec) |
void | save_load (stagewise_poly &poly, io_buf &model_file, bool read, bool text) |
base_learner * | stagewise_poly_setup (options_i &options, vw &all) |
Variables | |
static constexpr uint32_t | parent_bit = 1 |
static constexpr uint32_t | cycle_bit = 2 |
static constexpr uint32_t | tree_atomics = 134 |
static constexpr float | tolerance = 1e-9f |
static constexpr uint32_t | indicator_bit = 128 |
static constexpr uint32_t | default_depth = 127 |
|
inline |
Definition at line 205 of file stagewise_poly.cc.
References constant_feat_masked(), stride_shift(), stride_un_shift(), and wid_mask().
Referenced by synthetic_create_rec().
|
inline |
Definition at line 120 of file stagewise_poly.cc.
References stagewise_poly::all, constant, stride_shift(), and vw::wpp.
Referenced by constant_feat_masked().
|
inline |
Definition at line 122 of file stagewise_poly.cc.
References constant_feat(), and wid_mask().
Referenced by child_wid(), sort_data_update_support(), and synthetic_create().
|
inline |
Definition at line 150 of file stagewise_poly.cc.
References cycle_bit, stagewise_poly::depthsbits, stride_shift(), and wid_mask_un_shifted().
Referenced by sanity_check_state(), synthetic_create_rec(), and synthetic_decycle().
|
inline |
Definition at line 160 of file stagewise_poly.cc.
References cycle_bit, stagewise_poly::depthsbits, stride_shift(), and wid_mask_un_shifted().
Referenced by synthetic_create_rec(), and synthetic_decycle().
void depthsbits_create | ( | stagewise_poly & | poly | ) |
Definition at line 126 of file stagewise_poly.cc.
References stagewise_poly::all, default_depth, stagewise_poly::depthsbits, indicator_bit, and vw::length().
Referenced by stagewise_poly_setup().
|
inline |
Definition at line 124 of file stagewise_poly.cc.
References stagewise_poly::all, and vw::length().
Referenced by end_pass(), and save_load().
|
inline |
Definition at line 91 of file stagewise_poly.cc.
References example_predict::ft_offset, stagewise_poly::original_ec, and stagewise_poly::synth_ec.
Referenced by min_depths_get(), min_depths_set(), parent_get(), and parent_toggle().
void end_pass | ( | stagewise_poly & | poly | ) |
Definition at line 581 of file stagewise_poly.cc.
References accumulate_scalar(), stagewise_poly::all, vw::all_reduce, stagewise_poly::batch_sz, stagewise_poly::depthsbits, depthsbits_sizeof(), stagewise_poly::num_examples, stagewise_poly::num_examples_sync, stagewise_poly::numpasses, vw::numpasses, sanity_check_state(), stagewise_poly::sum_input_sparsity, stagewise_poly::sum_input_sparsity_sync, stagewise_poly::sum_sparsity, stagewise_poly::sum_sparsity_sync, and stagewise_poly::update_support.
void finish_example | ( | vw & | all, |
stagewise_poly & | poly, | ||
example & | ec | ||
) |
Definition at line 630 of file stagewise_poly.cc.
References VW::finish_example(), example::num_features, output_and_account_example(), and stagewise_poly::synth_ec.
Referenced by stagewise_poly_setup().
void learn | ( | stagewise_poly & | poly, |
single_learner & | base, | ||
example & | ec | ||
) |
Definition at line 506 of file stagewise_poly.cc.
References stagewise_poly::all, vw::all_reduce, stagewise_poly::batch_sz, stagewise_poly::batch_sz_double, example::example_counter, example::l, label_data::label, stagewise_poly::last_example_counter, LEARNER::learner< T, E >::learn(), stagewise_poly::next_batch_sz, stagewise_poly::numpasses, stagewise_poly::original_ec, example::partial_prediction, example::pred, predict(), polyprediction::scalar, polylabel::simple, sort_data_update_support(), stagewise_poly::synth_ec, synthetic_create(), vw::training, stagewise_poly::update_support, and example::updated_prediction.
Referenced by stagewise_poly_setup().
|
inline |
Definition at line 167 of file stagewise_poly.cc.
References stagewise_poly::depthsbits, do_ft_offset(), stride_shift(), and stride_un_shift().
Referenced by sanity_check_state(), and synthetic_create_rec().
|
inline |
Definition at line 174 of file stagewise_poly.cc.
References stagewise_poly::depthsbits, do_ft_offset(), stride_shift(), and stride_un_shift().
Referenced by synthetic_create_rec().
|
inline |
Definition at line 136 of file stagewise_poly.cc.
References stagewise_poly::depthsbits, do_ft_offset(), parent_bit, stride_shift(), and wid_mask_un_shifted().
Referenced by sanity_check_state(), sort_data_update_support(), and synthetic_create_rec().
|
inline |
Definition at line 143 of file stagewise_poly.cc.
References stagewise_poly::depthsbits, do_ft_offset(), parent_bit, stride_shift(), and wid_mask_un_shifted().
Referenced by sort_data_update_support(), and synthetic_create_rec().
void predict | ( | stagewise_poly & | poly, |
single_learner & | base, | ||
example & | ec | ||
) |
Definition at line 496 of file stagewise_poly.cc.
References stagewise_poly::original_ec, example::partial_prediction, example::pred, LEARNER::learner< T, E >::predict(), polyprediction::scalar, stagewise_poly::synth_ec, synthetic_create(), and example::updated_prediction.
Referenced by learn(), and stagewise_poly_setup().
void reduce_min | ( | uint8_t & | v1, |
const uint8_t & | v2 | ||
) |
void reduce_min_max | ( | uint8_t & | v1, |
const uint8_t & | v2 | ||
) |
void sanity_check_state | ( | stagewise_poly & | poly | ) |
Definition at line 182 of file stagewise_poly.cc.
References stagewise_poly::all, cycle_bit, cycle_get(), default_depth, parameters::dense_weights, stagewise_poly::depthsbits, indicator_bit, vw::length(), min_depths_get(), parent_bit, parent_get(), parameters::sparse, parameters::sparse_weights, stride_shift(), vw::weights, and wid_mask_un_shifted().
Referenced by end_pass(), and sort_data_update_support().
void save_load | ( | stagewise_poly & | poly, |
io_buf & | model_file, | ||
bool | read, | ||
bool | text | ||
) |
Definition at line 639 of file stagewise_poly.cc.
References bin_text_read_write_fixed(), stagewise_poly::depthsbits, depthsbits_sizeof(), io_buf::files, and v_array< T >::size().
Referenced by stagewise_poly_setup().
Definition at line 259 of file stagewise_poly.cc.
References sort_data::weightsal.
Referenced by sort_data_update_support().
void sort_data_create | ( | stagewise_poly & | poly | ) |
Definition at line 228 of file stagewise_poly.cc.
References stagewise_poly::sd, and stagewise_poly::sd_len.
Referenced by stagewise_poly_setup().
void sort_data_ensure_sz | ( | stagewise_poly & | poly, |
size_t | len | ||
) |
Definition at line 234 of file stagewise_poly.cc.
References stagewise_poly::all, vw::length(), stagewise_poly::sd, and stagewise_poly::sd_len.
Referenced by sort_data_update_support().
void sort_data_update_support | ( | stagewise_poly & | poly | ) |
Definition at line 274 of file stagewise_poly.cc.
References stagewise_poly::all, constant_feat_masked(), example_predict::ft_offset, vw::length(), vw::normalized_idx, stagewise_poly::num_examples, stagewise_poly::original_ec, parent_get(), parent_toggle(), sanity_check_state(), stagewise_poly::sched_exponent, stagewise_poly::sd, stagewise_poly::sd_len, sort_data_compar_heap(), sort_data_ensure_sz(), stride_shift(), stagewise_poly::sum_input_sparsity, stagewise_poly::synth_ec, tolerance, vw::weights, sort_data::weightsal, and sort_data::wid.
Referenced by learn().
base_learner* stagewise_poly_setup | ( | options_i & | options, |
vw & | all | ||
) |
Definition at line 656 of file stagewise_poly.cc.
References VW::config::option_group_definition::add(), add(), VW::config::options_i::add_and_parse(), LEARNER::as_singleline(), depthsbits_create(), LEARNER::end_pass(), finish_example(), LEARNER::init_learner(), learn(), LEARNER::make_base(), VW::config::make_option(), predict(), save_load(), LEARNER::learner< T, E >::set_end_pass(), LEARNER::learner< T, E >::set_finish_example(), LEARNER::learner< T, E >::set_save_load(), setup_base(), and sort_data_create().
Referenced by parse_reductions().
|
inline |
Definition at line 81 of file stagewise_poly.cc.
References stagewise_poly::all, parameters::stride_shift(), and vw::weights.
Referenced by Search::add_neighbor_features(), GD::audit_feature(), child_wid(), constant_feat(), cycle_get(), cycle_toggle(), VW::export_example(), learn_with_metrics(), min_depths_get(), min_depths_set(), parent_get(), parent_toggle(), predict_or_learn(), MWT::predict_or_learn(), GD::print_lda_features(), sanity_check_state(), MARGINAL::save_load(), save_load(), sort_data_update_support(), sparse_parameters::stride_shift(), and synthetic_create_rec().
|
inline |
Definition at line 86 of file stagewise_poly.cc.
References stagewise_poly::all, parameters::stride_shift(), and vw::weights.
Referenced by child_wid(), min_depths_get(), min_depths_set(), and wid_mask_un_shifted().
void synthetic_create | ( | stagewise_poly & | poly, |
example & | ec, | ||
bool | training | ||
) |
Definition at line 470 of file stagewise_poly.cc.
References stagewise_poly::all, constant_feat_masked(), stagewise_poly::cur_depth, example_predict::feature_space, stagewise_poly::num_examples, example::num_features, stagewise_poly::original_ec, stagewise_poly::sum_input_sparsity, stagewise_poly::sum_sparsity, stagewise_poly::synth_ec, stagewise_poly::synth_rec_f, synthetic_decycle(), synthetic_reset(), example::total_sum_feat_sq, stagewise_poly::training, tree_atomics, feature::weight_index, and feature::x.
Referenced by learn(), and predict().
void synthetic_create_rec | ( | stagewise_poly & | poly, |
float | v, | ||
uint64_t | findex | ||
) |
Definition at line 415 of file stagewise_poly.cc.
References stagewise_poly::all, child_wid(), stagewise_poly::cur_depth, cycle_get(), cycle_toggle(), default_depth, example_predict::feature_space, min_depths_get(), min_depths_set(), example::num_features, stagewise_poly::original_ec, parent_get(), parent_toggle(), stride_shift(), stagewise_poly::synth_ec, stagewise_poly::synth_rec_f, stagewise_poly::training, tree_atomics, un_ft_offset(), feature::weight_index, wid_mask(), and feature::x.
void synthetic_decycle | ( | stagewise_poly & | poly | ) |
Definition at line 405 of file stagewise_poly.cc.
References cycle_get(), cycle_toggle(), example_predict::feature_space, features::indicies, features::size(), stagewise_poly::synth_ec, and tree_atomics.
Referenced by synthetic_create().
void synthetic_reset | ( | stagewise_poly & | poly, |
example & | ec | ||
) |
Some comments on ft_offset.
The plan is to do the feature mapping dfs with weight indices ignoring the ft_offset. This is because ft_offset is then added at the end, guaranteeing local/strided access on synth_ec. This might not matter too much in this implementation (where, e.g., –oaa runs one after the other, not interleaved), but who knows.
(The other choice is to basically ignore adjusting for ft_offset when doing the traversal, which means synth_ec.ft_offset is 0 here...)
Anyway, so here is how ft_offset matters:
Definition at line 363 of file stagewise_poly.cc.
References stagewise_poly::all, example::end_pass, example::example_counter, example_predict::feature_space, example_predict::ft_offset, example::in_use, example_predict::indices, example_predict::interactions, vw::interactions, example::l, example::num_features, v_array< T >::push_back(), v_array< T >::size(), example::sorted, stagewise_poly::synth_ec, example::tag, example::test_only, example::total_sum_feat_sq, tree_atomics, and example::weight.
Referenced by synthetic_create().
|
inline |
Definition at line 98 of file stagewise_poly.cc.
References stagewise_poly::all, example_predict::ft_offset, vw::length(), stagewise_poly::original_ec, parameters::stride_shift(), stagewise_poly::synth_ec, and vw::weights.
Referenced by synthetic_create_rec().
|
inline |
Definition at line 113 of file stagewise_poly.cc.
References stagewise_poly::all, parameters::mask(), and vw::weights.
Referenced by child_wid(), constant_feat_masked(), and synthetic_create_rec().
|
inline |
Definition at line 115 of file stagewise_poly.cc.
References stagewise_poly::all, parameters::mask(), stride_un_shift(), and vw::weights.
Referenced by cycle_get(), cycle_toggle(), parent_get(), parent_toggle(), and sanity_check_state().
|
static |
Definition at line 16 of file stagewise_poly.cc.
Referenced by cycle_get(), cycle_toggle(), and sanity_check_state().
|
static |
Definition at line 20 of file stagewise_poly.cc.
Referenced by depthsbits_create(), reduce_min(), reduce_min_max(), sanity_check_state(), and synthetic_create_rec().
|
static |
Definition at line 19 of file stagewise_poly.cc.
Referenced by depthsbits_create(), reduce_min_max(), and sanity_check_state().
|
static |
Definition at line 15 of file stagewise_poly.cc.
Referenced by parent_get(), parent_toggle(), and sanity_check_state().
|
static |
Definition at line 18 of file stagewise_poly.cc.
Referenced by sort_data_update_support().
|
static |
Definition at line 17 of file stagewise_poly.cc.
Referenced by synthetic_create(), synthetic_create_rec(), synthetic_decycle(), synthetic_reset(), and stagewise_poly::~stagewise_poly().