SWDEV-317925 - Fix for remove dependency issue

Change-Id: Ifbd3e9892f328d9c0d029c81d7bd08d9d444a318


[ROCm/clr commit: e34fd8abe1]
This commit is contained in:
Sarbojit Sarkar
2022-01-19 07:07:13 +00:00
committed by Sarbojit Sarkar
parent fe0a0d66a7
commit 3c42e9cd0f
2 changed files with 13 additions and 3 deletions
+3 -1
View File
@@ -1177,7 +1177,9 @@ hipError_t hipGraphRemoveDependencies(hipGraph_t graph, const hipGraphNode_t* fr
HIP_RETURN(hipErrorInvalidValue);
}
for (size_t i = 0; i < numDependencies; i++) {
from[i]->RemoveEdge(to[i]);
if (from[i]->RemoveEdge(to[i]) == false) {
HIP_RETURN(hipErrorInvalidValue);
}
}
HIP_RETURN(hipSuccess);
}
+10 -2
View File
@@ -163,8 +163,15 @@ struct hipGraphNode {
childNode->AddDependency(this);
}
/// Remove edge, update parent node outdegree, child node indegree, level and dependency
void RemoveEdge(const Node& childNode) {
edges_.erase(std::remove(edges_.begin(), edges_.end(), childNode), edges_.end());
bool RemoveEdge(const Node& childNode) {
// std::remove changes the end() hence saving it before hand for validation
auto currEdgeEnd = edges_.end();
auto it = std::remove(edges_.begin(), edges_.end(), childNode);
if (it == currEdgeEnd) {
// Should come here if childNode is not present in the edge list
return false;
}
edges_.erase(it, edges_.end());
outDegree_--;
childNode->SetInDegree(childNode->GetInDegree() - 1);
const std::vector<Node>& dependencies = childNode->GetDependencies();
@@ -176,6 +183,7 @@ struct hipGraphNode {
}
childNode->SetLevel(level);
childNode->RemoveDependency(this);
return true;
}
/// Get Runlist of the nodes embedded as part of the graphnode(e.g. ChildGraph)
virtual void GetRunList(std::vector<std::vector<Node>>& parallelList,