From 11480f18f3f1bddc239f505aad74f985f30acaef Mon Sep 17 00:00:00 2001 From: Jia Date: Wed, 14 Apr 2021 10:49:19 +0800 Subject: [PATCH] Store operation into graph because the operation is a shared pointor, in app, the operation is created as: auto op = graph->CreateOperation(); uses natively think the operation had been register into the graph and would not manage the op locally. if running the graph in another fucntion instead of the function that create the operation, the operation would had been delete. so the operation should be stored into the graph. Signed-off-by: Jia --- include/tim/vx/graph.h | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/include/tim/vx/graph.h b/include/tim/vx/graph.h index cd17ef0..fb43bb3 100644 --- a/include/tim/vx/graph.h +++ b/include/tim/vx/graph.h @@ -33,6 +33,8 @@ namespace vx { class Tensor; class TensorSpec; +class Operation; + class Graph { public: virtual ~Graph() {} @@ -54,8 +56,13 @@ class Graph { template std::shared_ptr CreateOperation(Params... parameters) { - return std::make_shared(this, parameters...); + auto op = std::make_shared(this, parameters...); + opVector.push_back(op); + return op; } + +private: + std::vector> opVector; }; } // namespace vx