From: Hyung-Kyu Choi Date: Thu, 29 Mar 2018 15:00:53 +0000 (+0900) Subject: Enable three operation of CpuExecutor X-Git-Tag: 0.1~501 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=ea75588821379fb864735beb0af030ad3a198444;p=platform%2Fcore%2Fml%2Fnnfw.git Enable three operation of CpuExecutor - Introduce Concatenation operation - Enable OperationType::CONCATENATION, OperationType::SOFTMAX and OperationType::MAX_POOL_2D of CpuExecutor Signed-off-by: Hyung-Kyu Choi --- diff --git a/src/runtime/ref/nn/common/CMakeLists.txt b/src/runtime/ref/nn/common/CMakeLists.txt index 285c850..7ec3803 100644 --- a/src/runtime/ref/nn/common/CMakeLists.txt +++ b/src/runtime/ref/nn/common/CMakeLists.txt @@ -14,6 +14,7 @@ SET (CUR_SRCS ${CMAKE_CURRENT_SOURCE_DIR}/OperationsUtils.cpp ${CMAKE_CURRENT_SOURCE_DIR}/Utils.cpp ${CMAKE_CURRENT_SOURCE_DIR}/operations/Activation.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/operations/Concatenation.cpp ${CMAKE_CURRENT_SOURCE_DIR}/operations/Pooling.cpp ${CMAKE_CURRENT_SOURCE_DIR}/operations/SimpleMath.cpp ) diff --git a/src/runtime/ref/nn/common/CpuExecutor.cpp b/src/runtime/ref/nn/common/CpuExecutor.cpp index 9f3473b..25f1973 100644 --- a/src/runtime/ref/nn/common/CpuExecutor.cpp +++ b/src/runtime/ref/nn/common/CpuExecutor.cpp @@ -715,6 +715,7 @@ int CpuExecutor::executeOperation(const Operation& operation) { outShape); } } break; +#endif // REF-ANN case OperationType::MAX_POOL_2D: { const size_t inCount = ins.size(); if ((inCount != 10 && inCount != 7) || @@ -796,6 +797,7 @@ int CpuExecutor::executeOperation(const Operation& operation) { } } break; +#if 0 // REF-ANN case OperationType::RELU: { if (!allParametersPresent(1, 1)) { return ANEURALNETWORKS_BAD_DATA; @@ -909,6 +911,7 @@ int CpuExecutor::executeOperation(const Operation& operation) { outShape); } } break; +#endif // REF-ANN case OperationType::SOFTMAX: { if (!allParametersPresent(2, 1)) { return ANEURALNETWORKS_BAD_DATA; @@ -941,6 +944,7 @@ int CpuExecutor::executeOperation(const Operation& operation) { output.shape()); } } break; +#if 0 // REF-ANN case OperationType::FULLY_CONNECTED: { if (!allParametersPresent(4, 1)) { return ANEURALNETWORKS_BAD_DATA; @@ -982,6 +986,7 @@ int CpuExecutor::executeOperation(const Operation& operation) { outShape); } } break; +#endif // REF-ANN case OperationType::CONCATENATION: { if (outs.size() != 1 || ins.size() < 2) { return ANEURALNETWORKS_BAD_DATA; @@ -1022,6 +1027,7 @@ int CpuExecutor::executeOperation(const Operation& operation) { outShape); } } break; +#if 0 // REF-ANN case OperationType::L2_NORMALIZATION: { if (!allParametersPresent(1, 1)) { return ANEURALNETWORKS_BAD_DATA; diff --git a/src/runtime/ref/nn/common/operations/Concatenation.cpp b/src/runtime/ref/nn/common/operations/Concatenation.cpp new file mode 100644 index 0000000..a8ba740 --- /dev/null +++ b/src/runtime/ref/nn/common/operations/Concatenation.cpp @@ -0,0 +1,63 @@ +/* + * Copyright (C) 2017 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "Operations.h" +#include "OperationsUtils.h" + +#include "internal/optimized/optimized_ops.h" + +namespace android { +namespace nn { + +bool concatenationFloat32(const std::vector& inputDataPtrs, + const std::vector& inputShapes, int32_t axis, + float* outputData, const Shape& outputShape) { + int num_inputs = inputShapes.size(); + std::vector*> inputDimsPtr(num_inputs); + std::vector > inputDims(num_inputs); + for (int i=0; i( + getNumberOfDimensions(outputShape) - axis - 1, + inputDataPtrs.data(), inputDimsPtr.data(), num_inputs, + outputData, convertShapeToDims(outputShape)); + + return true; +} + +bool concatenationQuant8(const std::vector& inputDataPtrs, + const std::vector& inputShapes, int32_t axis, + uint8_t* outputData, const Shape& outputShape) { + int num_inputs = inputShapes.size(); + std::vector*> inputDimsPtr(num_inputs); + std::vector > inputDims(num_inputs); + for (int i=0; i( + getNumberOfDimensions(outputShape) - axis - 1, + inputDataPtrs.data(), inputDimsPtr.data(), num_inputs, + outputData, convertShapeToDims(outputShape)); + + return true; +} +} // namespace nn +} // namespace android