diff options
-rw-r--r-- | arm_compute/core/experimental/PostOps.h (renamed from src/core/experimental/PostOp.h) | 70 | ||||
-rw-r--r-- | arm_compute/graph/backends/FunctionHelpers.h | 2 | ||||
-rw-r--r-- | src/core/CL/CLUtils.cpp | 2 | ||||
-rw-r--r-- | src/core/experimental/PostOpUtils.h | 99 | ||||
-rw-r--r-- | src/gpu/cl/kernels/ClGemmMatrixMultiplyNativeKernel.cpp | 2 | ||||
-rw-r--r-- | src/gpu/cl/kernels/ClGemmMatrixMultiplyReshapedKernel.cpp | 2 | ||||
-rw-r--r-- | src/gpu/cl/kernels/ClGemmMatrixMultiplyReshapedOnlyRhsKernel.cpp | 2 | ||||
-rw-r--r-- | src/runtime/CL/functions/CLConvolutionLayer.cpp | 1 | ||||
-rw-r--r-- | src/runtime/CL/functions/CLGEMMConvolutionLayer.cpp | 2 | ||||
-rw-r--r-- | tests/validation/CL/ConvolutionLayer.cpp | 2 | ||||
-rw-r--r-- | tests/validation/CL/GEMMMatrixMultiplyReshaped.cpp | 2 | ||||
-rw-r--r-- | tests/validation/CL/GEMMMatrixMultiplyReshapedOnlyRHS.cpp | 2 | ||||
-rw-r--r-- | tests/validation/fixtures/GEMMFixture.h | 2 | ||||
-rw-r--r-- | tests/validation/reference/PostOps.cpp | 3 | ||||
-rw-r--r-- | utils/TypePrinter.h | 3 |
15 files changed, 122 insertions, 74 deletions
diff --git a/src/core/experimental/PostOp.h b/arm_compute/core/experimental/PostOps.h index b29f67ec5c..4ea90fc348 100644 --- a/src/core/experimental/PostOp.h +++ b/arm_compute/core/experimental/PostOps.h @@ -21,22 +21,23 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ -#ifndef ARM_COMPUTE_EXPERIMENTAL_POSTOP -#define ARM_COMPUTE_EXPERIMENTAL_POSTOP +#ifndef ARM_COMPUTE_EXPERIMENTAL_POSTOPS +#define ARM_COMPUTE_EXPERIMENTAL_POSTOPS #include "arm_compute/core/experimental/IPostOp.h" #include "arm_compute/core/Types.h" -#include "arm_compute/core/experimental/Types.h" -#include "support/Cast.h" #include <vector> -/** (EXPERIMENTAL_POST_OPS) */ namespace arm_compute { namespace experimental { +/** (EXPERIMENTAL_POST_OPS) + * Implementation of specific IPostOps +*/ + template <typename TensorRelatedT> struct PostOpAct : public IPostOp<TensorRelatedT> { @@ -156,63 +157,6 @@ public: int _prev_dst_pos; ConvertPolicy _policy; }; - -/** Transform a PostOpList of type FromTensorT to one of type ToTensorT */ -template <typename FromTensorT, typename ToTensorT> -PostOpList<ToTensorT> transform_post_op_list_arguments(const PostOpList<FromTensorT> &post_ops, std::function<ToTensorT(FromTensorT)> transform_arg) -{ - PostOpList<ToTensorT> transformed_post_ops; - int op_idx = 0; - for(const auto &post_op : post_ops.get_list()) - { - switch(post_op->type()) - { - case PostOpType::Activation: - { - const auto _post_op = utils::cast::polymorphic_downcast<const PostOpAct<FromTensorT> *>(post_op.get()); - transformed_post_ops.template push_back_op<PostOpAct<ToTensorT>>(_post_op->_act_info); - break; - } - case PostOpType::Eltwise_Add: - { - const auto _post_op = utils::cast::polymorphic_downcast<const PostOpEltwiseAdd<FromTensorT> *>(post_op.get()); - transformed_post_ops.template push_back_op<PostOpEltwiseAdd<ToTensorT>>(transform_arg(_post_op->_addend), _post_op->_prev_dst_pos, _post_op->_policy); - break; - } - case PostOpType::Eltwise_PRelu: - { - const auto _post_op = utils::cast::polymorphic_downcast<const PostOpEltwisePRelu<FromTensorT> *>(post_op.get()); - transformed_post_ops.template push_back_op<PostOpEltwisePRelu<ToTensorT>>(transform_arg(_post_op->_alpha_param), _post_op->_prev_dst_pos, _post_op->_policy); - break; - } - default: - { - ARM_COMPUTE_ERROR("Unsupported PostOpType"); - } - } - ++op_idx; - } - return transformed_post_ops; -} - -/** Get post op argument TensorType from post op argument index in a flattened, ordered post op argument list */ -inline TensorType get_post_op_arg_type(size_t index) -{ - ARM_COMPUTE_ERROR_ON_MSG(static_cast<int>(index) > EXPERIMENTAL_ACL_POST_OP_ARG_LAST - EXPERIMENTAL_ACL_POST_OP_ARG_FIRST, "Post Op argument index is out of range"); - return static_cast<TensorType>(EXPERIMENTAL_ACL_POST_OP_ARG_FIRST + static_cast<int>(index)); -} - -template <typename T> -PostOpTypeSequence get_post_op_sequence(const PostOpList<T> &post_ops) -{ - PostOpTypeSequence post_op_sequence; - for(const auto &op : post_ops.get_list()) - { - post_op_sequence.push_back(op->type()); - } - return post_op_sequence; -} - } // namespace experimental } // namespace arm_compute -#endif //ARM_COMPUTE_EXPERIMENTAL_POSTOP +#endif //ARM_COMPUTE_EXPERIMENTAL_POSTOPS
\ No newline at end of file diff --git a/arm_compute/graph/backends/FunctionHelpers.h b/arm_compute/graph/backends/FunctionHelpers.h index 55af056a43..1e420a803f 100644 --- a/arm_compute/graph/backends/FunctionHelpers.h +++ b/arm_compute/graph/backends/FunctionHelpers.h @@ -24,6 +24,8 @@ #ifndef ARM_COMPUTE_GRAPH_BACKENDS_DETAIL_FUNCTION_HELPERS_H #define ARM_COMPUTE_GRAPH_BACKENDS_DETAIL_FUNCTION_HELPERS_H +#include "arm_compute/core/experimental/IPostOp.h" +#include "arm_compute/core/experimental/PostOps.h" #include "arm_compute/graph/Logger.h" #include "arm_compute/graph/Tensor.h" #include "arm_compute/graph/TypePrinter.h" diff --git a/src/core/CL/CLUtils.cpp b/src/core/CL/CLUtils.cpp index 8dab8aa876..5de9a55686 100644 --- a/src/core/CL/CLUtils.cpp +++ b/src/core/CL/CLUtils.cpp @@ -28,7 +28,7 @@ #include "support/StringSupport.h" #include "src/core/CL/CLUtils.h" -#include "src/core/experimental/PostOp.h" +#include "src/core/experimental/PostOpUtils.h" namespace arm_compute { diff --git a/src/core/experimental/PostOpUtils.h b/src/core/experimental/PostOpUtils.h new file mode 100644 index 0000000000..53795db13f --- /dev/null +++ b/src/core/experimental/PostOpUtils.h @@ -0,0 +1,99 @@ +/* + * Copyright (c) 2021 Arm Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#ifndef ARM_COMPUTE_EXPERIMENTAL_POSTOPUTILS +#define ARM_COMPUTE_EXPERIMENTAL_POSTOPUTILS + +#include "arm_compute/core/experimental/IPostOp.h" +#include "arm_compute/core/experimental/PostOps.h" + +#include "arm_compute/core/experimental/Types.h" +#include "support/Cast.h" + +#include <vector> + +/** (EXPERIMENTAL_POST_OPS) */ +namespace arm_compute +{ +namespace experimental +{ +/** Transform a PostOpList of type FromTensorT to one of type ToTensorT */ +template <typename FromTensorT, typename ToTensorT> +PostOpList<ToTensorT> transform_post_op_list_arguments(const PostOpList<FromTensorT> &post_ops, std::function<ToTensorT(FromTensorT)> transform_arg) +{ + PostOpList<ToTensorT> transformed_post_ops; + int op_idx = 0; + for(const auto &post_op : post_ops.get_list()) + { + switch(post_op->type()) + { + case PostOpType::Activation: + { + const auto _post_op = utils::cast::polymorphic_downcast<const PostOpAct<FromTensorT> *>(post_op.get()); + transformed_post_ops.template push_back_op<PostOpAct<ToTensorT>>(_post_op->_act_info); + break; + } + case PostOpType::Eltwise_Add: + { + const auto _post_op = utils::cast::polymorphic_downcast<const PostOpEltwiseAdd<FromTensorT> *>(post_op.get()); + transformed_post_ops.template push_back_op<PostOpEltwiseAdd<ToTensorT>>(transform_arg(_post_op->_addend), _post_op->_prev_dst_pos, _post_op->_policy); + break; + } + case PostOpType::Eltwise_PRelu: + { + const auto _post_op = utils::cast::polymorphic_downcast<const PostOpEltwisePRelu<FromTensorT> *>(post_op.get()); + transformed_post_ops.template push_back_op<PostOpEltwisePRelu<ToTensorT>>(transform_arg(_post_op->_alpha_param), _post_op->_prev_dst_pos, _post_op->_policy); + break; + } + default: + { + ARM_COMPUTE_ERROR("Unsupported PostOpType"); + } + } + ++op_idx; + } + return transformed_post_ops; +} + +/** Get post op argument TensorType from post op argument index in a flattened, ordered post op argument list */ +inline TensorType get_post_op_arg_type(size_t index) +{ + ARM_COMPUTE_ERROR_ON_MSG(static_cast<int>(index) > EXPERIMENTAL_ACL_POST_OP_ARG_LAST - EXPERIMENTAL_ACL_POST_OP_ARG_FIRST, "Post Op argument index is out of range"); + return static_cast<TensorType>(EXPERIMENTAL_ACL_POST_OP_ARG_FIRST + static_cast<int>(index)); +} + +/** Get a sequence of PostOp Types from PostOpList */ +template <typename T> +PostOpTypeSequence get_post_op_sequence(const PostOpList<T> &post_ops) +{ + PostOpTypeSequence post_op_sequence; + for(const auto &op : post_ops.get_list()) + { + post_op_sequence.push_back(op->type()); + } + return post_op_sequence; +} + +} // namespace experimental +} // namespace arm_compute +#endif //ARM_COMPUTE_EXPERIMENTAL_POSTOPUTILS diff --git a/src/gpu/cl/kernels/ClGemmMatrixMultiplyNativeKernel.cpp b/src/gpu/cl/kernels/ClGemmMatrixMultiplyNativeKernel.cpp index 350312f6fe..af794354c3 100644 --- a/src/gpu/cl/kernels/ClGemmMatrixMultiplyNativeKernel.cpp +++ b/src/gpu/cl/kernels/ClGemmMatrixMultiplyNativeKernel.cpp @@ -34,7 +34,7 @@ #include "arm_compute/core/utils/misc/ShapeCalculator.h" #include "src/core/AccessWindowStatic.h" #include "src/core/CL/CLUtils.h" -#include "src/core/experimental/PostOp.h" +#include "src/core/experimental/PostOpUtils.h" #include "src/core/helpers/AutoConfiguration.h" #include "src/core/helpers/WindowHelpers.h" #include "src/core/utils/helpers/float_ops.h" diff --git a/src/gpu/cl/kernels/ClGemmMatrixMultiplyReshapedKernel.cpp b/src/gpu/cl/kernels/ClGemmMatrixMultiplyReshapedKernel.cpp index 52c8cd4fd5..64e99332fd 100644 --- a/src/gpu/cl/kernels/ClGemmMatrixMultiplyReshapedKernel.cpp +++ b/src/gpu/cl/kernels/ClGemmMatrixMultiplyReshapedKernel.cpp @@ -34,7 +34,7 @@ #include "arm_compute/core/utils/misc/ShapeCalculator.h" #include "src/core/CL/CLUtils.h" #include "src/core/CL/CLValidate.h" -#include "src/core/experimental/PostOp.h" +#include "src/core/experimental/PostOpUtils.h" #include "src/core/helpers/AutoConfiguration.h" #include "src/core/helpers/WindowHelpers.h" #include "src/core/utils/helpers/float_ops.h" diff --git a/src/gpu/cl/kernels/ClGemmMatrixMultiplyReshapedOnlyRhsKernel.cpp b/src/gpu/cl/kernels/ClGemmMatrixMultiplyReshapedOnlyRhsKernel.cpp index 633c2630cf..aa806978ef 100644 --- a/src/gpu/cl/kernels/ClGemmMatrixMultiplyReshapedOnlyRhsKernel.cpp +++ b/src/gpu/cl/kernels/ClGemmMatrixMultiplyReshapedOnlyRhsKernel.cpp @@ -27,7 +27,7 @@ #include "arm_compute/core/utils/misc/ShapeCalculator.h" #include "src/core/CL/CLUtils.h" #include "src/core/CL/CLValidate.h" -#include "src/core/experimental/PostOp.h" +#include "src/core/experimental/PostOpUtils.h" #include "src/core/helpers/AutoConfiguration.h" #include "src/core/helpers/WindowHelpers.h" #include "src/core/utils/helpers/float_ops.h" diff --git a/src/runtime/CL/functions/CLConvolutionLayer.cpp b/src/runtime/CL/functions/CLConvolutionLayer.cpp index d75f54f19c..20d7292d38 100644 --- a/src/runtime/CL/functions/CLConvolutionLayer.cpp +++ b/src/runtime/CL/functions/CLConvolutionLayer.cpp @@ -29,6 +29,7 @@ #include "arm_compute/core/utils/misc/ShapeCalculator.h" #include "arm_compute/runtime/CL/functions/CLFFTConvolutionLayer.h" #include "src/core/CL/ICLKernel.h" +#include "src/core/experimental/PostOpUtils.h" #include "src/core/helpers/MemoryHelpers.h" #include "src/gpu/cl/operators/ClConv2d.h" diff --git a/src/runtime/CL/functions/CLGEMMConvolutionLayer.cpp b/src/runtime/CL/functions/CLGEMMConvolutionLayer.cpp index 1eabee65f8..ad5bfd8dd2 100644 --- a/src/runtime/CL/functions/CLGEMMConvolutionLayer.cpp +++ b/src/runtime/CL/functions/CLGEMMConvolutionLayer.cpp @@ -31,7 +31,7 @@ #include "arm_compute/core/utils/misc/ShapeCalculator.h" #include "arm_compute/core/utils/quantization/AsymmHelpers.h" #include "arm_compute/runtime/CL/CLScheduler.h" -#include "src/core/experimental/PostOp.h" +#include "src/core/experimental/PostOpUtils.h" #include "src/core/helpers/MemoryHelpers.h" #include "src/gpu/cl/operators/ClGemmConv2d.h" #include "support/Cast.h" diff --git a/tests/validation/CL/ConvolutionLayer.cpp b/tests/validation/CL/ConvolutionLayer.cpp index ff28ac0985..10b67075e2 100644 --- a/tests/validation/CL/ConvolutionLayer.cpp +++ b/tests/validation/CL/ConvolutionLayer.cpp @@ -22,12 +22,12 @@ * SOFTWARE. */ #include "arm_compute/core/Types.h" +#include "arm_compute/core/experimental/PostOps.h" #include "arm_compute/core/utils/misc/ShapeCalculator.h" #include "arm_compute/runtime/CL/CLTensor.h" #include "arm_compute/runtime/CL/CLTensorAllocator.h" #include "arm_compute/runtime/CL/functions/CLConvolutionLayer.h" #include "arm_compute/runtime/CL/functions/CLGEMMConvolutionLayer.h" -#include "src/core/experimental/PostOp.h" #include "tests/CL/CLAccessor.h" #include "tests/PaddingCalculator.h" #include "tests/datasets/LargeConvolutionLayerDataset.h" diff --git a/tests/validation/CL/GEMMMatrixMultiplyReshaped.cpp b/tests/validation/CL/GEMMMatrixMultiplyReshaped.cpp index 37e25e9cf8..e75a352ffa 100644 --- a/tests/validation/CL/GEMMMatrixMultiplyReshaped.cpp +++ b/tests/validation/CL/GEMMMatrixMultiplyReshaped.cpp @@ -23,10 +23,10 @@ */ #include "arm_compute/core/KernelDescriptors.h" #include "arm_compute/core/Types.h" +#include "arm_compute/core/experimental/PostOps.h" #include "arm_compute/core/utils/misc/ShapeCalculator.h" #include "arm_compute/runtime/CL/CLTensor.h" #include "arm_compute/runtime/CL/CLTensorAllocator.h" -#include "src/core/experimental/PostOp.h" #include "src/gpu/cl/kernels/ClGemmMatrixMultiplyReshapedKernel.h" #include "src/gpu/cl/kernels/ClGemmReshapeLhsMatrixKernel.h" #include "src/gpu/cl/kernels/ClGemmReshapeRhsMatrixKernel.h" diff --git a/tests/validation/CL/GEMMMatrixMultiplyReshapedOnlyRHS.cpp b/tests/validation/CL/GEMMMatrixMultiplyReshapedOnlyRHS.cpp index 4c482b49aa..ca63d3a679 100644 --- a/tests/validation/CL/GEMMMatrixMultiplyReshapedOnlyRHS.cpp +++ b/tests/validation/CL/GEMMMatrixMultiplyReshapedOnlyRHS.cpp @@ -23,10 +23,10 @@ */ #include "arm_compute/core/KernelDescriptors.h" #include "arm_compute/core/Types.h" +#include "arm_compute/core/experimental/PostOps.h" #include "arm_compute/core/utils/misc/ShapeCalculator.h" #include "arm_compute/runtime/CL/CLTensor.h" #include "arm_compute/runtime/CL/CLTensorAllocator.h" -#include "src/core/experimental/PostOp.h" #include "src/gpu/cl/kernels/ClGemmMatrixMultiplyReshapedOnlyRhsKernel.h" #include "src/gpu/cl/kernels/ClGemmReshapeRhsMatrixKernel.h" #include "tests/CL/CLAccessor.h" diff --git a/tests/validation/fixtures/GEMMFixture.h b/tests/validation/fixtures/GEMMFixture.h index fa273018a4..52cd6759a7 100644 --- a/tests/validation/fixtures/GEMMFixture.h +++ b/tests/validation/fixtures/GEMMFixture.h @@ -28,7 +28,7 @@ #include "arm_compute/core/TensorShape.h" #include "arm_compute/core/Types.h" #include "arm_compute/core/experimental/IPostOp.h" -#include "src/core/experimental/PostOp.h" +#include "src/core/experimental/PostOpUtils.h" #include "tests/AssetsLibrary.h" #include "tests/Globals.h" #include "tests/IAccessor.h" diff --git a/tests/validation/reference/PostOps.cpp b/tests/validation/reference/PostOps.cpp index a81b1c1905..ecfed4c48f 100644 --- a/tests/validation/reference/PostOps.cpp +++ b/tests/validation/reference/PostOps.cpp @@ -25,7 +25,8 @@ #include "arm_compute/core/Helpers.h" #include "arm_compute/core/Types.h" -#include "src/core/experimental/PostOp.h" +#include "arm_compute/core/experimental/PostOps.h" +#include "support/Cast.h" #include "tests/validation/reference/ActivationLayer.h" #include "tests/validation/reference/ElementwiseOperations.h" diff --git a/utils/TypePrinter.h b/utils/TypePrinter.h index 9858478c29..e152cf6fc3 100644 --- a/utils/TypePrinter.h +++ b/utils/TypePrinter.h @@ -37,11 +37,12 @@ #include "arm_compute/core/TensorInfo.h" #include "arm_compute/core/Types.h" #include "arm_compute/core/experimental/IPostOp.h" +#include "arm_compute/core/experimental/PostOps.h" #include "arm_compute/runtime/CL/CLTunerTypes.h" #include "arm_compute/runtime/CL/CLTypes.h" #include "arm_compute/runtime/FunctionDescriptors.h" #include "arm_compute/runtime/common/LSTMParams.h" -#include "src/core/experimental/PostOp.h" +#include "support/Cast.h" #include "support/StringSupport.h" #include <ostream> #include <sstream> |