summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author오형석/On-Device Lab(SR)/Staff Engineer/삼성전자 <hseok82.oh@samsung.com>2019-04-23 13:20:20 +0900
committerGitHub Enterprise <noreply-CODE@samsung.com>2019-04-23 13:20:20 +0900
commitbf8af66a7d961c58c08131e48a31d12eabce3f37 (patch)
tree52a71ea09d9385828eeb923a6c9d849f6477c5e0
parent8cfa5b45a4f6a8ab40e35ee699af4dc899179609 (diff)
downloadnnfw-bf8af66a7d961c58c08131e48a31d12eabce3f37.tar.gz
nnfw-bf8af66a7d961c58c08131e48a31d12eabce3f37.tar.bz2
nnfw-bf8af66a7d961c58c08131e48a31d12eabce3f37.zip
Remove operand usage getter methods (#5038)
- Remove unused isModelInput() method - Remove usage() method. Use hasData() and model's input/output Signed-off-by: Hyeongseok Oh <hseok82.oh@samsung.com>
-rw-r--r--runtimes/neurun/core/include/model/operand/Object.h2
-rw-r--r--runtimes/neurun/core/src/compiler/ConstantInitializer.cc2
-rw-r--r--runtimes/neurun/core/src/compiler/ParamChecker.cc4
-rw-r--r--runtimes/neurun/core/src/compiler/SubTensorAnalyzer.cc2
-rw-r--r--runtimes/neurun/core/src/dumper/dot/DotDumper.cc6
-rw-r--r--runtimes/neurun/core/src/exec/interp/ExecManager.cc2
-rw-r--r--runtimes/neurun/core/src/graph/Graph.cc2
-rw-r--r--runtimes/neurun/core/src/linear/Linear.cc4
-rw-r--r--runtimes/neurun/core/src/model/operand/Object.cc2
-rw-r--r--runtimes/neurun/frontend/nnapi/wrapper/model.cc2
10 files changed, 11 insertions, 17 deletions
diff --git a/runtimes/neurun/core/include/model/operand/Object.h b/runtimes/neurun/core/include/model/operand/Object.h
index 151d11218..fb4ba9e92 100644
--- a/runtimes/neurun/core/include/model/operand/Object.h
+++ b/runtimes/neurun/core/include/model/operand/Object.h
@@ -59,8 +59,6 @@ public:
const Info &info(void) const { return _info; }
size_t operandSize(void) const;
bool usageIsDefined(void) const { return _usage != Usage::NOT_DEFINED; }
- bool isModelInput(void) const { return _usage == Usage::MODEL_INPUT; }
- Usage usage() const { return _usage; }
bool usage(Usage usage);
const operation::IndexList &getUses() const { return _uses; }
diff --git a/runtimes/neurun/core/src/compiler/ConstantInitializer.cc b/runtimes/neurun/core/src/compiler/ConstantInitializer.cc
index 861c50ac1..51bbad485 100644
--- a/runtimes/neurun/core/src/compiler/ConstantInitializer.cc
+++ b/runtimes/neurun/core/src/compiler/ConstantInitializer.cc
@@ -172,7 +172,7 @@ void ConstantInitializer::operator()()
const auto &model_obj = _graph.operands().at(index);
// For only CONSTANTS
- if (model_obj.usage() != neurun::model::operand::Usage::CONSTANT)
+ if (!model_obj.hasData())
return;
auto type = model_obj.typeInfo().type();
diff --git a/runtimes/neurun/core/src/compiler/ParamChecker.cc b/runtimes/neurun/core/src/compiler/ParamChecker.cc
index 28f877d84..68452ec13 100644
--- a/runtimes/neurun/core/src/compiler/ParamChecker.cc
+++ b/runtimes/neurun/core/src/compiler/ParamChecker.cc
@@ -23,8 +23,6 @@ namespace neurun
namespace compiler
{
-using Usage = neurun::model::operand::Usage;
-
void ParamChecker::operator()()
{
_model->operations().iterate([&](const model::OperationIndex &, const model::Operation &node) {
@@ -36,7 +34,7 @@ void ParamChecker::visit(const model::operation::AddNode &node)
{
const auto activation_index = node.param().activation_index;
- if (_model->operands().at(activation_index).usage() != Usage::CONSTANT)
+ if (!_model->operands().at(activation_index).hasData())
{
_nonConstParam = true;
}
diff --git a/runtimes/neurun/core/src/compiler/SubTensorAnalyzer.cc b/runtimes/neurun/core/src/compiler/SubTensorAnalyzer.cc
index 9084add50..b1a1c5a25 100644
--- a/runtimes/neurun/core/src/compiler/SubTensorAnalyzer.cc
+++ b/runtimes/neurun/core/src/compiler/SubTensorAnalyzer.cc
@@ -38,7 +38,7 @@ void SubTensorAnalyzer::visit(const model::operation::ConcatNode &node)
auto axis_index = node.param().axis_index;
// To prepare concat elimination, axis should be constant
- if (_ctx.at(axis_index).usage() != model::operand::Usage::CONSTANT)
+ if (!_ctx.at(axis_index).hasData())
{
VERBOSE(SUBTENSOR) << "Cannot handle non-constant axis" << std::endl;
return;
diff --git a/runtimes/neurun/core/src/dumper/dot/DotDumper.cc b/runtimes/neurun/core/src/dumper/dot/DotDumper.cc
index a590fd626..a03618ff9 100644
--- a/runtimes/neurun/core/src/dumper/dot/DotDumper.cc
+++ b/runtimes/neurun/core/src/dumper/dot/DotDumper.cc
@@ -56,17 +56,15 @@ void DotDumper::dumpIfNeeded(const std::string &tag)
operands.iterate([&](const model::operand::Index &index, const model::operand::Object &object) {
bool showing_cond = false;
- auto usage = object.usage();
if (_option == OPTIONS::SHOW_CONSTANTS)
{
showing_cond = object.usageIsDefined();
}
else
{
- showing_cond = (usage == model::operand::Usage::MODEL_INPUT) ||
- (usage == model::operand::Usage::OPERATION_OUTPUT);
+ showing_cond = !object.hasData();
}
- if (usage != model::operand::Usage::OPERATION_OUTPUT)
+ if (object.hasData() || _graph.getInputs().contains(index))
{
showing_cond = showing_cond && (object.getUses().size() > 0);
}
diff --git a/runtimes/neurun/core/src/exec/interp/ExecManager.cc b/runtimes/neurun/core/src/exec/interp/ExecManager.cc
index e3d4c314e..a941c7f64 100644
--- a/runtimes/neurun/core/src/exec/interp/ExecManager.cc
+++ b/runtimes/neurun/core/src/exec/interp/ExecManager.cc
@@ -136,7 +136,7 @@ void ExecManager::execute(void)
// Allocate constant tensor
_model->operands.iterate([&](const model::operand::Index &ind,
const model::operand::Object &obj) {
- if (obj.usage() == model::operand::Usage::CONSTANT)
+ if (obj.hasData())
{
VERBOSE(INTERPRETER) << "Allocate and assign constant tensor. operand index:" << ind.value()
<< std::endl;
diff --git a/runtimes/neurun/core/src/graph/Graph.cc b/runtimes/neurun/core/src/graph/Graph.cc
index bc52095b0..512a3388f 100644
--- a/runtimes/neurun/core/src/graph/Graph.cc
+++ b/runtimes/neurun/core/src/graph/Graph.cc
@@ -241,7 +241,7 @@ void Graph::lower(void)
{
// only valid_inputs
const auto &operand = _model->operands.at(input);
- if (operand.usage() == model::operand::Usage::CONSTANT)
+ if (operand.hasData())
continue;
// This operand is input of operation, not weight or bias
diff --git a/runtimes/neurun/core/src/linear/Linear.cc b/runtimes/neurun/core/src/linear/Linear.cc
index 674808c9a..965989950 100644
--- a/runtimes/neurun/core/src/linear/Linear.cc
+++ b/runtimes/neurun/core/src/linear/Linear.cc
@@ -69,7 +69,7 @@ Linear::Linear(const std::shared_ptr<const model::Model> &model,
{
// only valid_inputs
const auto &operand = _model->operands.at(input);
- if (operand.usage() == model::operand::Usage::CONSTANT)
+ if (operand.hasData())
continue;
auto it = input_to_subgs.find(input);
@@ -195,7 +195,7 @@ backend::TensorBuilderSet Linear::planTensors()
// If a tensor is a constant, increase the use of the tensor.
// It makes the tensor not be dealloced.
- if (obj.usage() == model::operand::Usage::CONSTANT)
+ if (obj.hasData())
{
constants.push_back(ind);
uses_map[ind]++;
diff --git a/runtimes/neurun/core/src/model/operand/Object.cc b/runtimes/neurun/core/src/model/operand/Object.cc
index 8d0d000b7..1ff5d6f6b 100644
--- a/runtimes/neurun/core/src/model/operand/Object.cc
+++ b/runtimes/neurun/core/src/model/operand/Object.cc
@@ -71,7 +71,7 @@ void Object::removeUse(const ::neurun::model::OperationIndex &idx)
void Object::appendDef(const ::neurun::model::OperationIndex &idx)
{
- assert(_usage != Usage::NOT_DEFINED && _usage != Usage::CONSTANT);
+ assert(_usage != Usage::NOT_DEFINED && !hasData());
assert(_def.size() == 0);
_def.append(idx);
diff --git a/runtimes/neurun/frontend/nnapi/wrapper/model.cc b/runtimes/neurun/frontend/nnapi/wrapper/model.cc
index 9fb16e47e..f3948ace0 100644
--- a/runtimes/neurun/frontend/nnapi/wrapper/model.cc
+++ b/runtimes/neurun/frontend/nnapi/wrapper/model.cc
@@ -223,7 +223,7 @@ bool ANeuralNetworksModel::isUsageSet(uint32_t index) noexcept
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).hasData() && !_model->inputs.contains(ind));
}
void ANeuralNetworksModel::setOptionalOperand(const neurun::model::operand::Index idx)