Skip to content

[Upd] replace() instead of replaceWith() in GraphView

Maxence Naud requested to merge fix/replaceWith into main

Description of replaceWith()

The replaceWith() member function works as follow:

  1. Select a set of Nodes to replace
  2. Create a GraphView from this set. (let's call it g)
  3. Select a set of new Nodes and solve their input connections (let's call it newNodes)
  4. run g.replaceWith(newNodes)
  5. Nodes are replaced in every GraphView pointing at them all

Issue

  1. It may be confusing to create a new GraphView from the set of Nodes to replace and replace it by another set of Nodes and not a GraphView
  2. Input connections are not handled at all
  3. Output connections are handled and authorized only if obvious

Solution

Change replaceWith() by replace()

GraphView::replace(std::set<std::shared_ptr<Node>> oldNodes, std::set<std::shared_ptr<Node>> newNodes);

  1. symetric handling of old/new Nodes
  2. automatically recreate input AND output connections if obvious (one connection or every input pointing to the same Tensor)
Edited by Vincent Templier

Merge request reports

Loading