96 auto f = std::make_unique<ClWinogradConv2d>();
98 _operator = std::move(f);
105 auto f = std::make_unique<ClDirectConv2d>();
106 f->configure(compile_context, src, weights, biases, dst, conv2d_info.
conv_info, conv2d_info.
act_info);
107 _operator = std::move(f);
112 auto f = std::make_unique<ClGemmConv2d>();
113 f->configure(compile_context, src, weights, biases, dst, conv2d_info, weights_info);
114 _operator = std::move(f);
121 _aux_mem = _operator->workspace();
182 using ConvolutionConfiguration = std::tuple<Size2D, Size2D, Size2D, PadStrideInfo, DataLayout>;
183 using ConfigurationMethod = std::pair<ConvolutionConfiguration, ConvolutionMethod>;
185 const std::vector<ConfigurationMethod> known_configs =
188 ConfigurationMethod(ConvolutionConfiguration(
Size2D(27
U, 27
U),
Size2D(5
U, 5
U),
Size2D(48
U, 128
U),
PadStrideInfo(1
U, 1
U, 2
U, 2
U),
DataLayout::NCHW),
ConvolutionMethod::DIRECT),
190 ConfigurationMethod(ConvolutionConfiguration(
Size2D(224
U, 224
U),
Size2D(3
U, 3
U),
Size2D(3
U, 64
U),
PadStrideInfo(1
U, 1
U, 1
U, 1
U),
DataLayout::NCHW),
ConvolutionMethod::DIRECT),
192 ConfigurationMethod(ConvolutionConfiguration(
Size2D(224
U, 224
U),
Size2D(3
U, 3
U),
Size2D(3
U, 32
U),
PadStrideInfo(2
U, 2
U, 0
U, 1
U, 0
U, 1
U,
DimensionRoundingType::FLOOR),
DataLayout::NCHW),
ConvolutionMethod::GEMM),
194 ConfigurationMethod(ConvolutionConfiguration(
Size2D(160
U, 160
U),
Size2D(3
U, 3
U),
Size2D(3
U, 24
U),
PadStrideInfo(2
U, 2
U, 0
U, 1
U, 0
U, 1
U,
DimensionRoundingType::FLOOR),
DataLayout::NCHW),
ConvolutionMethod::GEMM),
196 ConfigurationMethod(ConvolutionConfiguration(
Size2D(224
U, 224
U),
Size2D(3
U, 3
U),
Size2D(3
U, 32
U),
PadStrideInfo(2
U, 2
U, 0
U, 1
U, 0
U, 1
U,
DimensionRoundingType::FLOOR),
DataLayout::NHWC),
ConvolutionMethod::GEMM),
198 ConfigurationMethod(ConvolutionConfiguration(
Size2D(160
U, 160
U),
Size2D(3
U, 3
U),
Size2D(3
U, 24
U),
PadStrideInfo(2
U, 2
U, 0
U, 1
U, 0
U, 1
U,
DimensionRoundingType::FLOOR),
DataLayout::NHWC),
ConvolutionMethod::GEMM),
201 const auto find_config = [&](ConfigurationMethod c)
203 const ConvolutionConfiguration config = c.first;
212 std::vector<ConfigurationMethod>::const_iterator found;
213 if((found = std::find_if(known_configs.begin(), known_configs.end(), find_config)) != known_configs.end())
215 return (*found).second;
245 const bool is_wino_valid = bool(
ClWinogradConv2d::validate(src, weights,
nullptr, dst, conv_info, act_info, enable_fast_math));
246 const size_t kernel_sz_direct_conv_thr = get_direct_conv_kernel_threshold_nhwc(gpu_target);
260 const bool is_large_kernel_sz = (weights->
dimension(idx_w) >= kernel_sz_direct_conv_thr) && (weights->
dimension(idx_h) >= kernel_sz_direct_conv_thr);
261 const bool is_ifm_ge_16 = src->
dimension(idx_c) >= 16;
262 const bool is_ofm_lte_8 = weights->
dimension(3
U) <= 8;
263 const bool workload_gte_8192 = (output_shape[0] * output_shape[1] * output_shape[2]) / 16 >= 8192;
267 if(is_wino_valid && is_ifm_ge_16)
279 if(is_large_kernel_sz && is_ifm_ge_16 && is_ifm_gt_ofm)
286 if((is_large_kernel_sz && workload_gte_8192 && is_ifm_ge_16) || (is_ofm_lte_8 && is_ifm_ge_16))
306 _operator->run(tensors);
311 _operator->prepare(tensors);
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.
virtual size_t dimension(size_t index) const =0
Return the size of the requested dimension.
static CLScheduler & get()
Access the scheduler singleton.
ActivationLayerInfo act_info
#define ARM_COMPUTE_ERROR(msg)
Print the given message then throw an std::runtime_error.
GPUTarget target() const
Get the target GPU.
ClConv2d()
Default constructor.
#define ARM_COMPUTE_RETURN_ON_ERROR(status)
Checks if a status contains an error and returns it.
virtual DataType data_type() const =0
Data type used for each element of the tensor.
#define ARM_COMPUTE_ERROR_ON(cond)
If the condition is true then an error message is printed and an exception thrown.
Store the tensor's metadata.
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_ERROR_THROW_ON(status)
void prepare(ITensorPack &tensors) override
Prepare the function for executing.
unsigned int pad_top() const
Get the top padding.
ConvolutionMethod
Available ConvolutionMethod.
Activation Layer Information class.
SimpleTensor< float > src
Copyright (c) 2017-2022 Arm Limited.
std::vector< MemoryInfo > MemoryRequirements
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.
void run(ITensorPack &tensors) override
Run the kernels contained in the function.
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.
Convolution Layer Weights Information class.
#define ARM_COMPUTE_RETURN_ERROR_ON_NULLPTR(...)
Interface to enqueue OpenCL kernels and get/set the OpenCL CommandQueue and ICLTuner.
#define ARM_COMPUTE_UNUSED(...)
To avoid unused variables warnings.
~ClConv2d()
Default Destructor.
std::pair< unsigned int, unsigned int > stride() const
Get the stride.
unsigned int pad_right() const
Get the right padding.
Padding and stride information class.
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.
Descriptor used by the 2d Convolution function.
Num samples, channels, height, width.
Convolution using Winograd.
experimental::PostOpList< ITensorInfo * > post_ops
ScaleKernelInfo info(interpolation_policy, default_border_mode, PixelValue(), sampling_policy, false)
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.
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.
Class for specifying the size of an image or rectangle.
Num samples, height, width, channels.
#define ARM_COMPUTE_RETURN_ERROR_ON_MSG(cond, msg)
If the condition is true, an error is returned.
#define ARM_COMPUTE_LOG_PARAMS(...)
#define ARM_COMPUTE_ERROR_ON_NULLPTR(...)
unsigned int pad_bottom() const
Get the bottom padding.
unsigned int pad_left() const
Get the left padding.
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.
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.
bool is_data_type_float(DataType dt)
Check if a given data type is of floating point type.
virtual DataLayout data_layout() const =0
Get the data layout of the tensor.