ONE - On-device Neural Engine
Loading...
Searching...
No Matches
Unpack.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::Unpack &) { _supported = true; }
26
27void KernelGenerator::visit(const ir::operation::Unpack &node)
28{
29 const auto input_index{node.getInputs().at(ir::operation::Unpack::Input::INPUT)};
30 auto axis{node.param().axis};
31
32 const auto input_rank = _ctx.at(input_index).shape().rank();
33
34 std::vector<ir::OperandIndex> output_indexes;
35 for (const auto &output_index : node.getOutputs())
36 output_indexes.emplace_back(output_index);
37
38 auto input_tensor = _tensor_reg->getAclTensor(input_index);
39 std::vector<arm_compute::ITensor *> outputs;
40 for (const auto &output_index : output_indexes)
41 outputs.emplace_back(_tensor_reg->getAclTensor(output_index)->handle());
42
43 if (axis < 0)
44 axis += input_rank;
45 axis = acl_common::ToARMComputeAxis(input_rank, axis).value();
46
47 // Disable applied dim_correction
48 if (static_cast<size_t>(input_tensor->getShape().rank()) !=
49 input_tensor->info()->num_dimensions())
50 {
51 // This means that high dimension's value is 1 and input tensor is applied dim_correction
53 }
54
55 auto fn =
56 acl_common::generateLayer<arm_compute::NEUnstack>(input_tensor->handle(), outputs, axis);
57
58 // Revert disabling applied dim_correction
59 if (input_tensor->getShape().dim(0) == 1)
60 {
62 }
63
65}
66
67} // namespace onert::backend::acl_neon
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
void enableDimCorrection(IACLTensor *tensor)
std::unique_ptr< AclFunction > asAclFunction(std::unique_ptr<::arm_compute::IFunction > &&layer)
Definition Convert.cc:246
void disableDimCorrection(IACLTensor *tensor)