From 1f2c287b85d295a97ed5e66ef5ba1aac0574c872 Mon Sep 17 00:00:00 2001 From: =?utf8?q?=EC=9E=A5=EC=A7=80=EC=84=AD/On-Device=20Lab=28SR=29/Enginee?= =?utf8?q?r/=EC=82=BC=EC=84=B1=EC=A0=84=EC=9E=90?= Date: Tue, 26 Mar 2019 13:56:41 +0900 Subject: [PATCH] [neurun] Move out of the graph of neurun to collect the model's information (#4838) This commit moves out of the graph of neurun to collect the model's infomation. Signed-off-by: jiseob.jang --- runtimes/neurun/core/include/graph/Graph.h | 5 +- runtimes/neurun/core/src/graph/Graph.cc | 5 +- .../neurun/frontend/nnapi/wrapper/compilation.h | 2 +- runtimes/neurun/frontend/nnapi/wrapper/model.cc | 46 +++++++++--------- runtimes/neurun/frontend/nnapi/wrapper/model.h | 7 +-- runtimes/neurun/test/graph/Graph.cc | 29 ++++++------ runtimes/neurun/test/graph/operand/UseDef.cc | 30 ++++++------ runtimes/neurun/test/graph/operation/SetIO.cc | 27 +++++------ runtimes/neurun/test/graph/verifier/Verifier.cc | 22 +++++---- runtimes/neurun/test/interp/ExecManager.cc | 54 ++++++++++++---------- 10 files changed, 124 insertions(+), 103 deletions(-) diff --git a/runtimes/neurun/core/include/graph/Graph.h b/runtimes/neurun/core/include/graph/Graph.h index 89e1f3a..0843ffb 100644 --- a/runtimes/neurun/core/include/graph/Graph.h +++ b/runtimes/neurun/core/include/graph/Graph.h @@ -107,7 +107,8 @@ public: using PostDfsConstIterator = PostDfsIterator; public: - Graph(void); + Graph(void) = delete; + Graph(std::unique_ptr &&model); ~Graph(void); // Graph Building @@ -151,7 +152,7 @@ public: private: Phase _phase{Phase::BUILDING}; - std::shared_ptr _model{new model::Model}; + std::shared_ptr _model; // For LOWERED phase public: diff --git a/runtimes/neurun/core/src/graph/Graph.cc b/runtimes/neurun/core/src/graph/Graph.cc index ae2f803..f806503 100644 --- a/runtimes/neurun/core/src/graph/Graph.cc +++ b/runtimes/neurun/core/src/graph/Graph.cc @@ -36,7 +36,10 @@ namespace neurun namespace graph { -Graph::Graph(void) = default; +Graph::Graph(std::unique_ptr &&model) : _model{std::move(model)} +{ + // DO NOTHING +} Graph::~Graph(void) = default; diff --git a/runtimes/neurun/frontend/nnapi/wrapper/compilation.h b/runtimes/neurun/frontend/nnapi/wrapper/compilation.h index 1e82cc5..7a4ee98 100644 --- a/runtimes/neurun/frontend/nnapi/wrapper/compilation.h +++ b/runtimes/neurun/frontend/nnapi/wrapper/compilation.h @@ -24,7 +24,7 @@ struct ANeuralNetworksCompilation { public: - ANeuralNetworksCompilation(const std::shared_ptr &model) noexcept; + ANeuralNetworksCompilation(const std::shared_ptr &graph) noexcept; public: bool finish() noexcept; diff --git a/runtimes/neurun/frontend/nnapi/wrapper/model.cc b/runtimes/neurun/frontend/nnapi/wrapper/model.cc index f0f0911..77e883f 100644 --- a/runtimes/neurun/frontend/nnapi/wrapper/model.cc +++ b/runtimes/neurun/frontend/nnapi/wrapper/model.cc @@ -27,7 +27,7 @@ // ANeuralNetworksModel // ANeuralNetworksModel::ANeuralNetworksModel() noexcept - : _model{new neurun::graph::Graph}, _optional_operands{} + : _model{new neurun::model::Model}, _graph{nullptr}, _optional_operands{} { // DO NOTHING } @@ -38,7 +38,7 @@ bool ANeuralNetworksModel::addOperand(const ANeuralNetworksOperandType *type) no { const auto shape = NNAPIConvert::getShape(type); const auto typeInfo = NNAPIConvert::getTypeInfo(type); - _model->addOperand(shape, typeInfo); + _model->operands.append(shape, typeInfo); } catch (const std::exception &e) { @@ -57,7 +57,7 @@ bool ANeuralNetworksModel::setOperandValue(uint32_t index, const void *buffer, s try { - _model->operands().at(ind).usage(neurun::model::operand::Usage::CONSTANT); + _model->operands.at(ind).usage(neurun::model::operand::Usage::CONSTANT); // Remain operands.at(ind).data()->base() as nullptr for optional operand // This will be filled when model finished @@ -70,13 +70,13 @@ bool ANeuralNetworksModel::setOperandValue(uint32_t index, const void *buffer, s using ::neurun::model::operand::ExternalData; if (copy) { - _model->setOperandValue(ind, nnfw::cpp14::make_unique( - reinterpret_cast(buffer), length)); + _model->operands.at(ind).data( + nnfw::cpp14::make_unique(reinterpret_cast(buffer), length)); } else { - _model->setOperandValue(ind, nnfw::cpp14::make_unique( - reinterpret_cast(buffer), length)); + _model->operands.at(ind).data(nnfw::cpp14::make_unique( + reinterpret_cast(buffer), length)); } } catch (const std::exception &e) @@ -98,14 +98,14 @@ bool ANeuralNetworksModel::addOperation(ANeuralNetworksOperationType type, uint3 for (uint32_t i = 0; i < outputCount; i++) { const neurun::model::operand::Index ind{outputs[i]}; - _model->operands().at(ind).usage(neurun::model::operand::Usage::OPERATION_OUTPUT); + _model->operands.at(ind).usage(neurun::model::operand::Usage::OPERATION_OUTPUT); } auto &factory = OperationFactory::instance(); OperationFactory::Param param{inputCount, inputs, outputCount, outputs}; auto node = factory.create(type, param); - _model->addOperation(std::unique_ptr{node}); + _model->operations.append(std::unique_ptr{node}); } catch (const std::exception &e) { @@ -126,14 +126,14 @@ bool ANeuralNetworksModel::addOperationEx(ANeuralNetworksOperationTypeEx type, u for (uint32_t i = 0; i < outputCount; i++) { const neurun::model::operand::Index ind{outputs[i]}; - _model->operands().at(ind).usage(neurun::model::operand::Usage::OPERATION_OUTPUT); + _model->operands.at(ind).usage(neurun::model::operand::Usage::OPERATION_OUTPUT); } auto &factory = OperationFactory::instance(); OperationFactory::Param param{inputCount, inputs, outputCount, outputs}; auto node = factory.create(type, param); - _model->addOperation(std::unique_ptr{node}); + _model->operations.append(std::unique_ptr{node}); } catch (const std::exception &e) { @@ -147,8 +147,8 @@ bool ANeuralNetworksModel::addModelInput(uint32_t index) noexcept try { const neurun::model::operand::Index ind{index}; - _model->operands().at(ind).usage(neurun::model::operand::Usage::MODEL_INPUT); - _model->addInput(ind); + _model->operands.at(ind).usage(neurun::model::operand::Usage::MODEL_INPUT); + _model->inputs.append(ind); } catch (const std::exception &e) { @@ -166,12 +166,12 @@ bool ANeuralNetworksModel::addModelOutput(uint32_t index) noexcept const neurun::model::operand::Index ind{index}; // Duplicated output is not allowed - if (_model->getOutputs().contains(ind)) + if (_model->outputs.contains(ind)) { return false; } - _model->addOutput(ind); + _model->outputs.append(ind); } catch (const std::exception &e) { @@ -189,7 +189,9 @@ bool ANeuralNetworksModel::finish() noexcept { fillOptionalOperand(); - _model->finishBuilding(); + _graph = std::make_shared(std::move(_model)); + + _graph->finishBuilding(); } catch (const std::exception &e) { @@ -201,27 +203,27 @@ bool ANeuralNetworksModel::finish() noexcept return true; } -bool ANeuralNetworksModel::isFinished() noexcept { return !_model->isBuildingPhase(); } +bool ANeuralNetworksModel::isFinished() noexcept { return _graph != nullptr; } bool ANeuralNetworksModel::isExistOperand(uint32_t index) noexcept { - return _model->operands().exist(neurun::model::operand::Index{index}); + return _model->operands.exist(neurun::model::operand::Index{index}); } size_t ANeuralNetworksModel::operandSize(uint32_t index) noexcept { - return _model->operands().at(neurun::model::operand::Index{index}).operandSize(); + return _model->operands.at(neurun::model::operand::Index{index}).operandSize(); } bool ANeuralNetworksModel::isUsageSet(uint32_t index) noexcept { - return _model->operands().at(neurun::model::operand::Index{index}).usageIsDefined(); + return _model->operands.at(neurun::model::operand::Index{index}).usageIsDefined(); } bool ANeuralNetworksModel::isOperationOutput(uint32_t index) noexcept { const neurun::model::operand::Index ind{index}; - return (_model->operands().at(ind).usage() == neurun::model::operand::Usage::OPERATION_OUTPUT); + return (_model->operands.at(ind).usage() == neurun::model::operand::Usage::OPERATION_OUTPUT); } void ANeuralNetworksModel::setOptionalOperand(const neurun::model::operand::Index idx) @@ -231,7 +233,7 @@ void ANeuralNetworksModel::setOptionalOperand(const neurun::model::operand::Inde void ANeuralNetworksModel::fillOptionalOperand(void) { - _model->operations().iterate( + _model->operations.iterate( [&](const ::neurun::model::operation::Index &, ::neurun::model::operation::Node &node) { for (auto input : node.getInputs()) { diff --git a/runtimes/neurun/frontend/nnapi/wrapper/model.h b/runtimes/neurun/frontend/nnapi/wrapper/model.h index 129604d..0a25512 100644 --- a/runtimes/neurun/frontend/nnapi/wrapper/model.h +++ b/runtimes/neurun/frontend/nnapi/wrapper/model.h @@ -41,20 +41,21 @@ public: bool addModelOutput(uint32_t index) noexcept; bool finish() noexcept; - neurun::graph::Graph &deref(void) { return *_model; } + neurun::graph::Graph &deref(void) { return *_graph; } bool isFinished() noexcept; bool isExistOperand(uint32_t index) noexcept; size_t operandSize(uint32_t index) noexcept; bool isUsageSet(uint32_t index) noexcept; bool isOperationOutput(uint32_t index) noexcept; - void release(std::shared_ptr &model) { model = _model; } + void release(std::shared_ptr &graph) { graph = _graph; } private: void setOptionalOperand(const neurun::model::operand::Index idx); void fillOptionalOperand(void); private: - std::shared_ptr _model; + std::unique_ptr _model; + std::shared_ptr _graph; std::unordered_set _optional_operands; }; diff --git a/runtimes/neurun/test/graph/Graph.cc b/runtimes/neurun/test/graph/Graph.cc index e6db3fe..9b5cf3e 100644 --- a/runtimes/neurun/test/graph/Graph.cc +++ b/runtimes/neurun/test/graph/Graph.cc @@ -16,37 +16,38 @@ #include -#include "graph/Graph.h" +#include "model/Model.h" +// TODO Change name to Model TEST(Graph, inputs_and_outputs) { - ::neurun::graph::Graph graph; + ::neurun::model::Model model; ::neurun::model::operand::Index index0{0u}; ::neurun::model::operand::Index index1{1u}; - graph.addInput({index0}); - graph.addInput({index1}); + model.inputs.append({index0}); + model.inputs.append({index1}); ::neurun::model::operand::Index index10{10u}; ::neurun::model::operand::Index index11{11u}; ::neurun::model::operand::Index index12{12u}; - graph.addOutput({index10}); - graph.addOutput({index11}); - graph.addOutput({index12}); + model.outputs.append({index10}); + model.outputs.append({index11}); + model.outputs.append({index12}); - ASSERT_EQ(graph.getInputs().size(), 2); - ASSERT_EQ(graph.getOutputs().size(), 3); + ASSERT_EQ(model.inputs.size(), 2); + ASSERT_EQ(model.outputs.size(), 3); ::neurun::model::operand::IO::Index io_index0{0}; ::neurun::model::operand::IO::Index io_index1{1}; ::neurun::model::operand::IO::Index io_index2{2}; - ASSERT_EQ(graph.getInputs().at(io_index0), 0); - ASSERT_EQ(graph.getInputs().at(io_index1), 1); + ASSERT_EQ(model.inputs.at(io_index0), 0); + ASSERT_EQ(model.inputs.at(io_index1), 1); - ASSERT_EQ(graph.getOutputs().at(io_index0), 10); - ASSERT_EQ(graph.getOutputs().at(io_index1), 11); - ASSERT_EQ(graph.getOutputs().at(io_index2), 12); + ASSERT_EQ(model.outputs.at(io_index0), 10); + ASSERT_EQ(model.outputs.at(io_index1), 11); + ASSERT_EQ(model.outputs.at(io_index2), 12); } diff --git a/runtimes/neurun/test/graph/operand/UseDef.cc b/runtimes/neurun/test/graph/operand/UseDef.cc index fd451c1..6129a29 100644 --- a/runtimes/neurun/test/graph/operand/UseDef.cc +++ b/runtimes/neurun/test/graph/operand/UseDef.cc @@ -20,6 +20,7 @@ #include "graph/verifier/Verifier.h" #include "cpp14/memory.h" #include "../MockNode.h" +#include "model/Model.h" #include @@ -33,7 +34,7 @@ using MockNode = neurun_test::graph::SimpleMockNode; TEST(graph_operand_usedef, usedef_test) { - neurun::graph::Graph graph; + std::unique_ptr model = nnfw::cpp14::make_unique(); neurun::graph::verifier::DAGChecker verifier; neurun::model::operand::Shape shape{1u}; @@ -41,30 +42,31 @@ TEST(graph_operand_usedef, usedef_test) shape.dim(0) = 3; // Model Input/Output - auto input_operand = graph.addOperand(shape, type); - auto output_operand = graph.addOperand(shape, type); + auto input_operand = model->operands.append(shape, type); + auto output_operand = model->operands.append(shape, type); - graph.addInput(input_operand); - graph.operands().at(input_operand).usage(neurun::model::operand::Usage::MODEL_INPUT); - graph.addOutput(output_operand); - graph.operands().at(output_operand).usage(neurun::model::operand::Usage::OPERATION_OUTPUT); + model->inputs.append(input_operand); + model->operands.at(input_operand).usage(neurun::model::operand::Usage::MODEL_INPUT); + model->outputs.append(output_operand); + model->operands.at(output_operand).usage(neurun::model::operand::Usage::OPERATION_OUTPUT); // MockNode1 - auto operand_index1 = graph.addOperand(shape, type); - graph.operands().at(operand_index1).usage(neurun::model::operand::Usage::OPERATION_OUTPUT); - auto mocknode_index1 = graph.addOperation( + auto operand_index1 = model->operands.append(shape, type); + model->operands.at(operand_index1).usage(neurun::model::operand::Usage::OPERATION_OUTPUT); + auto mocknode_index1 = model->operations.append( nnfw::cpp14::make_unique(IndexSet{input_operand}, IndexSet{operand_index1})); // MockNode2 - auto operand_index2 = graph.addOperand(shape, type); - graph.operands().at(operand_index2).usage(neurun::model::operand::Usage::OPERATION_OUTPUT); - auto mocknode_index2 = graph.addOperation( + auto operand_index2 = model->operands.append(shape, type); + model->operands.at(operand_index2).usage(neurun::model::operand::Usage::OPERATION_OUTPUT); + auto mocknode_index2 = model->operations.append( nnfw::cpp14::make_unique(IndexSet{input_operand}, IndexSet{operand_index2})); // MockNode3(two input) - auto multiinput_index = graph.addOperation(nnfw::cpp14::make_unique( + auto multiinput_index = model->operations.append(nnfw::cpp14::make_unique( IndexSet{operand_index1, operand_index2}, IndexSet{output_operand})); + neurun::graph::Graph graph{std::move(model)}; graph.finishBuilding(); ASSERT_EQ(verifier.verify(graph), true); diff --git a/runtimes/neurun/test/graph/operation/SetIO.cc b/runtimes/neurun/test/graph/operation/SetIO.cc index ec57774..68a3fbe 100644 --- a/runtimes/neurun/test/graph/operation/SetIO.cc +++ b/runtimes/neurun/test/graph/operation/SetIO.cc @@ -17,6 +17,7 @@ #include #include "graph/Graph.h" +#include "model/Model.h" #include "model/operand/Index.h" #include "model/operand/IndexSet.h" #include "model/operation/Conv2DNode.h" @@ -31,7 +32,7 @@ using IndexSet = neurun::model::operand::IndexSet; TEST(graph_operation_setIO, operation_setIO_conv) { - neurun::graph::Graph graph; + neurun::model::Model model; neurun::model::operand::Shape shape{1u}; neurun::model::operand::TypeInfo type{neurun::model::operand::DataType::TENSOR_INT32, 0, 0}; @@ -40,19 +41,19 @@ TEST(graph_operation_setIO, operation_setIO_conv) // Add Conv using GraphNode = neurun::model::operation::Conv2DNode; - auto input_operand = graph.addOperand(shape, type); - auto kernel_operand = graph.addOperand(shape, type); - auto bias_operand = graph.addOperand(shape, type); + auto input_operand = model.operands.append(shape, type); + auto kernel_operand = model.operands.append(shape, type); + auto bias_operand = model.operands.append(shape, type); IndexSet inputs{input_operand, kernel_operand, bias_operand}; GraphNode::Param conv_params; conv_params.explicit_padding = false; - conv_params.padding_code_index = graph.addOperand(shape, type); - conv_params.hstride_index = graph.addOperand(shape, type); - conv_params.vstride_index = graph.addOperand(shape, type); - conv_params.activation_index = graph.addOperand(shape, type); + conv_params.padding_code_index = model.operands.append(shape, type); + conv_params.hstride_index = model.operands.append(shape, type); + conv_params.vstride_index = model.operands.append(shape, type); + conv_params.activation_index = model.operands.append(shape, type); - auto output_operand = graph.addOperand(shape, type).value(); + auto output_operand = model.operands.append(shape, type).value(); IndexSet outputs{output_operand}; auto conv = nnfw::cpp14::make_unique(inputs, outputs, conv_params); @@ -66,7 +67,7 @@ TEST(graph_operation_setIO, operation_setIO_conv) TEST(graph_operation_setIO, operation_setIO_concat) { - neurun::graph::Graph graph; + neurun::model::Model model; neurun::model::operand::Shape shape{1u}; neurun::model::operand::TypeInfo type{neurun::model::operand::DataType::TENSOR_INT32, 0, 0}; @@ -78,13 +79,13 @@ TEST(graph_operation_setIO, operation_setIO_concat) IndexSet inputs; for (int i = 0; i < 6; ++i) { - inputs.append(graph.addOperand(shape, type)); + inputs.append(model.operands.append(shape, type)); } GraphNode::Param concat_params; - concat_params.axis_index = graph.addOperand(shape, type); + concat_params.axis_index = model.operands.append(shape, type); - auto output_operand = graph.addOperand(shape, type).value(); + auto output_operand = model.operands.append(shape, type).value(); IndexSet outputs{output_operand}; auto concat = nnfw::cpp14::make_unique(inputs, outputs, concat_params); diff --git a/runtimes/neurun/test/graph/verifier/Verifier.cc b/runtimes/neurun/test/graph/verifier/Verifier.cc index b4e15a5..8bd1643 100644 --- a/runtimes/neurun/test/graph/verifier/Verifier.cc +++ b/runtimes/neurun/test/graph/verifier/Verifier.cc @@ -20,6 +20,7 @@ #include "graph/Graph.h" #include "graph/verifier/Verifier.h" #include "cpp14/memory.h" +#include "model/Model.h" #include "model/operand/Object.h" #include "../MockNode.h" @@ -28,24 +29,27 @@ using MockNode = neurun_test::graph::SimpleMockNode; TEST(Verifier, dag_checker) { - neurun::graph::Graph graph; - neurun::graph::verifier::DAGChecker verifier; + std::unique_ptr model = nnfw::cpp14::make_unique(); ::neurun::model::operand::Shape shape{1u}; ::neurun::model::operand::TypeInfo type{neurun::model::operand::DataType::TENSOR_INT32, 0, 0}; shape.dim(0) = 3; - auto operand1 = graph.addOperand(shape, type); - auto operand2 = graph.addOperand(shape, type); + auto operand1 = model->operands.append(shape, type); + auto operand2 = model->operands.append(shape, type); - graph.addInput(operand1); - graph.operands().at(operand1).usage(neurun::model::operand::Usage::MODEL_INPUT); - graph.addOutput(operand2); - graph.operands().at(operand2).usage(neurun::model::operand::Usage::OPERATION_OUTPUT); + model->inputs.append(operand1); + model->operands.at(operand1).usage(neurun::model::operand::Usage::MODEL_INPUT); + model->outputs.append(operand2); + model->operands.at(operand2).usage(neurun::model::operand::Usage::OPERATION_OUTPUT); - graph.addOperation(nnfw::cpp14::make_unique(IndexSet{operand1}, IndexSet{operand2})); + model->operations.append( + nnfw::cpp14::make_unique(IndexSet{operand1}, IndexSet{operand2})); + neurun::graph::Graph graph{std::move(model)}; graph.finishBuilding(); + neurun::graph::verifier::DAGChecker verifier; + ASSERT_EQ(verifier.verify(graph), true); } diff --git a/runtimes/neurun/test/interp/ExecManager.cc b/runtimes/neurun/test/interp/ExecManager.cc index 233b12a..5f1b691 100644 --- a/runtimes/neurun/test/interp/ExecManager.cc +++ b/runtimes/neurun/test/interp/ExecManager.cc @@ -20,6 +20,7 @@ #include "graph/Graph.h" #include "exec/interp/ExecManager.h" +#include "model/Model.h" #include "model/operation/AddNode.h" namespace @@ -42,6 +43,8 @@ protected: // model output: add result // lhs, rhs, result shape: {1, 2, 2, 1} // activation: none (constant) + std::unique_ptr model = nnfw::cpp14::make_unique(); + operand::Shape shape{4}; shape.dim(0) = 1; shape.dim(1) = 2; @@ -51,36 +54,39 @@ protected: operand::Shape shape_scalar{0}; operand::TypeInfo type_scalar{DataType::SCALAR_INT32, 0, 0}; - auto operand_lhs = graph.addOperand(shape, type); - auto operand_rhs = graph.addOperand(shape, type); + auto operand_lhs = model->operands.append(shape, type); + auto operand_rhs = model->operands.append(shape, type); auto input_set = operand::IndexSet{operand_lhs, operand_rhs}; - auto operand_activation = graph.addOperand(shape_scalar, type_scalar); - graph.operands().at(operand_activation).usage(Usage::CONSTANT); + auto operand_activation = model->operands.append(shape_scalar, type_scalar); + model->operands.at(operand_activation).usage(Usage::CONSTANT); operation::AddNode::Param param; param.activation_index = operand_activation; - graph.setOperandValue(operand_activation, - nnfw::cpp14::make_unique( - reinterpret_cast(&_activation_value), 4)); + model->operands.at(operand_activation).usage(operand::Usage::CONSTANT); + model->operands.at(operand_activation) + .data(nnfw::cpp14::make_unique( + reinterpret_cast(&_activation_value), 4)); - auto operand_result = graph.addOperand(shape, type); + auto operand_result = model->operands.append(shape, type); auto output_set = operand::IndexSet{operand_result}; - graph.operands().at(operand_result).usage(Usage::OPERATION_OUTPUT); - graph.addOperation(nnfw::cpp14::make_unique(input_set, output_set, param)); + model->operands.at(operand_result).usage(Usage::OPERATION_OUTPUT); + model->operations.append( + nnfw::cpp14::make_unique(input_set, output_set, param)); - graph.operands().at(operand_lhs).usage(Usage::MODEL_INPUT); - graph.operands().at(operand_rhs).usage(Usage::MODEL_INPUT); - graph.addInput(operand_lhs); - graph.addInput(operand_rhs); - graph.addOutput(operand_rhs); - graph.finishBuilding(); + model->operands.at(operand_lhs).usage(Usage::MODEL_INPUT); + model->operands.at(operand_rhs).usage(Usage::MODEL_INPUT); + model->inputs.append(operand_lhs); + model->inputs.append(operand_rhs); + model->outputs.append(operand_rhs); + _graph = nnfw::cpp14::make_unique<::neurun::graph::Graph>(std::move(model)); + _graph->finishBuilding(); - _executor = nnfw::cpp14::make_unique(graph.shareModel()); + _executor = nnfw::cpp14::make_unique(_graph->shareModel()); } virtual void TearDown() { _executor = nullptr; } - ::neurun::graph::Graph graph{}; + std::unique_ptr<::neurun::graph::Graph> _graph{nullptr}; std::unique_ptr _executor{nullptr}; const int32_t _activation_value{0}; }; @@ -102,10 +108,10 @@ TEST_F(InterpExecManagerTest, setInput) CreateSimpleModel(); auto input1 = operand::IO::Index{0}; - auto input1_idx = graph.getInputs().at(input1); + auto input1_idx = _graph->getInputs().at(input1); - auto input1_type = graph.operands().at(input1_idx).typeInfo(); - auto input1_shape = graph.operands().at(input1_idx).shape(); + auto input1_type = _graph->operands().at(input1_idx).typeInfo(); + auto input1_shape = _graph->operands().at(input1_idx).shape(); const int32_t input1_buffer[4] = {1, 0, -1, -2}; @@ -124,10 +130,10 @@ TEST_F(InterpExecManagerTest, setOutput) CreateSimpleModel(); auto output = operand::IO::Index{0}; - auto output_idx = graph.getOutputs().at(output); + auto output_idx = _graph->getOutputs().at(output); - auto output_type = graph.operands().at(output_idx).typeInfo(); - auto output_shape = graph.operands().at(output_idx).shape(); + auto output_type = _graph->operands().at(output_idx).typeInfo(); + auto output_shape = _graph->operands().at(output_idx).shape(); int32_t input1_buffer[4] = {}; -- 2.7.4