From: 오형석/On-Device Lab(SR)/Staff Engineer/삼성전자 Date: Tue, 23 Apr 2019 10:37:34 +0000 (+0900) Subject: Rename hasData to isConstant (#5046) X-Git-Tag: submit/tizen/20190809.050447~883 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=857ab0410dd334802fc84b681c23d0af7a9518a3;p=platform%2Fcore%2Fml%2Fnnfw.git Rename hasData to isConstant (#5046) Rename hasData to isConstant It is used to check operand is constant Signed-off-by: Hyeongseok Oh --- diff --git a/runtimes/neurun/backend/acl_cl/StageGenerator.cc b/runtimes/neurun/backend/acl_cl/StageGenerator.cc index ef35f56..9828a19 100644 --- a/runtimes/neurun/backend/acl_cl/StageGenerator.cc +++ b/runtimes/neurun/backend/acl_cl/StageGenerator.cc @@ -2713,7 +2713,7 @@ void StageGenerator::visit(const model::operation::ArgMaxNode &node) auto ofm_shape = _ctx.at(ofm_index).shape(); auto axis_shape = _ctx.at(axis_index).shape(); - assert(_ctx.at(axis_index).hasData()); + assert(_ctx.at(axis_index).isConstant()); // Axis dimension is always 1. assert(axis_shape.rank() == 1); assert((ifm_shape.rank() - 1) == ofm_shape.rank()); diff --git a/runtimes/neurun/core/include/model/operand/Object.h b/runtimes/neurun/core/include/model/operand/Object.h index fb4ba9e..256192a 100644 --- a/runtimes/neurun/core/include/model/operand/Object.h +++ b/runtimes/neurun/core/include/model/operand/Object.h @@ -83,7 +83,7 @@ public: * @brief Get true if Object has data, otherwise @c false * @return @c true if Object has data, otherwise @c false */ - bool hasData(void) const { return _data != nullptr; } + bool isConstant(void) const { return _data != nullptr; } public: template void data(Args &&... args) diff --git a/runtimes/neurun/core/src/compiler/ConstantInitializer.cc b/runtimes/neurun/core/src/compiler/ConstantInitializer.cc index 51bbad4..07cc799 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.hasData()) + if (!model_obj.isConstant()) return; auto type = model_obj.typeInfo().type(); diff --git a/runtimes/neurun/core/src/compiler/OperationValidator.cc b/runtimes/neurun/core/src/compiler/OperationValidator.cc index c181c26..8befb00 100644 --- a/runtimes/neurun/core/src/compiler/OperationValidator.cc +++ b/runtimes/neurun/core/src/compiler/OperationValidator.cc @@ -104,7 +104,7 @@ void OperationValidator::visit(const model::operation::ReduceSumNode &node) assert(input_shape.rank() <= 4); assert(output_shape.rank() <= input_shape.rank()); - assert(_ctx.at(axis_index).hasData()); + assert(_ctx.at(axis_index).isConstant()); assert(axis_shape.rank() == 0 || axis_shape.rank() == 1); // NOTE For the 4-dimensions, if the rank of input and output are different, this runtime only @@ -171,7 +171,7 @@ void OperationValidator::visit(const model::operation::ReduceMaxNode &node) assert(input_shape.rank() <= 4); assert(output_shape.rank() <= input_shape.rank()); - assert(_ctx.at(axis_index).hasData()); + assert(_ctx.at(axis_index).isConstant()); assert(axis_shape.rank() == 0 || axis_shape.rank() == 1); // NOTE For the 4-dimensions, if the rank of input and output are different, this runtime only @@ -349,7 +349,7 @@ void OperationValidator::visit(const model::operation::TransposeConvNode &node) UNUSED_RELEASE(ifm_shape); UNUSED_RELEASE(ker_shape); - assert(_ctx.at(padding_index).hasData() == true); + assert(_ctx.at(padding_index).isConstant() == true); const int32_t vstride = _ctx.at(vstride_index).asScalar(); const int32_t hstride = _ctx.at(hstride_index).asScalar(); @@ -393,7 +393,7 @@ void OperationValidator::visit(const model::operation::GatherNode &node) assert(ifm_shape.rank() <= 4); assert(indices_shape.rank() <= 3); assert(ofm_shape.rank() <= 4); - assert(_ctx.at(axis_index).hasData()); + assert(_ctx.at(axis_index).isConstant()); assert(axis_shape.rank() == 0); } @@ -493,7 +493,7 @@ void OperationValidator::visit(const model::operation::ReduceMinNode &node) assert(ifm_shape.rank() <= 4); assert(ofm_shape.rank() <= ifm_shape.rank()); - assert(_ctx.at(axis_index).hasData()); + assert(_ctx.at(axis_index).isConstant()); assert(axis_shape.rank() == 0 || axis_shape.rank() == 1); // NOTE For the 4-dimensions, if the rank of input and output are different, this runtime only diff --git a/runtimes/neurun/core/src/compiler/ParamChecker.cc b/runtimes/neurun/core/src/compiler/ParamChecker.cc index 68452ec..c9c063c 100644 --- a/runtimes/neurun/core/src/compiler/ParamChecker.cc +++ b/runtimes/neurun/core/src/compiler/ParamChecker.cc @@ -34,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).hasData()) + if (!_model->operands().at(activation_index).isConstant()) { _nonConstParam = true; } diff --git a/runtimes/neurun/core/src/compiler/SubTensorAnalyzer.cc b/runtimes/neurun/core/src/compiler/SubTensorAnalyzer.cc index b1a1c5a..acca5a8 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).hasData()) + if (!_ctx.at(axis_index).isConstant()) { 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 a03618f..9ba3515 100644 --- a/runtimes/neurun/core/src/dumper/dot/DotDumper.cc +++ b/runtimes/neurun/core/src/dumper/dot/DotDumper.cc @@ -62,9 +62,9 @@ void DotDumper::dumpIfNeeded(const std::string &tag) } else { - showing_cond = !object.hasData(); + showing_cond = !object.isConstant(); } - if (object.hasData() || _graph.getInputs().contains(index)) + if (object.isConstant() || _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 a941c7f..0a6ea43 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.hasData()) + if (obj.isConstant()) { VERBOSE(INTERPRETER) << "Allocate and assign constant tensor. operand index:" << ind.value() << std::endl; diff --git a/runtimes/neurun/core/src/exec/interp/Interpreter.cc b/runtimes/neurun/core/src/exec/interp/Interpreter.cc index f452697..c57ea2d 100644 --- a/runtimes/neurun/core/src/exec/interp/Interpreter.cc +++ b/runtimes/neurun/core/src/exec/interp/Interpreter.cc @@ -50,7 +50,7 @@ void Interpreter::run() _env->model().operands.iterate( [&](const model::operand::Index &ind, const model::operand::Object &obj) { - if (obj.hasData()) + if (obj.isConstant()) { VERBOSE(INTERPRETER) << "Constant: Push to operand stack " << ind.value() << std::endl; diff --git a/runtimes/neurun/core/src/graph/Graph.cc b/runtimes/neurun/core/src/graph/Graph.cc index 512a338..4e37f74 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.hasData()) + if (operand.isConstant()) 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 9659899..24fd936 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 &model, { // only valid_inputs const auto &operand = _model->operands.at(input); - if (operand.hasData()) + if (operand.isConstant()) 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.hasData()) + if (obj.isConstant()) { 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 1ff5d6f..df58db6 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 && !hasData()); + assert(_usage != Usage::NOT_DEFINED && !isConstant()); 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 a15ac3e..fd95193 100644 --- a/runtimes/neurun/frontend/nnapi/wrapper/model.cc +++ b/runtimes/neurun/frontend/nnapi/wrapper/model.cc @@ -238,7 +238,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).hasData() && !_model->inputs.contains(ind)); + return (!_model->operands.at(ind).isConstant() && !_model->inputs.contains(ind)); } void ANeuralNetworksModel::setOptionalOperand(const neurun::model::operand::Index idx)