ONE - On-device Neural Engine
Loading...
Searching...
No Matches
BatchToSpaceND.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::BatchToSpaceND &) { _supported = true; }
26
27void KernelGenerator::visit(const ir::operation::BatchToSpaceND &node)
28{
29 const auto ofm_index{node.getOutputs().at(0)};
30 const auto ifm_index{node.getInputs().at(ir::operation::BatchToSpaceND::Input::INPUT)};
31 const auto block_size_index{
33
34 const auto NNApiInputs = 2;
35 if (node.getInputs().size() != NNApiInputs)
36 {
37 const auto crops_index{node.getInputs().at(ir::operation::BatchToSpaceND::Input::CROPS_DATA)};
38 if (!_ctx.at(crops_index).isConstant())
39 {
40 throw std::runtime_error("Non-constant crops NYI for acl_neon backend BatchToSpaceND");
41 }
42
43 auto crops = _ctx.at(crops_index).asVector<int32_t>();
44 for (auto &&crop : crops)
45 {
46 if (crop != 0)
47 {
48 throw std::runtime_error("Non-zero crops NYI for acl_neon backend BatchToSpaceND");
49 }
50 }
51 }
52
53 auto ofm_tensor = _tensor_reg->getAclTensor(ofm_index);
54 auto ifm_tensor = _tensor_reg->getAclTensor(ifm_index);
55
56 if (!_ctx.at(block_size_index).data())
57 throw std::runtime_error("ACL NEON does not support dynamic block size for BatchToSpaceND");
58
59 auto block = _ctx.at(block_size_index).asVector<int32_t>();
60 int32_t height = block[0];
61 int32_t width = block[1];
62
63 auto fn = acl_common::generateLayer<arm_compute::NEBatchToSpaceLayer>(
64 ifm_tensor->handle(), width, height, ofm_tensor->handle());
65
67}
68
69} // 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.
std::unique_ptr< AclFunction > asAclFunction(std::unique_ptr<::arm_compute::IFunction > &&layer)
Definition Convert.cc:246