24.02.1
|
Go to the documentation of this file.
98 auto f = std::make_unique<ClWinogradConv2d>();
101 _operator = std::move(f);
107 auto f = std::make_unique<ClDirectConv2d>();
109 _operator = std::move(f);
115 auto f = std::make_unique<ClIndirectConv2d>();
117 _operator = std::move(f);
122 auto f = std::make_unique<ClGemmConv2d>();
124 _operator = std::move(f);
131 _aux_mem = _operator->workspace();
143 "Grouping (num_groups != 1) with NHWC data layout is not supported");
153 "Grouping (num_groups != 1) with ClWinogradConv2d is not supported");
162 "Grouping (num_groups != 1) with ClDirectConv2d is not supported");
171 "Grouping (num_groups != 1) with ClIndirectConv2d is not supported");
212 using ConvolutionConfiguration = std::tuple<Size2D, Size2D, Size2D, PadStrideInfo, DataLayout>;
213 using ConfigurationMethod = std::pair<ConvolutionConfiguration, ConvolutionMethod>;
215 const std::vector<ConfigurationMethod> known_configs = {
225 ConfigurationMethod(ConvolutionConfiguration(
230 ConfigurationMethod(ConvolutionConfiguration(
235 ConfigurationMethod(ConvolutionConfiguration(
240 ConfigurationMethod(ConvolutionConfiguration(
246 const auto find_config = [&](ConfigurationMethod c)
248 const ConvolutionConfiguration config = c.first;
252 return std::get<0>(config) ==
Size2D(
src->dimension(idx_w),
src->dimension(idx_h)) &&
260 std::vector<ConfigurationMethod>::const_iterator found;
261 if ((found = std::find_if(known_configs.begin(), known_configs.end(), find_config)) != known_configs.end())
263 return (*found).second;
275 if ((
src->dimension(idx_h) > 720
U) && (
dst->dimension(idx_h) > 720
U) && (weights->
dimension(idx_h) == 9) &&
281 if ((weights->
dimension(idx_h) > 5) && (
src->dimension(idx_c) >
dst->dimension(idx_c)) &&
286 if (
src->dimension(idx_c) < 16)
296 const bool is_direct_valid =
298 const bool is_wino_valid =
300 const size_t kernel_sz_direct_conv_thr = get_direct_conv_kernel_threshold_nhwc(gpu_target);
303 if ((
src->dimension(idx_h) > 720
U) && (
dst->dimension(idx_h) > 720
U) && (weights->
dimension(idx_h) == 9) &&
304 (
conv_info.pad_top() < 3) && is_direct_valid)
315 const bool is_large_kernel_sz = (weights->
dimension(idx_w) >= kernel_sz_direct_conv_thr) &&
316 (weights->
dimension(idx_h) >= kernel_sz_direct_conv_thr);
317 const bool is_ifm_ge_8 =
src->dimension(idx_c) >= 8;
318 const bool is_ifm_ge_16 =
src->dimension(idx_c) >= 16;
319 const bool is_ofm_lte_8 = weights->
dimension(3
U) <= 8;
320 const bool is_ofm_lt_64 = weights->
dimension(3
U) < 64;
322 const bool is_ifm_gt_ofm =
src->dimension(idx_c) > weights->
dimension(3
U);
324 const bool is_unit_stride =
329 if (is_wino_valid && is_ifm_ge_8)
351 if (is_large_kernel_sz && is_ifm_ge_16 && is_ifm_gt_ofm)
358 if ((is_large_kernel_sz && workload_gte_8192 && is_ifm_ge_16) || (is_ofm_lte_8 && is_ifm_ge_16))
367 const bool is_indirect_valid =
374 if (is_indirect_valid)
376 const bool is_kernel_sz_odd = kernel_sz % 2;
378 preferred_conv_method = (kernel_sz > 1) && (kernel_sz <= 81) && is_kernel_sz_odd && is_g77
384 if (workload_gte_8192 && !is_ifm_ge_16 && !is_unit_stride && is_ofm_lt_64)
390 return preferred_conv_method;
393 if ((is_large_kernel_sz || is_m_one) && workload_gte_8192 && is_ifm_ge_16)
395 return preferred_conv_method;
401 return preferred_conv_method;
419 _operator->run(tensors);
424 _operator->prepare(tensors);
@ NCHW
Num samples, channels, height, width.
std::vector< MemoryInfo > MemoryRequirements
Convolution Layer Weights Information class.
SimpleTensor< float > src
@ FFT
Convolution using FFT.
DataLayout
[DataLayout enum definition]
static Status validate(const ITensorInfo *src, const ITensorInfo *weights, const ITensorInfo *biases, const ITensorInfo *dst, const Conv2dInfo &conv2d_info, const WeightsInfo &weights_info=WeightsInfo())
Static function to check if given info will lead to a valid configuration of ClConv2d.
@ NHWC
Num samples, height, width, channels.
@ INDIRECT
Indirect convolution.
#define ARM_COMPUTE_ERROR(msg)
Print the given message then throw an std::runtime_error.
Class for specifying the size of an image or rectangle.
static ConvolutionMethod get_convolution_method(const ITensorInfo *src, const ITensorInfo *weights, const ITensorInfo *dst, const Conv2dInfo &conv2d_info, const WeightsInfo &weights_info, const GPUTarget gpu_target)
Static function to check if given info will return the convolution called by ClConv2d.
static Status validate(const ITensorInfo *src, const ITensorInfo *weights, const ITensorInfo *biases, const ITensorInfo *dst, const PadStrideInfo &conv_info, const ActivationLayerInfo &act_info=ActivationLayerInfo())
Static function to check if given info will lead to a valid configuration.
experimental::MemoryRequirements workspace() const override
Return the memory requirements required by the workspace.
constexpr auto data_layout
Descriptor used by the 2d Convolution function.
#define ARM_COMPUTE_RETURN_ON_ERROR(status)
Checks if a status contains an error and returns it.
ConvolutionMethod
Available ConvolutionMethod.
virtual size_t dimension(size_t index) const =0
Return the size of the requested dimension.
Activation Layer Information class.
#define ARM_COMPUTE_ERROR_ON_NULLPTR(...)
#define ARM_COMPUTE_ERROR_ON(cond)
If the condition is true then an error message is printed and an exception thrown.
#define ARM_COMPUTE_ERROR_THROW_ON(status)
~ClConv2d()
Default Destructor.
GPUTarget get_arch_from_target(GPUTarget target)
Helper function to get the GPU arch.
Interface to enqueue OpenCL kernels and get/set the OpenCL CommandQueue and ICLTuner.
@ WINOGRAD
Convolution using Winograd.
ActivationLayerInfo act_info
@ GEMM
Convolution using GEMM.
void prepare(ITensorPack &tensors) override
Prepare the function for executing.
static Status validate(const ITensorInfo *src, const ITensorInfo *weights, const ITensorInfo *biases, const ITensorInfo *dst, const PadStrideInfo &conv_info, const ActivationLayerInfo &act_info=ActivationLayerInfo())
Static function to check if given info will lead to a valid configuration.
static Status validate(const ITensorInfo *input, const ITensorInfo *weights, const ITensorInfo *biases, const ITensorInfo *output, const PadStrideInfo &conv_info, const ActivationLayerInfo &act_info=ActivationLayerInfo(), bool enable_fast_math=false)
Static function to check if given info will lead to a valid configuration of CLFFTConvolutionLayer.
#define ARM_COMPUTE_UNUSED(...)
To avoid unused variables warnings.
static CLScheduler & get()
Access the scheduler singleton.
@ DIRECT
Direct convolution.
ClConv2d()
Default constructor.
static Status validate(const ITensorInfo *input, const ITensorInfo *weights, const ITensorInfo *biases, const ITensorInfo *output, const Conv2dInfo &conv2d_info, const WeightsInfo &weights_info=WeightsInfo())
Static function to check if given info will lead to a valid configuration.
GPUTarget target() const
Get the target GPU.
GPUTarget
Available GPU Targets.
size_t get_data_layout_dimension_index(const DataLayout &data_layout, const DataLayoutDimension &data_layout_dimension)
Get the index of the given dimension.
static Status validate(const ITensorInfo *src, const ITensorInfo *weights, const ITensorInfo *biases, const ITensorInfo *dst, const PadStrideInfo &conv_info, const ActivationLayerInfo &act_info=ActivationLayerInfo(), bool enable_fast_math=false)
Static function to check if given info will lead to a valid configuration.
void configure(const CLCompileContext &compile_context, ITensorInfo *src, ITensorInfo *weights, ITensorInfo *biases, ITensorInfo *dst, const Conv2dInfo &conv2d_info, const WeightsInfo &weights_info=WeightsInfo())
Set the src and dst tensors.
#define ARM_COMPUTE_RETURN_ERROR_ON_MSG(cond, msg)
If the condition is true, an error is returned.
Copyright (c) 2017-2024 Arm Limited.
bool is_data_type_float(DataType dt)
Check if a given data type is of floating point type.
#define ARM_COMPUTE_RETURN_ERROR_ON_NULLPTR(...)
void run(ITensorPack &tensors) override
Run the kernels contained in the function.
Store the tensor's metadata.
ScaleKernelInfo info(interpolation_policy, default_border_mode, PixelValue(), sampling_policy, false)
TensorShape compute_deep_convolution_shape(const TensorShape &input_shape, DataLayout input_data_layout, const TensorShape &weights_shape, const PadStrideInfo &conv_info)
Calculate the deep convolution shape output shape of a tensor.
#define ARM_COMPUTE_LOG_PARAMS(...)
std::pair< unsigned int, unsigned int > stride() const
Get the stride.