ONE - On-device Neural Engine
Loading...
Searching...
No Matches
TransposeConv.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::TransposeConv &) { _supported = true; }
26
27void KernelGenerator::visit(const ir::operation::TransposeConv &node)
28{
29 const auto ofm_index{node.getOutputs().at(0)};
30 const auto ker_index{node.getInputs().at(ir::operation::TransposeConv::Input::KERNEL)};
31 const auto ifm_index{node.getInputs().at(ir::operation::TransposeConv::Input::INPUT)};
32
33 const auto ofm_shape = _ctx.at(ofm_index).shape().asFeature();
34 const auto ifm_shape = _ctx.at(ifm_index).shape().asFeature();
35 const auto ker_shape = _ctx.at(ker_index).shape().asFeature();
36
37 const auto stride = node.param().stride;
38
39 assert((node.param().padding.type == ir::PaddingType::SAME) ||
40 (node.param().padding.type == ir::PaddingType::VALID));
41 auto padding = ir::calculatePadding(node.param().padding, ofm_shape, ifm_shape, stride,
42 ker_shape.W, ker_shape.H);
43
44 auto ofm_tensor = _tensor_reg->getAclTensor(ofm_index);
45 auto ifm_tensor = _tensor_reg->getAclTensor(ifm_index);
46 auto ker_tensor = _tensor_reg->getAclTensor(ker_index);
47
48 const auto tconv_info = acl_common::asPadStrideInfo(padding, stride);
49
50 auto fn = acl_common::generateLayer<arm_compute::NEDeconvolutionLayer>(
51 ifm_tensor->handle(), ker_tensor->handle(), nullptr, ofm_tensor->handle(), tconv_info);
52
54}
55
56} // 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.
::arm_compute::PadStrideInfo asPadStrideInfo(const ir::ExplicitPadding &padding, const ir::Stride &stride)
Definition Convert.cc:119
std::unique_ptr< AclFunction > asAclFunction(std::unique_ptr<::arm_compute::IFunction > &&layer)
Definition Convert.cc:246
const ExplicitPadding calculatePadding(const Padding &padding, const FeatureShape &ifm_shape, const FeatureShape &ofm_shape, const Stride &stride, uint32_t kw, uint32_t kh, uint32_t dwf=1, uint32_t dhf=1)
Definition Padding.cc:131
CLTensor ker_tensor