SWDEV-386685 - return proper error
- if graph is already instantiated there cant be a second instance in case nodes are free or alloc Signed-off-by: sdashmiz <shadi.dashmiz@amd.com> Change-Id: I51e2ca8ade24799da96ed126a26c5ea3bad6f452
This commit is contained in:
@@ -1218,12 +1218,20 @@ hipError_t hipGraphAddChildGraphNode(hipGraphNode_t* pGraphNode, hipGraph_t grap
|
||||
hipError_t ihipGraphInstantiate(hipGraphExec_t* pGraphExec, hipGraph_t graph,
|
||||
uint64_t flags = 0) {
|
||||
if (pGraphExec == nullptr || graph == nullptr) {
|
||||
HIP_RETURN(hipErrorInvalidValue);
|
||||
return hipErrorInvalidValue;
|
||||
}
|
||||
if (graph->IsGraphInstantiated() == true) {
|
||||
for (auto node : graph->GetNodes()) {
|
||||
if ((node->GetType() == hipGraphNodeTypeMemAlloc)
|
||||
|| (node->GetType() == hipGraphNodeTypeMemFree)) {
|
||||
return hipErrorNotSupported;
|
||||
}
|
||||
}
|
||||
}
|
||||
std::unordered_map<Node, Node> clonedNodes;
|
||||
hipGraph_t clonedGraph = graph->clone(clonedNodes);
|
||||
if (clonedGraph == nullptr) {
|
||||
HIP_RETURN(hipErrorInvalidValue);
|
||||
return hipErrorInvalidValue;
|
||||
}
|
||||
std::vector<std::vector<Node>> parallelLists;
|
||||
std::unordered_map<Node, std::vector<Node>> nodeWaitLists;
|
||||
@@ -1236,6 +1244,7 @@ hipError_t ihipGraphInstantiate(hipGraphExec_t* pGraphExec, hipGraph_t graph,
|
||||
new hipGraphExec(levelOrder, parallelLists, nodeWaitLists, clonedNodes,
|
||||
graphExeUserObj, flags);
|
||||
if (*pGraphExec != nullptr) {
|
||||
graph->SetGraphInstantiated(true);
|
||||
return (*pGraphExec)->Init();
|
||||
} else {
|
||||
return hipErrorOutOfMemory;
|
||||
|
||||
@@ -398,6 +398,7 @@ struct ihipGraph {
|
||||
hip::Device* device_; //!< HIP device object
|
||||
hip::MemoryPool* mem_pool_; //!< Memory pool, associated with this graph
|
||||
std::unordered_set<hipGraphNode*> capturedNodes_;
|
||||
bool graphInstantiated_;
|
||||
|
||||
public:
|
||||
ihipGraph(hip::Device* device, const ihipGraph* original = nullptr)
|
||||
@@ -408,6 +409,7 @@ struct ihipGraph {
|
||||
graphSet_.insert(this);
|
||||
mem_pool_ = device->GetGraphMemoryPool();
|
||||
mem_pool_->retain();
|
||||
graphInstantiated_ = false;
|
||||
}
|
||||
|
||||
~ihipGraph() {
|
||||
@@ -529,6 +531,14 @@ struct ihipGraph {
|
||||
void FreeAllMemory() {
|
||||
mem_pool_->FreeAllMemory();
|
||||
}
|
||||
|
||||
bool IsGraphInstantiated() const {
|
||||
return graphInstantiated_;
|
||||
}
|
||||
|
||||
void SetGraphInstantiated(bool graphInstantiate) {
|
||||
graphInstantiated_ = graphInstantiate;
|
||||
}
|
||||
};
|
||||
|
||||
struct hipGraphExec {
|
||||
|
||||
Reference in New Issue
Block a user