ONE - On-device Neural Engine
Loading...
Searching...
No Matches
TopKV2.cc
Go to the documentation of this file.
1/*
2 * Copyright (c) 2025 Samsung Electronics Co., Ltd. All Rights Reserved
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#include "../KernelGenerator.h"
18#include "../Validator.h"
19
20#include <AclKernelGen.h>
21
23{
24
25void Validator::visit(const ir::operation::TopKV2 &) { _supported = true; }
26
27void KernelGenerator::visit(const ir::operation::TopKV2 &node)
28{
29 const auto outputValues_index{node.getOutputs().at(ir::operation::TopKV2::Output::OUTPUT_VALUES)};
30 const auto outputIndices_index{
32
33 const auto inputData_index{node.getInputs().at(ir::operation::TopKV2::Input::INPUT)};
34
35 // Currently, we only support the vector input.
36 assert(_ctx.at(inputData_index).shape().rank() == 1 ||
37 _ctx.at(inputData_index).shape().rank() == 2);
38
39 const auto k = node.param().k;
40
41 auto values_tensor = _tensor_reg->getAclTensor(outputValues_index);
42 auto indices_tensor = _tensor_reg->getAclTensor(outputIndices_index);
43 auto input_tensor = _tensor_reg->getAclTensor(inputData_index);
44
45 auto fn = acl_common::generateLayer<arm_compute::CLTopKV2>(
46 input_tensor->handle(), k, values_tensor->handle(), indices_tensor->handle());
47
49}
50
51} // namespace onert::backend::acl_cl
std::unique_ptr< exec::IFunction > _return_fn
const Object & at(const Index &index) const
Get the object that is associated with the given index.
std::unique_ptr< AclFunction > asAclFunction(std::unique_ptr<::arm_compute::IFunction > &&layer)
Definition Convert.cc:246