tf-encrypted / moose

Secure distributed dataflow framework for encrypted machine learning and data processing

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Elk memory: avoid cloning all operations in `toposort`

mortendahl opened this issue · comments

toposort is currently cloning operations as part of constructing its output:

 pub fn toposort(&self) -> Result<NamedComputation> {
    let graph = self.as_graph();
    let toposort = toposort(&graph, None).map_err(|_| {
        Error::MalformedComputation("There is a cycle detected in the runtime graph".into())
    })?;

    let operations = toposort
        .iter()
        .map(|node| self.operations[graph[*node].1].clone())
        .collect();
    ...

Maybe there's a way this can be avoided by eg consuming comp instead.

It would be nice to rearrange self.operations according to toposort, but couldn't find straight-forward way of doing this.