Skip to content

Commit

Permalink
allow parallel edges in merge prim func
Browse files Browse the repository at this point in the history
  • Loading branch information
zhen8838 committed Mar 3, 2025
1 parent c0312cf commit 7b64c5a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Nncase.Graph/Graphs/CondensationGraphAlgorithm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public CondensationGraphAlgorithm(IEdgeListAndIncidenceGraph<TVertex, TEdge> vis
: base(visitedGraph)
{
CondensedGraph = new(true);
WrappedGraph = new(false);
WrappedGraph = new(true);
ClusteredGraph = new(WrappedGraph);
VertexMap = new Dictionary<TVertex, ClusteredBidirectionalGraph<TVertex, TEdge>>();
EdgeMap = new(ReferenceEqualityComparer.Instance);
Expand Down
7 changes: 7 additions & 0 deletions src/Nncase.Passes/GraphPartition/ExprReConstructor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,14 @@ public Expr Construct()
protected virtual IEnumerable<(Expr Pre, Expr Post)> GetClusterArgumentPairs(ClusteredBidirectionalGraph<TVertex, TEdge> cluster)
{
var pairs = new List<(Expr Pre, Expr Post)>();
var preSet = new HashSet<Expr>(ReferenceEqualityComparer.Instance);
foreach (var inEdge in cluster.InEdges(Algo.ClusteredGraph))
{
if (preSet.Contains(inEdge.Source.Expr))
{
continue;
}

// get in Expr
Expr postArg;
var sourceCluster = Algo.VertexMap[inEdge.Source];
Expand All @@ -57,6 +63,7 @@ public Expr Construct()
postArg = postResult is IR.Tuple tp ? tp.Fields[sourceOutIndex] : IR.F.Tensors.GetItem(postResult, sourceOutIndex);
}

preSet.Add(inEdge.Source.Expr);
pairs.Add((inEdge.Source.Expr, postArg));
}

Expand Down

0 comments on commit 7b64c5a

Please sign in to comment.