removed is_multiplication from operatoin trait

This commit is contained in:
Matthew Liu
2023-07-31 19:44:49 -07:00
parent 6e2676b079
commit 2ef629d7ab
10 changed files with 10 additions and 42 deletions

View File

@@ -142,13 +142,6 @@ impl OperationTrait for FheOperation {
fn is_ordered(&self) -> bool {
false
}
fn is_multiplication(&self) -> bool {
matches!(
self,
FheOperation::Multiply | FheOperation::MultiplyPlaintext
)
}
}
/**

View File

@@ -282,6 +282,11 @@ pub type ZkpApplication = Application<Zkp>;
*/
pub type FheZkpApplication = Application<FheZkp>;
type Group = String;
/**
* Allows for abstract interaction with a context group stack.
*/
pub enum ContextEnum {
Fhe(FheContext),
Zkp(ZkpContext),

View File

@@ -151,10 +151,6 @@ impl OperationTrait for Operation {
fn is_ordered(&self) -> bool {
matches!(self, Operation::InvokeGadget(_))
}
fn is_multiplication(&self) -> bool {
matches!(self, Operation::Mul)
}
}
impl Operation {

View File

@@ -586,10 +586,6 @@ mod tests {
fn is_ordered(&self) -> bool {
false
}
fn is_multiplication(&self) -> bool {
matches!(self, Self::Mul)
}
}
type TestGraph = Context<Operation, ()>;

View File

@@ -78,10 +78,6 @@ pub trait Operation: Clone + Debug + Hash + PartialEq + Eq {
*/
fn is_ordered(&self) -> bool;
/**
* Whether or not this operation involves a multiplication.
*/
fn is_multiplication(&self) -> bool;
}
/**

View File

@@ -175,9 +175,6 @@ mod tests {
false
}
fn is_multiplication(&self) -> bool {
matches!(self, Operation::Mul)
}
}
fn get_graph() -> CompilationResult<Operation> {

View File

@@ -4,7 +4,6 @@ use sunscreen_compiler_common::Operation as OperationTrait;
use crate::Literal;
#[derive(Debug, Clone, Serialize, Hash, Deserialize, PartialEq, Eq)]
//#[serde(tag = "type")]
/**
* An operation in the execution graph.
*/
@@ -150,7 +149,4 @@ impl OperationTrait for Operation {
false
}
fn is_multiplication(&self) -> bool {
matches!(self, Self::Multiply | Self::MultiplyPlaintext)
}
}

View File

@@ -43,9 +43,7 @@ pub struct BfvNodeType {
/**
* Gets the multiplicative depth of a node in the compilation graph.
*/
pub fn get_mult_depth<O>(graph: &StableGraph<NodeInfo<O>, EdgeInfo>, start_node: NodeIndex) -> u64
where
O: OperationTrait,
pub fn get_mult_depth(graph: &StableGraph<NodeInfo<FheOperation>, EdgeInfo>, start_node: NodeIndex) -> u64
{
let mut queue: VecDeque<(NodeIndex, u64)> = VecDeque::new();
let mut visited: HashMap<NodeIndex, bool> = HashMap::new();
@@ -57,12 +55,10 @@ where
while let Some((node, depth)) = queue.pop_front() {
visited.insert(node, true);
let curr_depth = depth
+ graph
.node_weight(node)
.unwrap()
.operation
.is_multiplication() as u64;
let curr_depth = match graph.node_weight(node).unwrap().operation {
FheOperation::Multiply => depth + 1,
_ => depth
};
max_depth = max_depth.max(curr_depth);

View File

@@ -45,9 +45,6 @@ impl OperationTrait for Operation {
false
}
fn is_multiplication(&self) -> bool {
matches!(self, Operation::Mul)
}
}
/**

View File

@@ -178,10 +178,6 @@ impl OperationTrait for Operation {
fn is_ordered(&self) -> bool {
matches!(self, Operation::InvokeGadget(_))
}
fn is_multiplication(&self) -> bool {
matches!(self, Operation::Mul)
}
}
/**