diff options
author | 장지섭/On-Device Lab(SR)/Engineer/삼성전자 <jiseob.jang@samsung.com> | 2019-03-29 15:16:06 +0900 |
---|---|---|
committer | 오형석/On-Device Lab(SR)/Staff Engineer/삼성전자 <hseok82.oh@samsung.com> | 2019-03-29 15:16:06 +0900 |
commit | 953dccad344fe626e2437343310a9b81e7107298 (patch) | |
tree | 72942a8a88ff587ae3821fe07a1f425706b535f1 | |
parent | 042510f77f5c066aa7ab97b8d93649b50c2c5626 (diff) | |
download | nnfw-953dccad344fe626e2437343310a9b81e7107298.tar.gz nnfw-953dccad344fe626e2437343310a9b81e7107298.tar.bz2 nnfw-953dccad344fe626e2437343310a9b81e7107298.zip |
[neurun] Enable operations using boolean type (#4883)
This commit enable operations using boolean type.
Signed-off-by: jiseob.jang <jiseob.jang@samsung.com>
-rw-r--r-- | runtimes/neurun/frontend/nnapi/wrapper/OperationFactory.cc | 43 | ||||
-rw-r--r-- | tests/nnapi/nnapi_gtest.skip.armv7l-linux.neurun | 8 |
2 files changed, 40 insertions, 11 deletions
diff --git a/runtimes/neurun/frontend/nnapi/wrapper/OperationFactory.cc b/runtimes/neurun/frontend/nnapi/wrapper/OperationFactory.cc index 76fd55c6d..dd04ca06a 100644 --- a/runtimes/neurun/frontend/nnapi/wrapper/OperationFactory.cc +++ b/runtimes/neurun/frontend/nnapi/wrapper/OperationFactory.cc @@ -18,6 +18,19 @@ #include "model/operation/Node.Include.h" +namespace +{ +using namespace neurun::model; + +void replaceDataType(operand::Set &operands, const operand::Index &index, + const operand::DataType &type) +{ + assert(operands.exist(index)); + operands.at(index).type(type); +} + +} // namespace + OperationFactory &OperationFactory::instance() { static OperationFactory factory; @@ -624,7 +637,7 @@ OperationFactory::OperationFactory() }; _map[ANEURALNETWORKS_NOT_EQUAL_EX] = [](const OperationFactory::Param &init_param, - neurun::model::operand::Set &) { + neurun::model::operand::Set &operands) { assert(init_param.input_count == 2 && init_param.output_count == 1); operand::IndexSet outputs{init_param.outputs[0]}; @@ -638,11 +651,14 @@ OperationFactory::OperationFactory() operation::ComparisonNode::Param param; param.comparison_type = operation::ComparisonNode::ComparisonType::NotEqual; + // Output operand type must be boolean + replaceDataType(operands, outputs.at(0), operand::DataType::TENSOR_BOOL8); + return new operation::ComparisonNode{inputs, outputs, param}; }; _map[ANEURALNETWORKS_LOGICAL_AND_EX] = [](const OperationFactory::Param &init_param, - neurun::model::operand::Set &) { + neurun::model::operand::Set &operands) { assert(init_param.input_count == 2 && init_param.output_count == 1); operand::IndexSet outputs{init_param.outputs[0]}; @@ -653,6 +669,11 @@ OperationFactory::OperationFactory() // 1 -> input1 Tensor Index operand::IndexSet inputs{init_param.inputs[0], init_param.inputs[1]}; + // This operation's operands must be boolean type. + replaceDataType(operands, inputs.at(0), operand::DataType::TENSOR_BOOL8); + replaceDataType(operands, inputs.at(1), operand::DataType::TENSOR_BOOL8); + replaceDataType(operands, outputs.at(0), operand::DataType::TENSOR_BOOL8); + return new operation::LogicalAndNode{inputs, outputs}; }; @@ -924,7 +945,7 @@ OperationFactory::OperationFactory() }; _map[ANEURALNETWORKS_LOGICAL_OR_EX] = [](const OperationFactory::Param &init_param, - neurun::model::operand::Set &) { + neurun::model::operand::Set &operands) { assert(init_param.input_count == 2 && init_param.output_count == 1); operand::IndexSet outputs{init_param.outputs[0]}; @@ -935,11 +956,16 @@ OperationFactory::OperationFactory() // 1 -> input1 Tensor Index operand::IndexSet inputs{init_param.inputs[0], init_param.inputs[1]}; + // This operation's operands must be boolean type. + replaceDataType(operands, inputs.at(0), operand::DataType::TENSOR_BOOL8); + replaceDataType(operands, inputs.at(1), operand::DataType::TENSOR_BOOL8); + replaceDataType(operands, outputs.at(0), operand::DataType::TENSOR_BOOL8); + return new operation::LogicalOrNode{inputs, outputs}; }; _map[ANEURALNETWORKS_LOGICAL_NOT_EX] = [](const OperationFactory::Param &init_param, - neurun::model::operand::Set &) { + neurun::model::operand::Set &operands) { assert(init_param.input_count == 1 && init_param.output_count == 1); operand::IndexSet outputs{init_param.outputs[0]}; @@ -949,11 +975,15 @@ OperationFactory::OperationFactory() // 0 -> input Tensor Index operand::IndexSet inputs{init_param.inputs[0]}; + // This operation's operands must be boolean type. + replaceDataType(operands, inputs.at(0), operand::DataType::TENSOR_BOOL8); + replaceDataType(operands, outputs.at(0), operand::DataType::TENSOR_BOOL8); + return new operation::LogicalNotNode{inputs, outputs}; }; _map[ANEURALNETWORKS_EQUAL_EX] = [](const OperationFactory::Param &init_param, - neurun::model::operand::Set &) { + neurun::model::operand::Set &operands) { assert(init_param.input_count == 2 && init_param.output_count == 1); operand::IndexSet outputs{init_param.outputs[0]}; @@ -967,6 +997,9 @@ OperationFactory::OperationFactory() operation::ComparisonNode::Param param; param.comparison_type = operation::ComparisonNode::ComparisonType::Equal; + // Output operand type must be boolean + replaceDataType(operands, outputs.at(0), operand::DataType::TENSOR_BOOL8); + return new operation::ComparisonNode{inputs, outputs, param}; }; diff --git a/tests/nnapi/nnapi_gtest.skip.armv7l-linux.neurun b/tests/nnapi/nnapi_gtest.skip.armv7l-linux.neurun index 45318c9f6..27bcab456 100644 --- a/tests/nnapi/nnapi_gtest.skip.armv7l-linux.neurun +++ b/tests/nnapi/nnapi_gtest.skip.armv7l-linux.neurun @@ -15,9 +15,5 @@ GeneratedTests.space_to_batch* GeneratedTests.split* GeneratedTests.pack* GeneratedTests.unpack* -# Unsupported U8 -GeneratedTests.equal* -GeneratedTests.notequal* -GeneratedTests.logical_or* -GeneratedTests.logical_not* - +# Not support broadcast +GeneratedTests.logical_or_ex_broadcast_4D_2D |