ArmNN
 24.08
UtilsGpuFsa.cpp
Go to the documentation of this file.
1 //
2 // Copyright © 2023-2024 Arm Ltd and Contributors. All rights reserved.
3 // SPDX-License-Identifier: MIT
4 //
5 
6 #include "UtilsGpuFsa.hpp"
9 
10 using namespace armnn;
11 using namespace armnn::armcomputetensorutils;
12 using namespace arm_compute::experimental::dynamic_fusion;
13 
14 Conv2dAttributes CreateConv2dAttributes(const Convolution2dDescriptor& descriptor)
15 {
16  const arm_compute::Padding2D padInfo = BuildArmComputePaddingInfo(descriptor);
17  const arm_compute::Size2D strideInfo = BuildArmComputeSize2D(descriptor.m_StrideX, descriptor.m_StrideY);
18  const arm_compute::Size2D dilationInfo = BuildArmComputeSize2D(descriptor.m_DilationX, descriptor.m_DilationY);
19 
20  arm_compute::experimental::dynamic_fusion::Conv2dAttributes conv2dAttributes{};
21  conv2dAttributes.pad(padInfo);
22  conv2dAttributes.stride(strideInfo);
23  conv2dAttributes.dilation(dilationInfo);
24 
25  return conv2dAttributes;
26 }
27 
28 arm_compute::experimental::dynamic_fusion::DepthwiseConv2dAttributes
29 CreateDWConv2dAttributes(const DepthwiseConvolution2dDescriptor& descriptor, const unsigned int aclDepthMultiplier)
30 {
31  const arm_compute::Padding2D padInfo = BuildArmComputePaddingInfo(descriptor);
32  const arm_compute::Size2D strideInfo = BuildArmComputeSize2D(descriptor.m_StrideX, descriptor.m_StrideY);
33  const arm_compute::Size2D dilationInfo = BuildArmComputeSize2D(descriptor.m_DilationX, descriptor.m_DilationY);
34 
35  arm_compute::experimental::dynamic_fusion::DepthwiseConv2dAttributes depthwiseConv2dAttributes{};
36  depthwiseConv2dAttributes.pad(padInfo);
37  depthwiseConv2dAttributes.stride(strideInfo);
38  depthwiseConv2dAttributes.dilation(dilationInfo);
39  depthwiseConv2dAttributes.depth_multiplier(aclDepthMultiplier);
40 
41  return depthwiseConv2dAttributes;
42 }
43 
44 arm_compute::experimental::dynamic_fusion::Pool2dAttributes
46 {
47  const arm_compute::PoolingType poolType = ConvertPoolingAlgorithmToAclPoolingType(descriptor.m_PoolType);
48  const arm_compute::Padding2D padding = BuildArmComputePaddingInfo(descriptor);
49  const arm_compute::Size2D poolSize = BuildArmComputeSize2D(descriptor.m_PoolWidth, descriptor.m_PoolHeight);
50  const arm_compute::Size2D strides = BuildArmComputeSize2D(descriptor.m_StrideX, descriptor.m_StrideY);
51  const bool excludePadding = (descriptor.m_PaddingMethod == PaddingMethod::Exclude);
52 
53  arm_compute::experimental::dynamic_fusion::Pool2dAttributes pool2dAttributes{};
54  pool2dAttributes.pool_type(poolType);
55  pool2dAttributes.pad(padding);
56  pool2dAttributes.pool_size(poolSize);
57  pool2dAttributes.stride(strides);
58  pool2dAttributes.exclude_padding(excludePadding);
59 
60  return pool2dAttributes;
61 }
62 
63 arm_compute::experimental::dynamic_fusion::ResizeAttributes
65 {
66  arm_compute::experimental::dynamic_fusion::ResizeAttributes resizeAttributes{};
67  resizeAttributes.output_width(static_cast<int32_t>(descriptor.m_TargetWidth));
68  resizeAttributes.output_height(static_cast<int32_t>(descriptor.m_TargetHeight));
69  resizeAttributes.interpolation_policy(descriptor.m_Method == ResizeMethod::Bilinear ?
70  arm_compute::InterpolationPolicy::BILINEAR :
71  arm_compute::InterpolationPolicy::NEAREST_NEIGHBOR);
72  resizeAttributes.sampling_policy(descriptor.m_HalfPixelCenters ? arm_compute::SamplingPolicy::CENTER
73  : arm_compute::SamplingPolicy::TOP_LEFT);
74  resizeAttributes.align_corners(descriptor.m_AlignCorners);
75 
76  return resizeAttributes;
77 }
armnn::Pooling2dDescriptor::m_PaddingMethod
PaddingMethod m_PaddingMethod
The padding method to be used. (Exclude, IgnoreValue).
Definition: Descriptors.hpp:425
armnn::ResizeDescriptor::m_HalfPixelCenters
bool m_HalfPixelCenters
Half Pixel Centers.
Definition: Descriptors.hpp:1018
armnn::ResizeDescriptor::m_TargetHeight
uint32_t m_TargetHeight
Target height value.
Definition: Descriptors.hpp:1009
armnn::Pooling2dDescriptor::m_PoolHeight
uint32_t m_PoolHeight
Pooling height value.
Definition: Descriptors.hpp:417
armnn::ResizeDescriptor
A ResizeDescriptor for the ResizeLayer.
Definition: Descriptors.hpp:985
armnn::Pooling2dDescriptor::m_StrideY
uint32_t m_StrideY
Stride value when proceeding through input for the height dimension.
Definition: Descriptors.hpp:421
armnn::Convolution2dDescriptor::m_StrideY
uint32_t m_StrideY
Stride value when proceeding through input for the height dimension.
Definition: Descriptors.hpp:576
armnn::Pooling2dDescriptor::m_PoolWidth
uint32_t m_PoolWidth
Pooling width value.
Definition: Descriptors.hpp:415
armnn::DepthwiseConvolution2dDescriptor::m_StrideY
uint32_t m_StrideY
Stride value when proceeding through input for the height dimension.
Definition: Descriptors.hpp:702
armnn::Convolution2dDescriptor::m_DilationY
uint32_t m_DilationY
Dilation along y axis.
Definition: Descriptors.hpp:580
CreateResizeAttributes
arm_compute::experimental::dynamic_fusion::ResizeAttributes CreateResizeAttributes(const armnn::ResizeDescriptor &descriptor)
Utility function used to setup an arm_compute::ResizeDescriptor object from given descriptor.
Definition: UtilsGpuFsa.cpp:64
armnn::ResizeDescriptor::m_Method
ResizeMethod m_Method
The Interpolation method to use (Bilinear, NearestNeighbor).
Definition: Descriptors.hpp:1012
CreatePool2dAttributes
arm_compute::experimental::dynamic_fusion::Pool2dAttributes CreatePool2dAttributes(const Pooling2dDescriptor &descriptor)
Utility function used to setup an arm_compute::Pool2dAttributes object from given descriptor.
Definition: UtilsGpuFsa.cpp:45
armnn::DepthwiseConvolution2dDescriptor::m_DilationY
uint32_t m_DilationY
Dilation factor value for height dimension.
Definition: Descriptors.hpp:706
CreateConv2dAttributes
Conv2dAttributes CreateConv2dAttributes(const Convolution2dDescriptor &descriptor)
Utility function used to setup an arm_compute::Conv2dAttributes object from given descriptor.
Definition: UtilsGpuFsa.cpp:14
CreateDWConv2dAttributes
arm_compute::experimental::dynamic_fusion::DepthwiseConv2dAttributes CreateDWConv2dAttributes(const DepthwiseConvolution2dDescriptor &descriptor, const unsigned int aclDepthMultiplier)
Utility function used to setup an arm_compute::DepthwiseConv2dAttributes object from given descriptor...
Definition: UtilsGpuFsa.cpp:29
armnn::PaddingMethod::Exclude
@ Exclude
The padding fields don't count and are ignored.
ArmComputeUtils.hpp
armnn::Convolution2dDescriptor::m_StrideX
uint32_t m_StrideX
Stride value when proceeding through input for the width dimension.
Definition: Descriptors.hpp:574
armnn::Convolution2dDescriptor
A Convolution2dDescriptor for the Convolution2dLayer.
Definition: Descriptors.hpp:534
armnn::ResizeMethod::Bilinear
@ Bilinear
armnn::Pooling2dDescriptor::m_StrideX
uint32_t m_StrideX
Stride value when proceeding through input for the width dimension.
Definition: Descriptors.hpp:419
armnn::ResizeDescriptor::m_TargetWidth
uint32_t m_TargetWidth
Target width value.
Definition: Descriptors.hpp:1007
armnn::ResizeDescriptor::m_AlignCorners
bool m_AlignCorners
Aligned corners.
Definition: Descriptors.hpp:1016
armnn::Convolution2dDescriptor::m_DilationX
uint32_t m_DilationX
Dilation along x axis.
Definition: Descriptors.hpp:578
armnn
Copyright (c) 2021 ARM Limited and Contributors.
Definition: 01_00_quick_start.dox:6
ArmComputeTensorUtils.hpp
UtilsGpuFsa.hpp
armnn::Pooling2dDescriptor
A Pooling2dDescriptor for the Pooling2dLayer.
Definition: Descriptors.hpp:371
armnn::DepthwiseConvolution2dDescriptor
A DepthwiseConvolution2dDescriptor for the DepthwiseConvolution2dLayer.
Definition: Descriptors.hpp:659
armnn::DepthwiseConvolution2dDescriptor::m_DilationX
uint32_t m_DilationX
Dilation factor value for width dimension.
Definition: Descriptors.hpp:704
armnn::Pooling2dDescriptor::m_PoolType
PoolingAlgorithm m_PoolType
The pooling algorithm to use (Max. Average, L2).
Definition: Descriptors.hpp:405
armnn::ConvertPoolingAlgorithmToAclPoolingType
arm_compute::PoolingType ConvertPoolingAlgorithmToAclPoolingType(PoolingAlgorithm poolingAlgorithm)
Definition: ArmComputeUtils.hpp:155
armnn::DepthwiseConvolution2dDescriptor::m_StrideX
uint32_t m_StrideX
Stride value when proceeding through input for the width dimension.
Definition: Descriptors.hpp:700