From 3b162e53267d13d18891baf3372f971f1d4213d3 Mon Sep 17 00:00:00 2001 From: David Svantesson Date: Tue, 28 Mar 2023 14:13:32 +0000 Subject: Reorder added Adds Reorder kernel exposing blocking reorders from arm_gemm Resolves ONCPUML-1232 Change-Id: I42bf4166311fe1771565134d3ed7039fc8e30230 Signed-off-by: David Svantesson Reviewed-on: https://review.mlplatform.org/c/ml/ComputeLibrary/+/9500 Comments-Addressed: Arm Jenkins Reviewed-by: SiCong Li Tested-by: Arm Jenkins Benchmark: Arm Jenkins --- arm_compute/runtime/NEON/NEFunctions.h | 1 + .../runtime/NEON/functions/NEReorderLayer.h | 84 ++++++++++++++++++++++ 2 files changed, 85 insertions(+) create mode 100644 arm_compute/runtime/NEON/functions/NEReorderLayer.h (limited to 'arm_compute') diff --git a/arm_compute/runtime/NEON/NEFunctions.h b/arm_compute/runtime/NEON/NEFunctions.h index 836cba7699..3a10310452 100644 --- a/arm_compute/runtime/NEON/NEFunctions.h +++ b/arm_compute/runtime/NEON/NEFunctions.h @@ -93,6 +93,7 @@ #include "arm_compute/runtime/NEON/functions/NERange.h" #include "arm_compute/runtime/NEON/functions/NEReduceMean.h" #include "arm_compute/runtime/NEON/functions/NEReductionOperation.h" +#include "arm_compute/runtime/NEON/functions/NEReorderLayer.h" #include "arm_compute/runtime/NEON/functions/NEReorgLayer.h" #include "arm_compute/runtime/NEON/functions/NEReshapeLayer.h" #include "arm_compute/runtime/NEON/functions/NEReverse.h" diff --git a/arm_compute/runtime/NEON/functions/NEReorderLayer.h b/arm_compute/runtime/NEON/functions/NEReorderLayer.h new file mode 100644 index 0000000000..4d5e3fa850 --- /dev/null +++ b/arm_compute/runtime/NEON/functions/NEReorderLayer.h @@ -0,0 +1,84 @@ +/* + * Copyright (c) 2023 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 ACL_ARM_COMPUTE_RUNTIME_NEON_FUNCTIONS_NEREORDERLAYER +#define ACL_ARM_COMPUTE_RUNTIME_NEON_FUNCTIONS_NEREORDERLAYER + +#include "arm_compute/core/Types.h" +#include "arm_compute/runtime/IFunction.h" +#include "src/core/NEON/kernels/NEReorderKernel.h" + +namespace arm_compute +{ +class ITensor; +class ITensorInfo; +/** Function to compute blocked reorder. */ +class NEReorderLayer : public IFunction +{ +public: + /** Default constructor */ + NEReorderLayer(); + /** Prevent instances of this class from being copied (As this class contains pointers) */ + NEReorderLayer(const NEReorderLayer &) = delete; + /** Prevent instances of this class from being copied (As this class contains pointers) */ + NEReorderLayer &operator=(const NEReorderLayer &) = delete; + /** Prevent instances of this class from being moved (As this class contains non movable objects) */ + NEReorderLayer(NEReorderLayer &&) = delete; + /** Prevent instances of this class from being moved (As this class contains non movable objects) */ + NEReorderLayer &operator=(NEReorderLayer &&) = delete; + /** Default destructor */ + ~NEReorderLayer() = default; + /** Set the input and output tensors. + * + * Valid data layouts: + * - NCHW + * + * Valid data type configurations: + * |src |dst | + * |:--------|:---------| + * |F32 |F32 | + * + * @param[in] input Source tensor. Data type supported: F32. Data layouts supported: NCHW. + * @param[out] output Destination with the same dimensions, data type, data layout as @p input + * except last dimension of data layout which needs to be multiple of blocking parameter ksize + * @param[in] input_wf WeightFormat of input. + * @param[in] output_wf WeightFormat of output. + */ + void configure(const ITensor *input, ITensor *output, arm_compute::WeightFormat input_wf, arm_compute::WeightFormat output_wf); + + /** Static function to check if given info will lead to a valid configuration of @ref NEReorderLayer + * + * Similar to @ref NEReorderLayer::configure() + * + * @return a status + */ + static Status validate(const ITensorInfo *input, const ITensorInfo *output, arm_compute::WeightFormat input_wf, arm_compute::WeightFormat output_wf); + + // Inherited methods overridden: + void run() override; + +private: + std::unique_ptr _reorder_kernel; /**< Reorder layer kernel */ +}; +} // namespace arm_compute +#endif /* ACL_ARM_COMPUTE_RUNTIME_NEON_FUNCTIONS_NEREORDERLAYER */ -- cgit v1.2.1