Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions Android.bp
Original file line number Diff line number Diff line change
Expand Up @@ -462,6 +462,7 @@ cc_library_static {
"src/cpu/kernels/CpuScatterKernel.cpp",
"src/cpu/kernels/CpuSoftmaxKernel.cpp",
"src/cpu/kernels/CpuSubKernel.cpp",
"src/cpu/kernels/CpuTopKVKernel.cpp",
"src/cpu/kernels/CpuTransposeKernel.cpp",
"src/cpu/kernels/CpuWeightsReshapeKernel.cpp",
"src/cpu/kernels/CpuWinogradConv2dKernel.cpp",
Expand Down Expand Up @@ -611,6 +612,10 @@ cc_library_static {
"src/cpu/kernels/sub/neon/qasymm8.cpp",
"src/cpu/kernels/sub/neon/qasymm8_signed.cpp",
"src/cpu/kernels/sub/neon/qsymm16.cpp",
"src/cpu/kernels/topkv/generic/neon/fp16.cpp",
"src/cpu/kernels/topkv/generic/neon/fp32.cpp",
"src/cpu/kernels/topkv/generic/neon/qasymm8.cpp",
"src/cpu/kernels/topkv/generic/neon/qasymm8_signed.cpp",
"src/cpu/operators/CpuActivation.cpp",
"src/cpu/operators/CpuAdd.cpp",
"src/cpu/operators/CpuAddMulAdd.cpp",
Expand Down Expand Up @@ -649,6 +654,7 @@ cc_library_static {
"src/cpu/operators/CpuScatter.cpp",
"src/cpu/operators/CpuSoftmax.cpp",
"src/cpu/operators/CpuSub.cpp",
"src/cpu/operators/CpuTopKV.cpp",
"src/cpu/operators/CpuTranspose.cpp",
"src/cpu/operators/CpuWinogradConv2d.cpp",
"src/cpu/operators/internal/CpuGemmAssemblyDispatch.cpp",
Expand Down Expand Up @@ -978,6 +984,7 @@ cc_library_static {
"src/runtime/NEON/functions/NEStackLayer.cpp",
"src/runtime/NEON/functions/NEStridedSlice.cpp",
"src/runtime/NEON/functions/NETile.cpp",
"src/runtime/NEON/functions/NETopKV.cpp",
"src/runtime/NEON/functions/NETranspose.cpp",
"src/runtime/NEON/functions/NEUnstack.cpp",
"src/runtime/NEON/functions/NEWinogradConvolutionLayer.cpp",
Expand Down
3 changes: 2 additions & 1 deletion arm_compute/runtime/NEON/NEFunctions.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2016-2025 Arm Limited.
* Copyright (c) 2016-2026 Arm Limited.
*
* SPDX-License-Identifier: MIT
*
Expand Down Expand Up @@ -112,6 +112,7 @@
#include "arm_compute/runtime/NEON/functions/NEStackLayer.h"
#include "arm_compute/runtime/NEON/functions/NEStridedSlice.h"
#include "arm_compute/runtime/NEON/functions/NETile.h"
#include "arm_compute/runtime/NEON/functions/NETopKV.h"
#include "arm_compute/runtime/NEON/functions/NETranspose.h"
#include "arm_compute/runtime/NEON/functions/NEUnstack.h"
#include "arm_compute/runtime/NEON/functions/NEWinogradConvolutionLayer.h"
Expand Down
87 changes: 87 additions & 0 deletions arm_compute/runtime/NEON/functions/NETopKV.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
/*
* Copyright (c) 2026 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_NETOPKV_H
#define ACL_ARM_COMPUTE_RUNTIME_NEON_FUNCTIONS_NETOPKV_H

/** @file
* @publicapi
*/

#include "arm_compute/core/Error.h"
#include "arm_compute/runtime/IFunction.h"

#include <memory>

namespace arm_compute
{
// Forward declarations
class ITensor;
class ITensorInfo;

/** Basic function to run cpu::kernels::CpuActivationKernel
*
* @note The function simulates an activation layer with the specified activation function.
*/
class NETopKV : public IFunction
{
public:
/** Constructor */
NETopKV();
/** Prevent instances of this class from being copied (As this class contains pointers) */
NETopKV(const NETopKV &) = delete;
/** Default move constructor */
NETopKV(NETopKV &&);
/** Prevent instances of this class from being copied (As this class contains pointers) */
NETopKV &operator=(const NETopKV &) = delete;
/** Default move assignment operator */
NETopKV &operator=(NETopKV &&);
/** Destructor */
~NETopKV();
/** Set the input and output of the kernel.
*
* @param[in] predictions A batch_size x classes tensor. Data types supported: F16/F32/QASYMM8/QASYMM8_SIGNED
* @param[in] targets A batch_size 1D tensor of class ids. Data types supported: U32
* @param[out] output Computed precision at @p k as a bool 1D tensor. Data types supported: U8
* @param[in] k Number of top elements to look at for computing precision.
*/
void configure(const ITensor *predictions, const ITensor *targets, ITensor *output, const unsigned int k);

/** Static function to check if given info will lead to a valid configuration.
*
* Similar to @ref NETopKV::configure()
*
* @return a status
*/
static Status
validate(const ITensorInfo *predictions, const ITensorInfo *targets, ITensorInfo *output, const unsigned int k);

// Inherited methods overridden
void run() override;

private:
struct Impl;
std::unique_ptr<Impl> _impl;
};
} // namespace arm_compute
#endif // ACL_ARM_COMPUTE_RUNTIME_NEON_FUNCTIONS_NETOPKV_H
20 changes: 20 additions & 0 deletions filelist.json
Original file line number Diff line number Diff line change
Expand Up @@ -2453,6 +2453,26 @@
]
}
},
"TopKV": {
"files": {
"common": [
"src/cpu/kernels/CpuTopKVKernel.cpp",
"src/cpu/operators/CpuTopKV.cpp",
"src/runtime/NEON/functions/NETopKV.cpp"
],
"neon": {
"fp16": [ "src/cpu/kernels/topkv/generic/neon/fp16.cpp" ],
"fp32": [ "src/cpu/kernels/topkv/generic/neon/fp32.cpp" ],
"qasymm8": [
"src/cpu/kernels/topkv/generic/neon/qasymm8.cpp"
],
"qasymm8_signed": [
"src/cpu/kernels/topkv/generic/neon/qasymm8_signed.cpp"
]
}

}
},
"Transpose": {
"files": {
"common": [
Expand Down
9 changes: 8 additions & 1 deletion src/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -738,6 +738,7 @@ filegroup(
"cpu/kernels/CpuScatterKernel.cpp",
"cpu/kernels/CpuSoftmaxKernel.cpp",
"cpu/kernels/CpuSubKernel.cpp",
"cpu/kernels/CpuTopKVKernel.cpp",
"cpu/kernels/CpuTransposeKernel.cpp",
"cpu/kernels/CpuWeightsReshapeKernel.cpp",
"cpu/kernels/CpuWinogradConv2dKernel.cpp",
Expand Down Expand Up @@ -848,6 +849,9 @@ filegroup(
"cpu/kernels/sub/neon/qasymm8.cpp",
"cpu/kernels/sub/neon/qasymm8_signed.cpp",
"cpu/kernels/sub/neon/qsymm16.cpp",
"cpu/kernels/topkv/generic/neon/fp32.cpp",
"cpu/kernels/topkv/generic/neon/qasymm8.cpp",
"cpu/kernels/topkv/generic/neon/qasymm8_signed.cpp",
"cpu/operators/CpuActivation.cpp",
"cpu/operators/CpuAdd.cpp",
"cpu/operators/CpuAddMulAdd.cpp",
Expand Down Expand Up @@ -886,6 +890,7 @@ filegroup(
"cpu/operators/CpuScatter.cpp",
"cpu/operators/CpuSoftmax.cpp",
"cpu/operators/CpuSub.cpp",
"cpu/operators/CpuTopKV.cpp",
"cpu/operators/CpuTranspose.cpp",
"cpu/operators/CpuWinogradConv2d.cpp",
"cpu/operators/internal/CpuGemmAssemblyDispatch.cpp",
Expand Down Expand Up @@ -994,6 +999,7 @@ filegroup(
"runtime/NEON/functions/NEStackLayer.cpp",
"runtime/NEON/functions/NEStridedSlice.cpp",
"runtime/NEON/functions/NETile.cpp",
"runtime/NEON/functions/NETopKV.cpp",
"runtime/NEON/functions/NETranspose.cpp",
"runtime/NEON/functions/NEUnstack.cpp",
"runtime/NEON/functions/NEWinogradConvolutionLayer.cpp",
Expand Down Expand Up @@ -1109,7 +1115,8 @@ filegroup(
"cpu/kernels/scatter/generic/neon/fp16.cpp",
"cpu/kernels/select/generic/neon/fp16.cpp",
"cpu/kernels/softmax/generic/neon/fp16.cpp",
"cpu/kernels/sub/neon/fp16.cpp"] +
"cpu/kernels/sub/neon/fp16.cpp",
"cpu/kernels/topkv/generic/neon/fp16.cpp"] +
glob(["**/*.h",
"**/*.hpp",
"**/*.inl"]),
Expand Down
7 changes: 7 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -732,6 +732,7 @@ target_sources(
cpu/kernels/CpuScatterKernel.cpp
cpu/kernels/CpuSoftmaxKernel.cpp
cpu/kernels/CpuSubKernel.cpp
cpu/kernels/CpuTopKVKernel.cpp
cpu/kernels/CpuTransposeKernel.cpp
cpu/kernels/CpuWeightsReshapeKernel.cpp
cpu/kernels/CpuWinogradConv2dKernel.cpp
Expand Down Expand Up @@ -842,6 +843,9 @@ target_sources(
cpu/kernels/sub/neon/qasymm8.cpp
cpu/kernels/sub/neon/qasymm8_signed.cpp
cpu/kernels/sub/neon/qsymm16.cpp
cpu/kernels/topkv/generic/neon/fp32.cpp
cpu/kernels/topkv/generic/neon/qasymm8.cpp
cpu/kernels/topkv/generic/neon/qasymm8_signed.cpp
cpu/operators/CpuActivation.cpp
cpu/operators/CpuAdd.cpp
cpu/operators/CpuAddMulAdd.cpp
Expand Down Expand Up @@ -880,6 +884,7 @@ target_sources(
cpu/operators/CpuScatter.cpp
cpu/operators/CpuSoftmax.cpp
cpu/operators/CpuSub.cpp
cpu/operators/CpuTopKV.cpp
cpu/operators/CpuTranspose.cpp
cpu/operators/CpuWinogradConv2d.cpp
cpu/operators/internal/CpuGemmAssemblyDispatch.cpp
Expand Down Expand Up @@ -988,6 +993,7 @@ target_sources(
runtime/NEON/functions/NEStackLayer.cpp
runtime/NEON/functions/NEStridedSlice.cpp
runtime/NEON/functions/NETile.cpp
runtime/NEON/functions/NETopKV.cpp
runtime/NEON/functions/NETranspose.cpp
runtime/NEON/functions/NEUnstack.cpp
runtime/NEON/functions/NEWinogradConvolutionLayer.cpp
Expand Down Expand Up @@ -1109,4 +1115,5 @@ target_sources(
cpu/kernels/select/generic/neon/fp16.cpp
cpu/kernels/softmax/generic/neon/fp16.cpp
cpu/kernels/sub/neon/fp16.cpp
cpu/kernels/topkv/generic/neon/fp16.cpp
)
Loading