mirror of
https://github.com/zama-ai/concrete.git
synced 2026-02-08 19:44:57 -05:00
dep(optimizer): remove derive_more dependency
This commit is contained in:
@@ -8,7 +8,6 @@ edition = "2021"
|
||||
[dependencies]
|
||||
concrete-commons = { git = "ssh://git@github.com/zama-ai/concrete-core.git", rev = "715d4a18a59d13a5a51fee14bc1f6578de665c20" }
|
||||
concrete-npe = { git = "ssh://git@github.com/zama-ai/concrete-core.git", rev = "715d4a18a59d13a5a51fee14bc1f6578de665c20" }
|
||||
derive_more = "0.99.17"
|
||||
file-lock = "2.1.6"
|
||||
static_init = "1.0.3"
|
||||
serde = { version = "1.0", features = ["derive"] }
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
use crate::dag::operator::tensor::{ClearTensor, Shape};
|
||||
use derive_more::{Add, AddAssign};
|
||||
|
||||
pub type Weights = ClearTensor<i64>;
|
||||
|
||||
@@ -12,7 +11,7 @@ impl FunctionTable {
|
||||
pub const UNKWOWN: Self = Self { values: vec![] };
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, PartialEq, Add, AddAssign, Debug)]
|
||||
#[derive(Clone, Copy, PartialEq, Debug)]
|
||||
pub struct LevelledComplexity {
|
||||
pub lwe_dim_cost_factor: f64,
|
||||
pub fixed_cost: f64,
|
||||
@@ -35,6 +34,24 @@ impl LevelledComplexity {
|
||||
}
|
||||
}
|
||||
|
||||
impl std::ops::Add for LevelledComplexity {
|
||||
type Output = Self;
|
||||
|
||||
fn add(self, rhs: Self) -> Self::Output {
|
||||
Self {
|
||||
lwe_dim_cost_factor: self.lwe_dim_cost_factor + rhs.lwe_dim_cost_factor,
|
||||
fixed_cost: self.fixed_cost + rhs.fixed_cost,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl std::ops::AddAssign for LevelledComplexity {
|
||||
fn add_assign(&mut self, rhs: Self) {
|
||||
self.lwe_dim_cost_factor += rhs.lwe_dim_cost_factor;
|
||||
self.fixed_cost += rhs.fixed_cost;
|
||||
}
|
||||
}
|
||||
|
||||
impl std::ops::Mul<u64> for LevelledComplexity {
|
||||
type Output = Self;
|
||||
fn mul(self, factor: u64) -> Self {
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
use derive_more::{Add, AddAssign, Sum};
|
||||
use std::iter::Sum;
|
||||
|
||||
/**
|
||||
* A variance that is represented as a linear combination of base variances.
|
||||
* Only the linear coefficient are known.
|
||||
@@ -12,7 +13,7 @@ use derive_more::{Add, AddAssign, Sum};
|
||||
* Each linear coefficient is a variance factor.
|
||||
* There are homogenious to squared weight (or summed square weights or squared norm2).
|
||||
*/
|
||||
#[derive(Clone, Copy, Add, AddAssign, Sum, Debug, PartialEq, PartialOrd)]
|
||||
#[derive(Clone, Copy, Debug, PartialEq, PartialOrd)]
|
||||
pub struct SymbolicVariance {
|
||||
pub lut_coeff: f64,
|
||||
pub input_coeff: f64,
|
||||
@@ -31,6 +32,36 @@ pub enum VarianceOrigin {
|
||||
Mixed,
|
||||
}
|
||||
|
||||
impl std::ops::Add for SymbolicVariance {
|
||||
type Output = Self;
|
||||
|
||||
fn add(self, rhs: Self) -> Self::Output {
|
||||
Self {
|
||||
lut_coeff: self.lut_coeff + rhs.lut_coeff,
|
||||
input_coeff: self.input_coeff + rhs.input_coeff,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl std::ops::AddAssign for SymbolicVariance {
|
||||
fn add_assign(&mut self, rhs: Self) {
|
||||
self.lut_coeff += rhs.lut_coeff;
|
||||
self.input_coeff += rhs.input_coeff;
|
||||
}
|
||||
}
|
||||
|
||||
impl Sum for SymbolicVariance {
|
||||
fn sum<I: Iterator<Item = Self>>(iter: I) -> Self {
|
||||
let mut accumulator = Self::ZERO;
|
||||
|
||||
for item in iter {
|
||||
accumulator += item;
|
||||
}
|
||||
|
||||
accumulator
|
||||
}
|
||||
}
|
||||
|
||||
impl std::ops::Mul<f64> for SymbolicVariance {
|
||||
type Output = Self;
|
||||
fn mul(self, sq_weight: f64) -> Self {
|
||||
|
||||
Reference in New Issue
Block a user