From c9cc5ad3d35b66efafd7fe08ba0243dadbb81221 Mon Sep 17 00:00:00 2001 From: Sergei Barannikov/AI Tools Lab /SRR/Engineer/Samsung Electronics Date: Mon, 2 Dec 2019 09:27:00 +0300 Subject: [PATCH] [neurun] Replace Execution::model with Execution::graph (#9289) Replace `model()` method of `Execution` class with `graph()` method. Signed-off-by: Sergei Barannikov --- runtime/neurun/core/include/exec/Execution.h | 6 ++-- runtime/neurun/core/src/exec/Execution.cc | 8 +++--- .../nnapi/wrapper/ANeuralNetworksExecution.cc | 32 +++++++++++----------- 3 files changed, 23 insertions(+), 23 deletions(-) diff --git a/runtime/neurun/core/include/exec/Execution.h b/runtime/neurun/core/include/exec/Execution.h index b23841f..d5c6c3f 100644 --- a/runtime/neurun/core/include/exec/Execution.h +++ b/runtime/neurun/core/include/exec/Execution.h @@ -48,10 +48,10 @@ public: public: /** - * @brief Returns model object - * @return Model object + * @brief Returns graph object + * @return Graph object */ - const model::Model &model() const { return *_executor->graph().shareModel(); } + const graph::Graph &graph() const { return _executor->graph(); } /** * @brief Set input data's information * @param[in] index Input index diff --git a/runtime/neurun/core/src/exec/Execution.cc b/runtime/neurun/core/src/exec/Execution.cc index 29eb7c7..2921599 100644 --- a/runtime/neurun/core/src/exec/Execution.cc +++ b/runtime/neurun/core/src/exec/Execution.cc @@ -33,8 +33,8 @@ Execution::Execution(const std::shared_ptr &executor) : _executor{exe void Execution::setInput(const model::IOIndex &index, const void *buffer, size_t length, model::Layout layout) { - const auto input_index = model().inputs.at(index); - const auto info = model().operands.at(input_index).info(); + const auto input_index = graph().getInputs().at(index); + const auto info = graph().operands().at(input_index).info(); if (length < info.total_size()) { @@ -65,8 +65,8 @@ void Execution::setInput(const model::IOIndex &index, const model::TypeInfo &typ void Execution::setOutput(const model::IOIndex &index, void *buffer, size_t length, model::Layout layout) { - const auto output_index = model().outputs.at(index); - const auto info = model().operands.at(output_index).info(); + const auto output_index = graph().getOutputs().at(index); + const auto info = graph().operands().at(output_index).info(); if (length < info.total_size()) { diff --git a/runtime/neurun/frontend/nnapi/wrapper/ANeuralNetworksExecution.cc b/runtime/neurun/frontend/nnapi/wrapper/ANeuralNetworksExecution.cc index 61dc0fc..7b580f1 100644 --- a/runtime/neurun/frontend/nnapi/wrapper/ANeuralNetworksExecution.cc +++ b/runtime/neurun/frontend/nnapi/wrapper/ANeuralNetworksExecution.cc @@ -28,14 +28,14 @@ ANeuralNetworksExecution::getInputOperandIndex(int32_t index) noexcept } uint32_t cast_index = static_cast(index); - if (cast_index >= _execution->model().inputs.size()) + if (cast_index >= _execution->graph().getInputs().size()) { // Return invalid index return neurun::model::OperandIndex{}; } neurun::model::IOIndex input_index{cast_index}; - const auto operand_index = _execution->model().inputs.at(input_index); + const auto operand_index = _execution->graph().getInputs().at(input_index); return operand_index; } @@ -49,14 +49,14 @@ ANeuralNetworksExecution::getOutputOperandIndex(int32_t index) noexcept } uint32_t cast_index = static_cast(index); - if (cast_index >= _execution->model().outputs.size()) + if (cast_index >= _execution->graph().getOutputs().size()) { // Return invalid index return neurun::model::OperandIndex{}; } neurun::model::IOIndex output_index{cast_index}; - const auto operand_index = _execution->model().outputs.at(output_index); + const auto operand_index = _execution->graph().getOutputs().at(output_index); return operand_index; } @@ -65,7 +65,7 @@ bool ANeuralNetworksExecution::compareDataType(const ANeuralNetworksOperandType { try { - const auto operand_type = _execution->model().operands.at(index).typeInfo(); + const auto operand_type = _execution->graph().operands().at(index).typeInfo(); const auto typeInfo = NNAPIConvert::getTypeInfo(type); if (operand_type != typeInfo) @@ -93,7 +93,7 @@ bool ANeuralNetworksExecution::compareShape(const ANeuralNetworksOperandType *ty return false; } - const auto &operand_shape = _execution->model().operands.at(index).shape(); + const auto &operand_shape = _execution->graph().operands().at(index).shape(); const auto &shape_from_type = NNAPIConvert::getShape(type); return operand_shape == shape_from_type; @@ -101,7 +101,7 @@ bool ANeuralNetworksExecution::compareShape(const ANeuralNetworksOperandType *ty bool ANeuralNetworksExecution::haveUnspecifiedDims(const neurun::model::OperandIndex index) noexcept { - const auto operand_shape = _execution->model().operands.at(index).shape(); + const auto operand_shape = _execution->graph().operands().at(index).shape(); return operand_shape.num_elements() == 0; } @@ -110,7 +110,7 @@ size_t ANeuralNetworksExecution::getOperandSize(const neurun::model::OperandInde { try { - return _execution->model().operands.at(index).operandSize(); + return _execution->graph().operands().at(index).operandSize(); } catch (const std::exception &e) { @@ -128,9 +128,9 @@ bool ANeuralNetworksExecution::setInput(uint32_t index, const ANeuralNetworksOpe neurun::model::IOIndex input_index{index}; const auto operand_index = getInputOperandIndex(index); - const auto type_info = _execution->model().operands.at(operand_index).typeInfo(); - const auto shape = ((type != nullptr) ? NNAPIConvert::getShape(type) - : _execution->model().operands.at(operand_index).shape()); + const auto type_info = _execution->graph().operands().at(operand_index).typeInfo(); + const auto shape = (type != nullptr) ? NNAPIConvert::getShape(type) + : _execution->graph().operands().at(operand_index).shape(); // NOTE The nnapi does not provide setting io_layout and not support changing layout. In other // words, we can assume that io_layout from nnapi always is the same as layout of the used @@ -157,9 +157,9 @@ bool ANeuralNetworksExecution::setOutput(uint32_t index, const ANeuralNetworksOp neurun::model::IOIndex output_index{index}; const auto operand_index = getOutputOperandIndex(index); - const auto type_info = _execution->model().operands.at(operand_index).typeInfo(); - const auto shape = ((type != nullptr) ? NNAPIConvert::getShape(type) - : _execution->model().operands.at(operand_index).shape()); + const auto type_info = _execution->graph().operands().at(operand_index).typeInfo(); + const auto shape = (type != nullptr) ? NNAPIConvert::getShape(type) + : _execution->graph().operands().at(operand_index).shape(); // NOTE The nnapi does not provide setting io_layout and not support changing layout. In other // words, we can assume that io_layout from nnapi always is the same as layout of the used @@ -236,7 +236,7 @@ bool ANeuralNetworksExecution::getOutputOperandRank(uint32_t index, uint32_t *ra return false; } - *rank = _execution->model().operands.at(operand_index).shape().rank(); + *rank = _execution->graph().operands().at(operand_index).shape().rank(); } catch (const std::exception &e) { @@ -267,7 +267,7 @@ bool ANeuralNetworksExecution::getOutputOperandDimensions(uint32_t index, uint32 return false; } - auto shape = _execution->model().operands.at(operand_index).shape(); + auto shape = _execution->graph().operands().at(operand_index).shape(); for (int i = 0; i < shape.rank(); i++) { auto dim = shape.dim(i); -- 2.7.4