From: 오형석/동작제어Lab(SR)/Staff Engineer/삼성전자 Date: Tue, 4 Dec 2018 01:16:30 +0000 (+0900) Subject: Collect optional operand index (#3768) X-Git-Tag: 0.3~233 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=5170c42ee0bd67c74b48644847ad71d377134b4c;p=platform%2Fcore%2Fml%2Fnnfw.git Collect optional operand index (#3768) Collect optional operand index using defined API in frontend Signed-off-by: Hyeongseok Oh --- diff --git a/runtimes/neurun/src/frontend/model.cc b/runtimes/neurun/src/frontend/model.cc index aa99ca4..5baf86f 100644 --- a/runtimes/neurun/src/frontend/model.cc +++ b/runtimes/neurun/src/frontend/model.cc @@ -109,6 +109,8 @@ int ANeuralNetworksModel_addOperand(ANeuralNetworksModel *model, int ANeuralNetworksModel_setOperandValue(ANeuralNetworksModel *model, int32_t index, const void *buffer, size_t length) { + const bool isOptional = ((buffer == nullptr) && (length == 0)); + if ((model == nullptr) || ((buffer == nullptr) && (length != 0))) { return ANEURALNETWORKS_UNEXPECTED_NULL; @@ -132,7 +134,7 @@ int ANeuralNetworksModel_setOperandValue(ANeuralNetworksModel *model, int32_t in } auto &obj = model->deref().operands().at(ind); - if (obj.operandSize() != length) + if ((obj.operandSize() != length) && !isOptional) { return ANEURALNETWORKS_BAD_DATA; } @@ -144,6 +146,13 @@ int ANeuralNetworksModel_setOperandValue(ANeuralNetworksModel *model, int32_t in using ::neurun::graph::operand::CachedData; using ::neurun::graph::operand::ExternalData; + // Remain operands.at(ind).data()->base() as nullptr for optional operand + // This will be filled when model finished + if (isOptional) + { + model->setOptionalOperand(ind); + } + // NNAPI spec in NeuralNetworks.h // For values of length greater than ANEURALNETWORKS_MAX_SIZE_OF_IMMEDIATELY_COPIED_VALUES, // the application is responsible for not changing the content of this region