Computes the set of nodes that need resharing of their output
(
&mut self,
graph: &Graph,
private_nodes: &HashSet<Node>,
)
| 77 | |
| 78 | // Computes the set of nodes that need resharing of their output |
| 79 | fn compute_graph_resharing( |
| 80 | &mut self, |
| 81 | graph: &Graph, |
| 82 | private_nodes: &HashSet<Node>, |
| 83 | ) -> Result<()> { |
| 84 | self.nodes_to_reshare = HashSet::new(); |
| 85 | // nodes that contain 3-out-of-3 shares |
| 86 | // All the other shared nodes have 2-out-of-3 shares |
| 87 | self.unreshared_nodes = HashSet::new(); |
| 88 | |
| 89 | for node in graph.get_nodes() { |
| 90 | // if node is public, no resharing is needed |
| 91 | if !private_nodes.contains(&node) { |
| 92 | continue; |
| 93 | } |
| 94 | let op = node.get_operation(); |
| 95 | if !op.is_mpc_compiled() { |
| 96 | return Err(runtime_error!("This operation shouldn't be MPC compiled")); |
| 97 | } |
| 98 | match op { |
| 99 | Operation::Input(_) |
| 100 | => { |
| 101 | // No resharing is needed |
| 102 | } |
| 103 | Operation::Add |
| 104 | | Operation::Subtract |
| 105 | | Operation::Sum(_) |
| 106 | | Operation::CumSum(_) |
| 107 | | Operation::Get(_) |
| 108 | | Operation::Stack(_) |
| 109 | | Operation::Concatenate(_) |
| 110 | | Operation::Reshape(_) |
| 111 | | Operation::PermuteAxes(_) |
| 112 | | Operation::Zip |
| 113 | | Operation::Repeat(_) |
| 114 | | Operation::TupleGet(_) |
| 115 | | Operation::CreateNamedTuple(_) |
| 116 | | Operation::NamedTupleGet(_) |
| 117 | | Operation::VectorToArray |
| 118 | | Operation::VectorGet |
| 119 | | Operation::CreateTuple |
| 120 | | Operation::ArrayToVector |
| 121 | | Operation::CreateVector(_) => { |
| 122 | self.local_operation_handler(node)?; |
| 123 | } |
| 124 | Operation::Multiply |
| 125 | | Operation::Dot |
| 126 | | Operation::Matmul |
| 127 | | Operation::Gemm(_, _) => { |
| 128 | let dependencies = node.get_node_dependencies(); |
| 129 | |
| 130 | let mut all_inputs_are_shared = true; |
| 131 | for dep_node in &dependencies { |
| 132 | if !private_nodes.contains(dep_node) { |
| 133 | all_inputs_are_shared = false; |
| 134 | } |
| 135 | } |
| 136 |
no test coverage detected