26 #define PROCESS_SELF_INTERACTIONS(ft_value) feature_self_interactions 30 template <
class R,
void (*T)(R&, const
float,
float&),
class W>
31 inline void call_T(R& dat, W& weights,
const float ft_value,
const uint64_t ft_idx)
33 T(dat, ft_value, weights[ft_idx]);
36 template <
class R,
void (*T)(R&, const
float, const
float&),
class W>
37 inline void call_T(R& dat,
const W& weights,
const float ft_value,
const uint64_t ft_idx)
39 T(dat, ft_value, weights[ft_idx]);
42 template <
class R,
void (*T)(R&,
float, u
int64_t),
class W>
43 inline void call_T(R& dat, W& ,
const float ft_value,
const uint64_t ft_idx)
45 T(dat, ft_value, ft_idx);
73 template <
class R,
class S,
void (*T)(R&,
float, S),
bool audit,
void (*audit_func)(R&, const audit_
strings*),
class W>
79 for (; begin != end; ++begin)
81 audit_func(dat, begin.
audit().get());
83 audit_func(dat,
nullptr);
88 for (; begin != end; ++begin)
96 template <
class R,
class S, void (*T)(R&, float, S),
bool audit,
void (*audit_func)(R&,
const audit_strings*),
113 empty_ns_data.x = 1.;
114 empty_ns_data.loop_end = 0;
115 empty_ns_data.self_interaction =
false;
118 for (
auto& ns : interactions)
121 #ifndef GEN_INTER_LOOP 127 const size_t len = ns.size();
131 features& first = features_data[(uint8_t)ns[0]];
134 features& second = features_data[(uint8_t)ns[1]];
137 const bool same_namespace = (!permutations && (ns[0] == ns[1]));
152 inner_kernel<R, S, T, audit, audit_func>(dat, begin, end, offset, weights, ft_value, halfhash);
155 audit_func(dat,
nullptr);
162 features& first = features_data[(uint8_t)ns[0]];
165 features& second = features_data[(uint8_t)ns[1]];
168 features& third = features_data[(uint8_t)ns[2]];
171 const bool same_namespace1 = (!permutations && (ns[0] == ns[1]));
172 const bool same_namespace2 = (!permutations && (ns[1] == ns[2]));
179 const float& first_ft_value = first.
values[i];
197 inner_kernel<R, S, T, audit, audit_func>(dat, begin, end, offset, weights, ft_value, halfhash);
199 audit_func(dat,
nullptr);
202 audit_func(dat,
nullptr);
213 bool must_skip_interaction =
false;
219 features& ft = features_data[(int32_t)n];
224 must_skip_interaction =
true;
228 if (fgd == state_data.
end())
231 fgd = state_data.
end() - 1;
240 if (must_skip_interaction)
253 for (fgd = state_data.
end() - 1; fgd > state_data.
begin(); --fgd)
264 must_skip_interaction = loop_end < margin;
265 if (must_skip_interaction)
272 else if (margin != 0)
279 if (must_skip_interaction)
283 fgd = state_data.
begin();
284 fgd2 = state_data.
end() - 1;
322 next_data->
x = fs.
values[feature];
347 inner_kernel<R, S, T, audit, audit_func, W>(dat, begin, end, offset, weights, ft_value, halfhash);
351 bool go_further =
true;
358 audit_func(dat,
nullptr);
359 }
while (go_further && cur_data != fgd);
361 do_it = !(cur_data == fgd && go_further);
v_array< feature_index > indicies
features_value_index_audit_range values_indices_audit()
the core definition of a set of features.
v_array< feature_value > values
constexpr bool feature_self_interactions
std::array< features, NUM_NAMESPACES > feature_space
void push_back(const T &new_ele)
defines a "range" usable by C++ 11 for loops
iterator over values, indicies and audit space names
unsigned char namespace_index
void generate_interactions(vw &all, example_predict &ec, R &dat)
audit_strings_ptr & audit()
#define PROCESS_SELF_INTERACTIONS(ft_value)
v_array< audit_strings_ptr > space_names
constexpr uint32_t FNV_prime
float INTERACTION_VALUE(float value1, float value2)
void call_T(R &dat, W &weights, const float ft_value, const uint64_t ft_idx)
void inner_kernel(R &dat, features::iterator_all &begin, features::iterator_all &end, const uint64_t offset, W &weights, feature_value ft_value, feature_index halfhash)
std::pair< std::string, std::string > audit_strings