#include #include #include #include #include #include #include #include #include #include #include #include namespace rust { inline namespace cxxbridge1 { // #include "rust/cxx.h" #ifndef CXXBRIDGE1_PANIC #define CXXBRIDGE1_PANIC template void panic [[noreturn]] (const char *msg); #endif // CXXBRIDGE1_PANIC struct unsafe_bitcopy_t; namespace { template class impl; } // namespace template ::std::size_t size_of(); template ::std::size_t align_of(); #ifndef CXXBRIDGE1_RUST_STRING #define CXXBRIDGE1_RUST_STRING class String final { public: String() noexcept; String(const String &) noexcept; String(String &&) noexcept; ~String() noexcept; String(const std::string &); String(const char *); String(const char *, std::size_t); String(const char16_t *); String(const char16_t *, std::size_t); static String lossy(const std::string &) noexcept; static String lossy(const char *) noexcept; static String lossy(const char *, std::size_t) noexcept; static String lossy(const char16_t *) noexcept; static String lossy(const char16_t *, std::size_t) noexcept; String &operator=(const String &) &noexcept; String &operator=(String &&) &noexcept; explicit operator std::string() const; const char *data() const noexcept; std::size_t size() const noexcept; std::size_t length() const noexcept; bool empty() const noexcept; const char *c_str() noexcept; std::size_t capacity() const noexcept; void reserve(size_t new_cap) noexcept; using iterator = char *; iterator begin() noexcept; iterator end() noexcept; using const_iterator = const char *; const_iterator begin() const noexcept; const_iterator end() const noexcept; const_iterator cbegin() const noexcept; const_iterator cend() const noexcept; bool operator==(const String &) const noexcept; bool operator!=(const String &) const noexcept; bool operator<(const String &) const noexcept; bool operator<=(const String &) const noexcept; bool operator>(const String &) const noexcept; bool operator>=(const String &) const noexcept; void swap(String &) noexcept; String(unsafe_bitcopy_t, const String &) noexcept; private: struct lossy_t; String(lossy_t, const char *, std::size_t) noexcept; String(lossy_t, const char16_t *, std::size_t) noexcept; friend void swap(String &lhs, String &rhs) noexcept { lhs.swap(rhs); } std::array repr; }; #endif // CXXBRIDGE1_RUST_STRING #ifndef CXXBRIDGE1_RUST_STR #define CXXBRIDGE1_RUST_STR class Str final { public: Str() noexcept; Str(const String &) noexcept; Str(const std::string &); Str(const char *); Str(const char *, std::size_t); Str &operator=(const Str &) &noexcept = default; explicit operator std::string() const; const char *data() const noexcept; std::size_t size() const noexcept; std::size_t length() const noexcept; bool empty() const noexcept; Str(const Str &) noexcept = default; ~Str() noexcept = default; using iterator = const char *; using const_iterator = const char *; const_iterator begin() const noexcept; const_iterator end() const noexcept; const_iterator cbegin() const noexcept; const_iterator cend() const noexcept; bool operator==(const Str &) const noexcept; bool operator!=(const Str &) const noexcept; bool operator<(const Str &) const noexcept; bool operator<=(const Str &) const noexcept; bool operator>(const Str &) const noexcept; bool operator>=(const Str &) const noexcept; void swap(Str &) noexcept; private: class uninit; Str(uninit) noexcept; friend impl; std::array repr; }; #endif // CXXBRIDGE1_RUST_STR #ifndef CXXBRIDGE1_RUST_SLICE #define CXXBRIDGE1_RUST_SLICE namespace detail { template struct copy_assignable_if {}; template <> struct copy_assignable_if { copy_assignable_if() noexcept = default; copy_assignable_if(const copy_assignable_if &) noexcept = default; copy_assignable_if &operator=(const copy_assignable_if &) &noexcept = delete; copy_assignable_if &operator=(copy_assignable_if &&) &noexcept = default; }; } // namespace detail template class Slice final : private detail::copy_assignable_if::value> { public: using value_type = T; Slice() noexcept; Slice(T *, std::size_t count) noexcept; Slice &operator=(const Slice &) &noexcept = default; Slice &operator=(Slice &&) &noexcept = default; T *data() const noexcept; std::size_t size() const noexcept; std::size_t length() const noexcept; bool empty() const noexcept; T &operator[](std::size_t n) const noexcept; T &at(std::size_t n) const; T &front() const noexcept; T &back() const noexcept; Slice(const Slice &) noexcept = default; ~Slice() noexcept = default; class iterator; iterator begin() const noexcept; iterator end() const noexcept; void swap(Slice &) noexcept; private: class uninit; Slice(uninit) noexcept; friend impl; friend void sliceInit(void *, const void *, std::size_t) noexcept; friend void *slicePtr(const void *) noexcept; friend std::size_t sliceLen(const void *) noexcept; std::array repr; }; template class Slice::iterator final { public: using iterator_category = std::random_access_iterator_tag; using value_type = T; using difference_type = std::ptrdiff_t; using pointer = typename std::add_pointer::type; using reference = typename std::add_lvalue_reference::type; reference operator*() const noexcept; pointer operator->() const noexcept; reference operator[](difference_type) const noexcept; iterator &operator++() noexcept; iterator operator++(int) noexcept; iterator &operator--() noexcept; iterator operator--(int) noexcept; iterator &operator+=(difference_type) noexcept; iterator &operator-=(difference_type) noexcept; iterator operator+(difference_type) const noexcept; iterator operator-(difference_type) const noexcept; difference_type operator-(const iterator &) const noexcept; bool operator==(const iterator &) const noexcept; bool operator!=(const iterator &) const noexcept; bool operator<(const iterator &) const noexcept; bool operator<=(const iterator &) const noexcept; bool operator>(const iterator &) const noexcept; bool operator>=(const iterator &) const noexcept; private: friend class Slice; void *pos; std::size_t stride; }; template Slice::Slice() noexcept { sliceInit(this, reinterpret_cast(align_of()), 0); } template Slice::Slice(T *s, std::size_t count) noexcept { assert(s != nullptr || count == 0); sliceInit(this, s == nullptr && count == 0 ? reinterpret_cast(align_of()) : const_cast::type *>(s), count); } template T *Slice::data() const noexcept { return reinterpret_cast(slicePtr(this)); } template std::size_t Slice::size() const noexcept { return sliceLen(this); } template std::size_t Slice::length() const noexcept { return this->size(); } template bool Slice::empty() const noexcept { return this->size() == 0; } template T &Slice::operator[](std::size_t n) const noexcept { assert(n < this->size()); auto ptr = static_cast(slicePtr(this)) + size_of() * n; return *reinterpret_cast(ptr); } template T &Slice::at(std::size_t n) const { if (n >= this->size()) { panic("rust::Slice index out of range"); } return (*this)[n]; } template T &Slice::front() const noexcept { assert(!this->empty()); return (*this)[0]; } template T &Slice::back() const noexcept { assert(!this->empty()); return (*this)[this->size() - 1]; } template typename Slice::iterator::reference Slice::iterator::operator*() const noexcept { return *static_cast(this->pos); } template typename Slice::iterator::pointer Slice::iterator::operator->() const noexcept { return static_cast(this->pos); } template typename Slice::iterator::reference Slice::iterator::operator[]( typename Slice::iterator::difference_type n) const noexcept { auto ptr = static_cast(this->pos) + this->stride * n; return *reinterpret_cast(ptr); } template typename Slice::iterator &Slice::iterator::operator++() noexcept { this->pos = static_cast(this->pos) + this->stride; return *this; } template typename Slice::iterator Slice::iterator::operator++(int) noexcept { auto ret = iterator(*this); this->pos = static_cast(this->pos) + this->stride; return ret; } template typename Slice::iterator &Slice::iterator::operator--() noexcept { this->pos = static_cast(this->pos) - this->stride; return *this; } template typename Slice::iterator Slice::iterator::operator--(int) noexcept { auto ret = iterator(*this); this->pos = static_cast(this->pos) - this->stride; return ret; } template typename Slice::iterator &Slice::iterator::operator+=( typename Slice::iterator::difference_type n) noexcept { this->pos = static_cast(this->pos) + this->stride * n; return *this; } template typename Slice::iterator &Slice::iterator::operator-=( typename Slice::iterator::difference_type n) noexcept { this->pos = static_cast(this->pos) - this->stride * n; return *this; } template typename Slice::iterator Slice::iterator::operator+( typename Slice::iterator::difference_type n) const noexcept { auto ret = iterator(*this); ret.pos = static_cast(this->pos) + this->stride * n; return ret; } template typename Slice::iterator Slice::iterator::operator-( typename Slice::iterator::difference_type n) const noexcept { auto ret = iterator(*this); ret.pos = static_cast(this->pos) - this->stride * n; return ret; } template typename Slice::iterator::difference_type Slice::iterator::operator-(const iterator &other) const noexcept { auto diff = std::distance(static_cast(other.pos), static_cast(this->pos)); return diff / this->stride; } template bool Slice::iterator::operator==(const iterator &other) const noexcept { return this->pos == other.pos; } template bool Slice::iterator::operator!=(const iterator &other) const noexcept { return this->pos != other.pos; } template bool Slice::iterator::operator<(const iterator &other) const noexcept { return this->pos < other.pos; } template bool Slice::iterator::operator<=(const iterator &other) const noexcept { return this->pos <= other.pos; } template bool Slice::iterator::operator>(const iterator &other) const noexcept { return this->pos > other.pos; } template bool Slice::iterator::operator>=(const iterator &other) const noexcept { return this->pos >= other.pos; } template typename Slice::iterator Slice::begin() const noexcept { iterator it; it.pos = slicePtr(this); it.stride = size_of(); return it; } template typename Slice::iterator Slice::end() const noexcept { iterator it = this->begin(); it.pos = static_cast(it.pos) + it.stride * this->size(); return it; } template void Slice::swap(Slice &rhs) noexcept { std::swap(*this, rhs); } #endif // CXXBRIDGE1_RUST_SLICE #ifndef CXXBRIDGE1_RUST_BOX #define CXXBRIDGE1_RUST_BOX template class Box final { public: using element_type = T; using const_pointer = typename std::add_pointer::type>::type; using pointer = typename std::add_pointer::type; Box() = delete; Box(Box &&) noexcept; ~Box() noexcept; explicit Box(const T &); explicit Box(T &&); Box &operator=(Box &&) &noexcept; const T *operator->() const noexcept; const T &operator*() const noexcept; T *operator->() noexcept; T &operator*() noexcept; template static Box in_place(Fields &&...); void swap(Box &) noexcept; static Box from_raw(T *) noexcept; T *into_raw() noexcept; /* Deprecated */ using value_type = element_type; private: class uninit; class allocation; Box(uninit) noexcept; void drop() noexcept; friend void swap(Box &lhs, Box &rhs) noexcept { lhs.swap(rhs); } T *ptr; }; template class Box::uninit {}; template class Box::allocation { static T *alloc() noexcept; static void dealloc(T *) noexcept; public: allocation() noexcept : ptr(alloc()) {} ~allocation() noexcept { if (this->ptr) { dealloc(this->ptr); } } T *ptr; }; template Box::Box(Box &&other) noexcept : ptr(other.ptr) { other.ptr = nullptr; } template Box::Box(const T &val) { allocation alloc; ::new (alloc.ptr) T(val); this->ptr = alloc.ptr; alloc.ptr = nullptr; } template Box::Box(T &&val) { allocation alloc; ::new (alloc.ptr) T(std::move(val)); this->ptr = alloc.ptr; alloc.ptr = nullptr; } template Box::~Box() noexcept { if (this->ptr) { this->drop(); } } template Box &Box::operator=(Box &&other) &noexcept { if (this->ptr) { this->drop(); } this->ptr = other.ptr; other.ptr = nullptr; return *this; } template const T *Box::operator->() const noexcept { return this->ptr; } template const T &Box::operator*() const noexcept { return *this->ptr; } template T *Box::operator->() noexcept { return this->ptr; } template T &Box::operator*() noexcept { return *this->ptr; } template template Box Box::in_place(Fields &&...fields) { allocation alloc; auto ptr = alloc.ptr; ::new (ptr) T{std::forward(fields)...}; alloc.ptr = nullptr; return from_raw(ptr); } template void Box::swap(Box &rhs) noexcept { using std::swap; swap(this->ptr, rhs.ptr); } template Box Box::from_raw(T *raw) noexcept { Box box = uninit{}; box.ptr = raw; return box; } template T *Box::into_raw() noexcept { T *raw = this->ptr; this->ptr = nullptr; return raw; } template Box::Box(uninit) noexcept {} #endif // CXXBRIDGE1_RUST_BOX #ifndef CXXBRIDGE1_RUST_BITCOPY_T #define CXXBRIDGE1_RUST_BITCOPY_T struct unsafe_bitcopy_t final { explicit unsafe_bitcopy_t() = default; }; #endif // CXXBRIDGE1_RUST_BITCOPY_T #ifndef CXXBRIDGE1_RUST_VEC #define CXXBRIDGE1_RUST_VEC template class Vec final { public: using value_type = T; Vec() noexcept; Vec(std::initializer_list); Vec(const Vec &); Vec(Vec &&) noexcept; ~Vec() noexcept; Vec &operator=(Vec &&) &noexcept; Vec &operator=(const Vec &) &; std::size_t size() const noexcept; bool empty() const noexcept; const T *data() const noexcept; T *data() noexcept; std::size_t capacity() const noexcept; const T &operator[](std::size_t n) const noexcept; const T &at(std::size_t n) const; const T &front() const noexcept; const T &back() const noexcept; T &operator[](std::size_t n) noexcept; T &at(std::size_t n); T &front() noexcept; T &back() noexcept; void reserve(std::size_t new_cap); void push_back(const T &value); void push_back(T &&value); template void emplace_back(Args &&...args); void truncate(std::size_t len); void clear(); using iterator = typename Slice::iterator; iterator begin() noexcept; iterator end() noexcept; using const_iterator = typename Slice::iterator; const_iterator begin() const noexcept; const_iterator end() const noexcept; const_iterator cbegin() const noexcept; const_iterator cend() const noexcept; void swap(Vec &) noexcept; Vec(unsafe_bitcopy_t, const Vec &) noexcept; private: void reserve_total(std::size_t new_cap) noexcept; void set_len(std::size_t len) noexcept; void drop() noexcept; friend void swap(Vec &lhs, Vec &rhs) noexcept { lhs.swap(rhs); } std::array repr; }; template Vec::Vec(std::initializer_list init) : Vec{} { this->reserve_total(init.size()); std::move(init.begin(), init.end(), std::back_inserter(*this)); } template Vec::Vec(const Vec &other) : Vec() { this->reserve_total(other.size()); std::copy(other.begin(), other.end(), std::back_inserter(*this)); } template Vec::Vec(Vec &&other) noexcept : repr(other.repr) { new (&other) Vec(); } template Vec::~Vec() noexcept { this->drop(); } template Vec &Vec::operator=(Vec &&other) &noexcept { this->drop(); this->repr = other.repr; new (&other) Vec(); return *this; } template Vec &Vec::operator=(const Vec &other) & { if (this != &other) { this->drop(); new (this) Vec(other); } return *this; } template bool Vec::empty() const noexcept { return this->size() == 0; } template T *Vec::data() noexcept { return const_cast(const_cast *>(this)->data()); } template const T &Vec::operator[](std::size_t n) const noexcept { assert(n < this->size()); auto data = reinterpret_cast(this->data()); return *reinterpret_cast(data + n * size_of()); } template const T &Vec::at(std::size_t n) const { if (n >= this->size()) { panic("rust::Vec index out of range"); } return (*this)[n]; } template const T &Vec::front() const noexcept { assert(!this->empty()); return (*this)[0]; } template const T &Vec::back() const noexcept { assert(!this->empty()); return (*this)[this->size() - 1]; } template T &Vec::operator[](std::size_t n) noexcept { assert(n < this->size()); auto data = reinterpret_cast(this->data()); return *reinterpret_cast(data + n * size_of()); } template T &Vec::at(std::size_t n) { if (n >= this->size()) { panic("rust::Vec index out of range"); } return (*this)[n]; } template T &Vec::front() noexcept { assert(!this->empty()); return (*this)[0]; } template T &Vec::back() noexcept { assert(!this->empty()); return (*this)[this->size() - 1]; } template void Vec::reserve(std::size_t new_cap) { this->reserve_total(new_cap); } template void Vec::push_back(const T &value) { this->emplace_back(value); } template void Vec::push_back(T &&value) { this->emplace_back(std::move(value)); } template template void Vec::emplace_back(Args &&...args) { auto size = this->size(); this->reserve_total(size + 1); ::new (reinterpret_cast(reinterpret_cast(this->data()) + size * size_of())) T(std::forward(args)...); this->set_len(size + 1); } template void Vec::clear() { this->truncate(0); } template typename Vec::iterator Vec::begin() noexcept { return Slice(this->data(), this->size()).begin(); } template typename Vec::iterator Vec::end() noexcept { return Slice(this->data(), this->size()).end(); } template typename Vec::const_iterator Vec::begin() const noexcept { return this->cbegin(); } template typename Vec::const_iterator Vec::end() const noexcept { return this->cend(); } template typename Vec::const_iterator Vec::cbegin() const noexcept { return Slice(this->data(), this->size()).begin(); } template typename Vec::const_iterator Vec::cend() const noexcept { return Slice(this->data(), this->size()).end(); } template void Vec::swap(Vec &rhs) noexcept { using std::swap; swap(this->repr, rhs.repr); } template Vec::Vec(unsafe_bitcopy_t, const Vec &bits) noexcept : repr(bits.repr) {} #endif // CXXBRIDGE1_RUST_VEC #ifndef CXXBRIDGE1_RUST_OPAQUE #define CXXBRIDGE1_RUST_OPAQUE class Opaque { public: Opaque() = delete; Opaque(const Opaque &) = delete; ~Opaque() = delete; }; #endif // CXXBRIDGE1_RUST_OPAQUE #ifndef CXXBRIDGE1_IS_COMPLETE #define CXXBRIDGE1_IS_COMPLETE namespace detail { namespace { template struct is_complete : std::false_type {}; template struct is_complete : std::true_type {}; } // namespace } // namespace detail #endif // CXXBRIDGE1_IS_COMPLETE #ifndef CXXBRIDGE1_LAYOUT #define CXXBRIDGE1_LAYOUT class layout { template friend std::size_t size_of(); template friend std::size_t align_of(); template static typename std::enable_if::value, std::size_t>::type do_size_of() { return T::layout::size(); } template static typename std::enable_if::value, std::size_t>::type do_size_of() { return sizeof(T); } template static typename std::enable_if::value, std::size_t>::type size_of() { return do_size_of(); } template static typename std::enable_if::value, std::size_t>::type do_align_of() { return T::layout::align(); } template static typename std::enable_if::value, std::size_t>::type do_align_of() { return alignof(T); } template static typename std::enable_if::value, std::size_t>::type align_of() { return do_align_of(); } }; template std::size_t size_of() { return layout::size_of(); } template std::size_t align_of() { return layout::align_of(); } #endif // CXXBRIDGE1_LAYOUT namespace detail { template struct operator_new { void *operator()(::std::size_t sz) { return ::operator new(sz); } }; template struct operator_new { void *operator()(::std::size_t sz) { return T::operator new(sz); } }; } // namespace detail template union MaybeUninit { T value; void *operator new(::std::size_t sz) { return detail::operator_new{}(sz); } MaybeUninit() {} ~MaybeUninit() {} }; } // namespace cxxbridge1 } // namespace rust namespace concrete_optimizer { struct OperationDag; struct Weights; enum class Encoding : ::std::uint8_t; struct Options; namespace dag { struct OperatorIndex; struct DagSolution; } namespace v0 { struct Solution; } } namespace concrete_optimizer { #ifndef CXXBRIDGE1_STRUCT_concrete_optimizer$OperationDag #define CXXBRIDGE1_STRUCT_concrete_optimizer$OperationDag struct OperationDag final : public ::rust::Opaque { ::concrete_optimizer::dag::OperatorIndex add_input(::std::uint8_t out_precision, ::rust::Slice<::std::uint64_t const> out_shape) noexcept; ::concrete_optimizer::dag::OperatorIndex add_lut(::concrete_optimizer::dag::OperatorIndex input, ::rust::Slice<::std::uint64_t const> table, ::std::uint8_t out_precision) noexcept; ::concrete_optimizer::dag::OperatorIndex add_dot(::rust::Slice<::concrete_optimizer::dag::OperatorIndex const> inputs, ::rust::Box<::concrete_optimizer::Weights> weights) noexcept; ::concrete_optimizer::dag::OperatorIndex add_levelled_op(::rust::Slice<::concrete_optimizer::dag::OperatorIndex const> inputs, double lwe_dim_cost_factor, double fixed_cost, double manp, ::rust::Slice<::std::uint64_t const> out_shape, ::rust::Str comment) noexcept; ::concrete_optimizer::dag::OperatorIndex add_round_op(::concrete_optimizer::dag::OperatorIndex input, ::std::uint8_t rounded_precision) noexcept; ::concrete_optimizer::v0::Solution optimize_v0(::concrete_optimizer::Options options) const noexcept; ::concrete_optimizer::dag::DagSolution optimize(::concrete_optimizer::Options options) const noexcept; ::rust::String dump() const noexcept; ~OperationDag() = delete; private: friend ::rust::layout; struct layout { static ::std::size_t size() noexcept; static ::std::size_t align() noexcept; }; }; #endif // CXXBRIDGE1_STRUCT_concrete_optimizer$OperationDag #ifndef CXXBRIDGE1_STRUCT_concrete_optimizer$Weights #define CXXBRIDGE1_STRUCT_concrete_optimizer$Weights struct Weights final : public ::rust::Opaque { ~Weights() = delete; private: friend ::rust::layout; struct layout { static ::std::size_t size() noexcept; static ::std::size_t align() noexcept; }; }; #endif // CXXBRIDGE1_STRUCT_concrete_optimizer$Weights #ifndef CXXBRIDGE1_ENUM_concrete_optimizer$Encoding #define CXXBRIDGE1_ENUM_concrete_optimizer$Encoding enum class Encoding : ::std::uint8_t { Auto = 0, Native = 1, Crt = 2, }; #endif // CXXBRIDGE1_ENUM_concrete_optimizer$Encoding namespace dag { #ifndef CXXBRIDGE1_STRUCT_concrete_optimizer$dag$OperatorIndex #define CXXBRIDGE1_STRUCT_concrete_optimizer$dag$OperatorIndex struct OperatorIndex final { ::std::size_t index; using IsRelocatable = ::std::true_type; }; #endif // CXXBRIDGE1_STRUCT_concrete_optimizer$dag$OperatorIndex } // namespace dag namespace v0 { #ifndef CXXBRIDGE1_STRUCT_concrete_optimizer$v0$Solution #define CXXBRIDGE1_STRUCT_concrete_optimizer$v0$Solution struct Solution final { ::std::uint64_t input_lwe_dimension; ::std::uint64_t internal_ks_output_lwe_dimension; ::std::uint64_t ks_decomposition_level_count; ::std::uint64_t ks_decomposition_base_log; ::std::uint64_t glwe_polynomial_size; ::std::uint64_t glwe_dimension; ::std::uint64_t br_decomposition_level_count; ::std::uint64_t br_decomposition_base_log; double complexity; double noise_max; double p_error; using IsRelocatable = ::std::true_type; }; #endif // CXXBRIDGE1_STRUCT_concrete_optimizer$v0$Solution } // namespace v0 namespace dag { #ifndef CXXBRIDGE1_STRUCT_concrete_optimizer$dag$DagSolution #define CXXBRIDGE1_STRUCT_concrete_optimizer$dag$DagSolution struct DagSolution final { ::std::uint64_t input_lwe_dimension; ::std::uint64_t internal_ks_output_lwe_dimension; ::std::uint64_t ks_decomposition_level_count; ::std::uint64_t ks_decomposition_base_log; ::std::uint64_t glwe_polynomial_size; ::std::uint64_t glwe_dimension; ::std::uint64_t br_decomposition_level_count; ::std::uint64_t br_decomposition_base_log; double complexity; double noise_max; double p_error; double global_p_error; bool use_wop_pbs; ::std::uint64_t cb_decomposition_level_count; ::std::uint64_t cb_decomposition_base_log; ::std::uint64_t pp_decomposition_level_count; ::std::uint64_t pp_decomposition_base_log; ::rust::Vec<::std::uint64_t> crt_decomposition; using IsRelocatable = ::std::true_type; }; #endif // CXXBRIDGE1_STRUCT_concrete_optimizer$dag$DagSolution } // namespace dag #ifndef CXXBRIDGE1_STRUCT_concrete_optimizer$Options #define CXXBRIDGE1_STRUCT_concrete_optimizer$Options struct Options final { ::std::uint64_t security_level; double maximum_acceptable_error_probability; double default_log_norm2_woppbs; bool use_gpu_constraints; ::concrete_optimizer::Encoding encoding; bool cache_on_disk; using IsRelocatable = ::std::true_type; }; #endif // CXXBRIDGE1_STRUCT_concrete_optimizer$Options namespace v0 { extern "C" { ::concrete_optimizer::v0::Solution concrete_optimizer$v0$cxxbridge1$optimize_bootstrap(::std::uint64_t precision, double noise_factor, ::concrete_optimizer::Options options) noexcept; } // extern "C" } // namespace v0 namespace utils { extern "C" { void concrete_optimizer$utils$cxxbridge1$convert_to_dag_solution(::concrete_optimizer::v0::Solution const &solution, ::concrete_optimizer::dag::DagSolution *return$) noexcept; } // extern "C" } // namespace utils extern "C" { ::std::size_t concrete_optimizer$cxxbridge1$OperationDag$operator$sizeof() noexcept; ::std::size_t concrete_optimizer$cxxbridge1$OperationDag$operator$alignof() noexcept; } // extern "C" namespace dag { extern "C" { ::concrete_optimizer::OperationDag *concrete_optimizer$dag$cxxbridge1$empty() noexcept; } // extern "C" } // namespace dag extern "C" { ::concrete_optimizer::dag::OperatorIndex concrete_optimizer$cxxbridge1$OperationDag$add_input(::concrete_optimizer::OperationDag &self, ::std::uint8_t out_precision, ::rust::Slice<::std::uint64_t const> out_shape) noexcept; ::concrete_optimizer::dag::OperatorIndex concrete_optimizer$cxxbridge1$OperationDag$add_lut(::concrete_optimizer::OperationDag &self, ::concrete_optimizer::dag::OperatorIndex input, ::rust::Slice<::std::uint64_t const> table, ::std::uint8_t out_precision) noexcept; ::concrete_optimizer::dag::OperatorIndex concrete_optimizer$cxxbridge1$OperationDag$add_dot(::concrete_optimizer::OperationDag &self, ::rust::Slice<::concrete_optimizer::dag::OperatorIndex const> inputs, ::concrete_optimizer::Weights *weights) noexcept; ::concrete_optimizer::dag::OperatorIndex concrete_optimizer$cxxbridge1$OperationDag$add_levelled_op(::concrete_optimizer::OperationDag &self, ::rust::Slice<::concrete_optimizer::dag::OperatorIndex const> inputs, double lwe_dim_cost_factor, double fixed_cost, double manp, ::rust::Slice<::std::uint64_t const> out_shape, ::rust::Str comment) noexcept; ::concrete_optimizer::dag::OperatorIndex concrete_optimizer$cxxbridge1$OperationDag$add_round_op(::concrete_optimizer::OperationDag &self, ::concrete_optimizer::dag::OperatorIndex input, ::std::uint8_t rounded_precision) noexcept; ::concrete_optimizer::v0::Solution concrete_optimizer$cxxbridge1$OperationDag$optimize_v0(::concrete_optimizer::OperationDag const &self, ::concrete_optimizer::Options options) noexcept; void concrete_optimizer$cxxbridge1$OperationDag$optimize(::concrete_optimizer::OperationDag const &self, ::concrete_optimizer::Options options, ::concrete_optimizer::dag::DagSolution *return$) noexcept; void concrete_optimizer$cxxbridge1$OperationDag$dump(::concrete_optimizer::OperationDag const &self, ::rust::String *return$) noexcept; ::std::size_t concrete_optimizer$cxxbridge1$Weights$operator$sizeof() noexcept; ::std::size_t concrete_optimizer$cxxbridge1$Weights$operator$alignof() noexcept; } // extern "C" namespace weights { extern "C" { ::concrete_optimizer::Weights *concrete_optimizer$weights$cxxbridge1$vector(::rust::Slice<::std::int64_t const> weights) noexcept; } // extern "C" } // namespace weights namespace v0 { ::concrete_optimizer::v0::Solution optimize_bootstrap(::std::uint64_t precision, double noise_factor, ::concrete_optimizer::Options options) noexcept { return concrete_optimizer$v0$cxxbridge1$optimize_bootstrap(precision, noise_factor, options); } } // namespace v0 namespace utils { ::concrete_optimizer::dag::DagSolution convert_to_dag_solution(::concrete_optimizer::v0::Solution const &solution) noexcept { ::rust::MaybeUninit<::concrete_optimizer::dag::DagSolution> return$; concrete_optimizer$utils$cxxbridge1$convert_to_dag_solution(solution, &return$.value); return ::std::move(return$.value); } } // namespace utils ::std::size_t OperationDag::layout::size() noexcept { return concrete_optimizer$cxxbridge1$OperationDag$operator$sizeof(); } ::std::size_t OperationDag::layout::align() noexcept { return concrete_optimizer$cxxbridge1$OperationDag$operator$alignof(); } namespace dag { ::rust::Box<::concrete_optimizer::OperationDag> empty() noexcept { return ::rust::Box<::concrete_optimizer::OperationDag>::from_raw(concrete_optimizer$dag$cxxbridge1$empty()); } } // namespace dag ::concrete_optimizer::dag::OperatorIndex OperationDag::add_input(::std::uint8_t out_precision, ::rust::Slice<::std::uint64_t const> out_shape) noexcept { return concrete_optimizer$cxxbridge1$OperationDag$add_input(*this, out_precision, out_shape); } ::concrete_optimizer::dag::OperatorIndex OperationDag::add_lut(::concrete_optimizer::dag::OperatorIndex input, ::rust::Slice<::std::uint64_t const> table, ::std::uint8_t out_precision) noexcept { return concrete_optimizer$cxxbridge1$OperationDag$add_lut(*this, input, table, out_precision); } ::concrete_optimizer::dag::OperatorIndex OperationDag::add_dot(::rust::Slice<::concrete_optimizer::dag::OperatorIndex const> inputs, ::rust::Box<::concrete_optimizer::Weights> weights) noexcept { return concrete_optimizer$cxxbridge1$OperationDag$add_dot(*this, inputs, weights.into_raw()); } ::concrete_optimizer::dag::OperatorIndex OperationDag::add_levelled_op(::rust::Slice<::concrete_optimizer::dag::OperatorIndex const> inputs, double lwe_dim_cost_factor, double fixed_cost, double manp, ::rust::Slice<::std::uint64_t const> out_shape, ::rust::Str comment) noexcept { return concrete_optimizer$cxxbridge1$OperationDag$add_levelled_op(*this, inputs, lwe_dim_cost_factor, fixed_cost, manp, out_shape, comment); } ::concrete_optimizer::dag::OperatorIndex OperationDag::add_round_op(::concrete_optimizer::dag::OperatorIndex input, ::std::uint8_t rounded_precision) noexcept { return concrete_optimizer$cxxbridge1$OperationDag$add_round_op(*this, input, rounded_precision); } ::concrete_optimizer::v0::Solution OperationDag::optimize_v0(::concrete_optimizer::Options options) const noexcept { return concrete_optimizer$cxxbridge1$OperationDag$optimize_v0(*this, options); } ::concrete_optimizer::dag::DagSolution OperationDag::optimize(::concrete_optimizer::Options options) const noexcept { ::rust::MaybeUninit<::concrete_optimizer::dag::DagSolution> return$; concrete_optimizer$cxxbridge1$OperationDag$optimize(*this, options, &return$.value); return ::std::move(return$.value); } ::rust::String OperationDag::dump() const noexcept { ::rust::MaybeUninit<::rust::String> return$; concrete_optimizer$cxxbridge1$OperationDag$dump(*this, &return$.value); return ::std::move(return$.value); } ::std::size_t Weights::layout::size() noexcept { return concrete_optimizer$cxxbridge1$Weights$operator$sizeof(); } ::std::size_t Weights::layout::align() noexcept { return concrete_optimizer$cxxbridge1$Weights$operator$alignof(); } namespace weights { ::rust::Box<::concrete_optimizer::Weights> vector(::rust::Slice<::std::int64_t const> weights) noexcept { return ::rust::Box<::concrete_optimizer::Weights>::from_raw(concrete_optimizer$weights$cxxbridge1$vector(weights)); } } // namespace weights } // namespace concrete_optimizer extern "C" { ::concrete_optimizer::OperationDag *cxxbridge1$box$concrete_optimizer$OperationDag$alloc() noexcept; void cxxbridge1$box$concrete_optimizer$OperationDag$dealloc(::concrete_optimizer::OperationDag *) noexcept; void cxxbridge1$box$concrete_optimizer$OperationDag$drop(::rust::Box<::concrete_optimizer::OperationDag> *ptr) noexcept; ::concrete_optimizer::Weights *cxxbridge1$box$concrete_optimizer$Weights$alloc() noexcept; void cxxbridge1$box$concrete_optimizer$Weights$dealloc(::concrete_optimizer::Weights *) noexcept; void cxxbridge1$box$concrete_optimizer$Weights$drop(::rust::Box<::concrete_optimizer::Weights> *ptr) noexcept; } // extern "C" namespace rust { inline namespace cxxbridge1 { template <> ::concrete_optimizer::OperationDag *Box<::concrete_optimizer::OperationDag>::allocation::alloc() noexcept { return cxxbridge1$box$concrete_optimizer$OperationDag$alloc(); } template <> void Box<::concrete_optimizer::OperationDag>::allocation::dealloc(::concrete_optimizer::OperationDag *ptr) noexcept { cxxbridge1$box$concrete_optimizer$OperationDag$dealloc(ptr); } template <> void Box<::concrete_optimizer::OperationDag>::drop() noexcept { cxxbridge1$box$concrete_optimizer$OperationDag$drop(this); } template <> ::concrete_optimizer::Weights *Box<::concrete_optimizer::Weights>::allocation::alloc() noexcept { return cxxbridge1$box$concrete_optimizer$Weights$alloc(); } template <> void Box<::concrete_optimizer::Weights>::allocation::dealloc(::concrete_optimizer::Weights *ptr) noexcept { cxxbridge1$box$concrete_optimizer$Weights$dealloc(ptr); } template <> void Box<::concrete_optimizer::Weights>::drop() noexcept { cxxbridge1$box$concrete_optimizer$Weights$drop(this); } } // namespace cxxbridge1 } // namespace rust