ONE - On-device Neural Engine
Loading...
Searching...
No Matches
SplitV.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::SplitV &) { _supported = true; }
26
27void KernelGenerator::visit(const ir::operation::SplitV &node)
28{
29 const auto ifm_index{node.getInputs().at(ir::operation::SplitV::Input::INPUT)};
30 const auto size_split_index{node.getInputs().at(ir::operation::SplitV::Input::SIZE_SPLITS)};
31 const auto split_dim_index{node.getInputs().at(ir::operation::SplitV::Input::SPLIT_DIM)};
32
33 assert(node.param().num_splits == static_cast<int>(node.getOutputs().size()));
34 if (!_ctx.at(split_dim_index).isConstant() || !_ctx.at(size_split_index).isConstant())
35 {
36 throw std::runtime_error(
37 "Non-constant split_dim and size_split is not supported in acl_cl backend");
38 }
39
40 // size_split is not used because acl_cl backend is not supporting dynamic shape
41
42 const size_t ifm_rank = _ctx.at(ifm_index).shape().rank();
43 std::vector<ir::OperandIndex> output_indexes;
44 for (const auto &output : node.getOutputs())
45 output_indexes.emplace_back(output);
46
47 auto ifm_tensor = _tensor_reg->getAclTensor(ifm_index);
48 std::vector<arm_compute::ICLTensor *> output_tensors;
49 for (const auto &ofm_ind : output_indexes)
50 output_tensors.emplace_back(_tensor_reg->getAclTensor(ofm_ind)->handle());
51
52 auto axis = _ctx.at(split_dim_index).asScalar<int32_t>();
53 if (axis < 0)
54 axis += ifm_rank;
55 axis = acl_common::ToARMComputeAxis(ifm_rank, axis).value();
56
57 auto fn =
58 acl_common::generateLayer<arm_compute::CLSplit>(ifm_tensor->handle(), output_tensors, axis);
59
61}
62
63} // 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.
ARMComputeAxis ToARMComputeAxis(uint32_t rank, uint32_t axis)
Definition Swizzle.h:45
std::unique_ptr< AclFunction > asAclFunction(std::unique_ptr<::arm_compute::IFunction > &&layer)
Definition Convert.cc:246