Checkpoint the party/runtime stack before share-program and malicious-mode work.
Ship the TLS mesh, composer, Beaver/Yao/leaf MPC, prep/online paths, apps, and docs so the tree is pushable before elevating share_expr, security_mode, and prep resume. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
parent
695f8e84f7
commit
0d22946a0e
1835 changed files with 170291 additions and 2849 deletions
|
|
@ -40,6 +40,9 @@ struct easy_lut
|
|||
|
||||
HEDLEY_NO_THROW
|
||||
std::size_t parts() const noexcept { return c0.size(); }
|
||||
/// \complexity `upper_bound` on `bounds` (`Θ(log P)` comparisons, `P = parts()`), then three multiplies for the quadratic. Extra space `Θ(1)`.
|
||||
/// @param x raw fixed-point input
|
||||
/// @return the rounded piece value
|
||||
|
||||
std::int64_t operator()(Raw x) const
|
||||
{
|
||||
|
|
@ -155,6 +158,11 @@ inline std::int64_t denom_shift(unsigned shift)
|
|||
}
|
||||
|
||||
} // namespace detail
|
||||
/// \complexity Assembles a constant number of pieces (the knots are a fixed integer pattern shifted by `fractional_bits`). `Θ(1)` time and extra space, aside from the returned vectors of that constant length.
|
||||
/// @see grotto::easy_lut
|
||||
/// @see grotto::eval_window
|
||||
/// @param fractional_bits fractional bits; integer knots become `k << fractional_bits`
|
||||
/// @tparam Raw signed raw word
|
||||
|
||||
template <typename Raw>
|
||||
easy_lut<Raw> make_abs_lut(unsigned fractional_bits = 0)
|
||||
|
|
@ -167,6 +175,11 @@ easy_lut<Raw> make_abs_lut(unsigned fractional_bits = 0)
|
|||
return p;
|
||||
});
|
||||
}
|
||||
/// \complexity Assembles a constant number of pieces (the knots are a fixed integer pattern shifted by `fractional_bits`). `Θ(1)` time and extra space, aside from the returned vectors of that constant length.
|
||||
/// @see grotto::easy_lut
|
||||
/// @see grotto::eval_window
|
||||
/// @param fractional_bits fractional bits; integer knots become `k << fractional_bits`
|
||||
/// @tparam Raw signed raw word
|
||||
|
||||
template <typename Raw>
|
||||
easy_lut<Raw> make_relu_lut(unsigned fractional_bits = 0)
|
||||
|
|
@ -182,6 +195,9 @@ easy_lut<Raw> make_relu_lut(unsigned fractional_bits = 0)
|
|||
/// @tparam Raw underlying representation
|
||||
/// @param shift the bit shift
|
||||
/// @return Negative side is `x / 2^shift`, rounded to nearest, ties away from zero
|
||||
/// \complexity Assembles a constant number of pieces. `Θ(1)` time and extra space, aside from the returned vectors of that constant length.
|
||||
/// @see grotto::easy_lut
|
||||
/// @see grotto::eval_window
|
||||
template <typename Raw>
|
||||
easy_lut<Raw> make_leaky_relu_lut(unsigned shift)
|
||||
{
|
||||
|
|
@ -192,6 +208,11 @@ easy_lut<Raw> make_leaky_relu_lut(unsigned shift)
|
|||
return detail::easy_poly{0, 1, 0, den};
|
||||
});
|
||||
}
|
||||
/// \complexity Assembles a constant number of pieces (the knots are a fixed integer pattern shifted by `fractional_bits`). `Θ(1)` time and extra space, aside from the returned vectors of that constant length.
|
||||
/// @see grotto::easy_lut
|
||||
/// @see grotto::eval_window
|
||||
/// @param fractional_bits fractional bits; integer knots become `k << fractional_bits`
|
||||
/// @tparam Raw signed raw word
|
||||
|
||||
template <typename Raw>
|
||||
easy_lut<Raw> make_squared_relu_lut(unsigned fractional_bits)
|
||||
|
|
@ -233,18 +254,35 @@ easy_lut<Raw> clip_to(unsigned fractional_bits, std::int64_t low_units, std::int
|
|||
}
|
||||
|
||||
} // namespace detail
|
||||
|
||||
/// @brief Clip to `[low_units, high_units]` in raw units, then shift the knots by `fractional_bits`.
|
||||
/// @tparam Raw signed raw word
|
||||
/// @param fractional_bits fractional bits; integer knots become `k << fractional_bits`
|
||||
/// @param low_units inclusive lower clip, in integer units before the fractional shift
|
||||
/// @param high_units inclusive upper clip, in integer units before the fractional shift
|
||||
/// \complexity Assembles a constant number of pieces. `Θ(1)` time and extra space.
|
||||
/// @see grotto::easy_lut
|
||||
/// @see grotto::eval_window
|
||||
template <typename Raw>
|
||||
easy_lut<Raw> make_clip_lut(unsigned fractional_bits, std::int64_t low_units, std::int64_t high_units)
|
||||
{
|
||||
return detail::clip_to<Raw>(fractional_bits, low_units, high_units);
|
||||
}
|
||||
/// \complexity Assembles a constant number of pieces (the knots are a fixed integer pattern shifted by `fractional_bits`). `Θ(1)` time and extra space, aside from the returned vectors of that constant length.
|
||||
/// @see grotto::easy_lut
|
||||
/// @see grotto::eval_window
|
||||
/// @param fractional_bits fractional bits; integer knots become `k << fractional_bits`
|
||||
/// @tparam Raw signed raw word
|
||||
|
||||
template <typename Raw>
|
||||
easy_lut<Raw> make_relu6_lut(unsigned fractional_bits)
|
||||
{
|
||||
return make_clip_lut<Raw>(fractional_bits, 0, 6);
|
||||
}
|
||||
/// \complexity Assembles a constant number of pieces (the knots are a fixed integer pattern shifted by `fractional_bits`). `Θ(1)` time and extra space, aside from the returned vectors of that constant length.
|
||||
/// @see grotto::easy_lut
|
||||
/// @see grotto::eval_window
|
||||
/// @param fractional_bits fractional bits; integer knots become `k << fractional_bits`
|
||||
/// @tparam Raw signed raw word
|
||||
|
||||
template <typename Raw>
|
||||
easy_lut<Raw> make_hardtanh_lut(unsigned fractional_bits)
|
||||
|
|
@ -256,6 +294,9 @@ easy_lut<Raw> make_hardtanh_lut(unsigned fractional_bits)
|
|||
/// @tparam Raw underlying representation
|
||||
/// @param fractional_bits the number of fractional bits
|
||||
/// @return `0` on `[-1, 1]`, `x - 1` above, `x + 1` below
|
||||
/// \complexity Assembles a constant number of pieces (the knots are a fixed integer pattern shifted by `fractional_bits`). `Θ(1)` time and extra space, aside from the returned vectors of that constant length.
|
||||
/// @see grotto::easy_lut
|
||||
/// @see grotto::eval_window
|
||||
template <typename Raw>
|
||||
easy_lut<Raw> make_softshrink_lut(unsigned fractional_bits)
|
||||
{
|
||||
|
|
@ -281,6 +322,9 @@ easy_lut<Raw> make_softshrink_lut(unsigned fractional_bits)
|
|||
/// @tparam Raw underlying representation
|
||||
/// @param fractional_bits the number of fractional bits
|
||||
/// @return `0` on `[-1, 1]`, identity outside
|
||||
/// \complexity Assembles a constant number of pieces (the knots are a fixed integer pattern shifted by `fractional_bits`). `Θ(1)` time and extra space, aside from the returned vectors of that constant length.
|
||||
/// @see grotto::easy_lut
|
||||
/// @see grotto::eval_window
|
||||
template <typename Raw>
|
||||
easy_lut<Raw> make_hardshrink_lut(unsigned fractional_bits)
|
||||
{
|
||||
|
|
@ -305,6 +349,9 @@ easy_lut<Raw> make_hardshrink_lut(unsigned fractional_bits)
|
|||
/// @param fractional_bits the number of fractional bits
|
||||
/// @return `0` left of `-3`, `1` right of `3`, `(x + 3) / 6` between, rounded
|
||||
/// @throws std::invalid_argument if `fractional width does not fit`
|
||||
/// \complexity Assembles a constant number of pieces (the knots are a fixed integer pattern shifted by `fractional_bits`). `Θ(1)` time and extra space, aside from the returned vectors of that constant length.
|
||||
/// @see grotto::easy_lut
|
||||
/// @see grotto::eval_window
|
||||
template <typename Raw>
|
||||
easy_lut<Raw> make_hardsigmoid_lut(unsigned fractional_bits)
|
||||
{
|
||||
|
|
@ -335,6 +382,9 @@ easy_lut<Raw> make_hardsigmoid_lut(unsigned fractional_bits)
|
|||
/// @param fractional_bits the number of fractional bits
|
||||
/// @return `0` left of `-3`, `x` right of `3`, `x(x + 3) / 6` between, rounded
|
||||
/// @throws std::invalid_argument if `fractional width does not fit the denominator`
|
||||
/// \complexity Assembles a constant number of pieces (the knots are a fixed integer pattern shifted by `fractional_bits`). `Θ(1)` time and extra space, aside from the returned vectors of that constant length.
|
||||
/// @see grotto::easy_lut
|
||||
/// @see grotto::eval_window
|
||||
template <typename Raw>
|
||||
easy_lut<Raw> make_hardswish_lut(unsigned fractional_bits)
|
||||
{
|
||||
|
|
@ -360,6 +410,25 @@ easy_lut<Raw> make_hardswish_lut(unsigned fractional_bits)
|
|||
});
|
||||
}
|
||||
|
||||
/// @brief Appendix D leaky ReLU: identity on the right, `x/100` on the left.
|
||||
/// @details `make_leaky_relu_lut` is the dyadic slope `1/2^shift`. This one is
|
||||
/// the paper's slope `1/100`, rounded to nearest, ties away from zero.
|
||||
/// The fractional scale cancels, so the denominator does not depend
|
||||
/// on `fractional_bits`.
|
||||
/// @tparam Raw underlying representation
|
||||
/// @return two pieces, degree 1
|
||||
/// \complexity Assembles two pieces. `Θ(1)` time and extra space, aside from the returned vectors.
|
||||
/// @see grotto::make_leaky_relu_lut
|
||||
template <typename Raw>
|
||||
easy_lut<Raw> make_leaky_relu_hundredth_lut()
|
||||
{
|
||||
return detail::assemble_easy<Raw>({0}, [](std::int64_t raw) {
|
||||
if (raw >= 0)
|
||||
return detail::kIdentity;
|
||||
return detail::easy_poly{0, 1, 0, 100};
|
||||
});
|
||||
}
|
||||
|
||||
} // namespace grotto
|
||||
|
||||
#endif // LIBDPF_INCLUDE_GROTTO_EASY_LUT_HPP__
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue