MCPcopy Create free account
hub / github.com/ciphermodelabs/ciphercore / sanity_pass

Method sanity_pass

ciphercore-base/src/mpc/resharing.rs:186–233  ·  view source on GitHub ↗

Check that nodes marked as "to be reshared" have input 3-out-of-3 nodes. If not, they don't need resharing.

(&mut self, graph: &Graph, shared_nodes: &HashSet<Node>)

Source from the content-addressed store, hash-verified

184 // Check that nodes marked as "to be reshared" have input 3-out-of-3 nodes.
185 // If not, they don't need resharing.
186 fn sanity_pass(&mut self, graph: &Graph, shared_nodes: &HashSet<Node>) -> Result<()> {
187 for node in graph.get_nodes() {
188 match node.get_operation() {
189 Operation::Multiply
190 | Operation::Matmul
191 | Operation::Dot
192 | Operation::Gemm(_, _) => {
193 let dependencies = node.get_node_dependencies();
194
195 let mut all_inputs_are_shared = true;
196 for dep_node in &dependencies {
197 if !shared_nodes.contains(dep_node) {
198 all_inputs_are_shared = false;
199 }
200 }
201
202 if all_inputs_are_shared {
203 continue;
204 }
205 }
206 _ => {}
207 }
208 if self.nodes_to_reshare.contains(&node) {
209 let mut node_should_be_reshared = false;
210 for dep in node.get_node_dependencies() {
211 if self.unreshared_nodes.contains(&dep) {
212 node_should_be_reshared = true;
213 }
214 }
215 if !node_should_be_reshared {
216 self.nodes_to_reshare.remove(&node);
217 }
218 }
219 if self.unreshared_nodes.contains(&node) {
220 let mut node_is_unreshared = false;
221 for dep in node.get_node_dependencies() {
222 if self.unreshared_nodes.contains(&dep) {
223 node_is_unreshared = true;
224 }
225 }
226 if !node_is_unreshared {
227 self.unreshared_nodes.remove(&node);
228 }
229 }
230 }
231
232 Ok(())
233 }
234}
235
236pub(super) fn get_nodes_to_reshare(

Callers 1

Calls 4

get_node_dependenciesMethod · 0.80
get_nodesMethod · 0.45
get_operationMethod · 0.45
removeMethod · 0.45

Tested by

no test coverage detected