Compute Library
 22.08
CpuConv2d Class Reference

Basic function to simulate a convolution layer. More...

#include <CpuConv2d.h>

Collaboration diagram for CpuConv2d:
[legend]

Public Member Functions

 CpuConv2d ()
 Constructor. More...
 
 ARM_COMPUTE_DISALLOW_COPY_ALLOW_MOVE (CpuConv2d)
 
 ~CpuConv2d ()
 Default destructor. More...
 
void configure (ITensorInfo *src, ITensorInfo *weights, const ITensorInfo *biases, ITensorInfo *dst, const PadStrideInfo &conv_info, const WeightsInfo &weights_info=WeightsInfo(), const Size2D &dilation=Size2D(1U, 1U), const ActivationLayerInfo &act_info=ActivationLayerInfo(), bool enable_fast_math=false, unsigned int num_groups=1)
 Set the input and output tensors. More...
 
void run (ITensorPack &tensors) override
 Run the kernels contained in the function. More...
 
void prepare (ITensorPack &constants) override
 Prepare the function for executing. More...
 
experimental::MemoryRequirements workspace () const override
 Return the memory requirements required by the workspace. More...
 
- Public Member Functions inherited from INEOperator
 INEOperator (IRuntimeContext *ctx=nullptr)
 Constructor. More...
 
 INEOperator (const INEOperator &)=delete
 Prevent instances of this class from being copied (As this class contains pointers) More...
 
 INEOperator (INEOperator &&)=default
 Default move constructor. More...
 
INEOperatoroperator= (const INEOperator &)=delete
 Prevent instances of this class from being copied (As this class contains pointers) More...
 
INEOperatoroperator= (INEOperator &&)=default
 Default move assignment operator. More...
 
 ~INEOperator ()
 Default destructor. More...
 
- Public Member Functions inherited from IOperator
virtual ~IOperator ()=default
 Destructor. More...
 

Static Public Member Functions

static Status validate (const ITensorInfo *src, const ITensorInfo *weights, const ITensorInfo *biases, const ITensorInfo *output, const PadStrideInfo &conv_info, const WeightsInfo &weights_info=WeightsInfo(), const Size2D &dilation=Size2D(1U, 1U), const ActivationLayerInfo &act_info=ActivationLayerInfo(), bool enable_fast_math=false, unsigned int num_groups=1)
 Static function to check if given info will lead to a valid configuration of CpuConv2d. More...
 
static ConvolutionMethod get_convolution_method (const ITensorInfo *src, const ITensorInfo *weights, const ITensorInfo *dst, const PadStrideInfo &conv_info, const WeightsInfo &weights_info=WeightsInfo(), const Size2D &dilation=Size2D(1U, 1U), const ActivationLayerInfo &act_info=ActivationLayerInfo(), bool enable_fast_math=false)
 Static function to check if given info will return the convolution called by CpuConv2d. More...
 

Detailed Description

Basic function to simulate a convolution layer.

This function calls one of the following functions:

  1. CpuGemm (executed only in case GEMM is required for the operation)
  2. CpuWinogradConv2d (executed only in case Winograd is required for the operation)
  3. CpuDirectConv2d (executed only in case Direct Convolution is required for the operation)

The function selects one of the algorithms mentioned above based on:

  • The size of the kernel
  • Number of input/output feature maps
  • Amount of memory needed

Generally GEMM-based convolution is executed when neither Winograd nor FFT nor Direct convolution can be performed.

FP32 AlgorithmFilter Size Input/Output feature maps
Winograd 3x3 1x3 3x1 5x1 1x5 5x5(fast maths) 7x1 1x7 Input channels is greater than 3
FFT Squared kernels and greater than 9x9 Input feature maps > Output feature maps
DirectConv 9x9
GEMM Any size

Winograd 5x5 requires fast maths enabled.

FP16 AlgorithmFilter Size
Winograd Not supported
FFT Not supported
DirectConv 9x9
GEMM Any size

Definition at line 62 of file CpuConv2d.h.

Constructor & Destructor Documentation

◆ CpuConv2d()

CpuConv2d ( )

Constructor.

Definition at line 38 of file CpuConv2d.cpp.

References CpuConv2d::~CpuConv2d().

39  : _function()
40 {
41 }

◆ ~CpuConv2d()

~CpuConv2d ( )
default

Default destructor.

Referenced by CpuConv2d::CpuConv2d().

Member Function Documentation

◆ ARM_COMPUTE_DISALLOW_COPY_ALLOW_MOVE()

ARM_COMPUTE_DISALLOW_COPY_ALLOW_MOVE ( CpuConv2d  )

◆ configure()

void configure ( ITensorInfo src,
ITensorInfo weights,
const ITensorInfo biases,
ITensorInfo dst,
const PadStrideInfo conv_info,
const WeightsInfo weights_info = WeightsInfo(),
const Size2D dilation = Size2D(1U, 1U),
const ActivationLayerInfo act_info = ActivationLayerInfo(),
bool  enable_fast_math = false,
unsigned int  num_groups = 1 
)

Set the input and output tensors.

Valid data layouts:

  • NHWC
  • NCHW

Valid data type configurations:

src0 src1 src2 dst
F16 F16 F16 F16
F32 F32 F32 F32
QASYMM8 QASYMM8 S32 QASYMM8
QASYMM8 QSYMM8_PER_CHANNEL S32 QASYMM8
QASYMM8_SIGNED QASYMM8_SIGNED S32 QASYMM8_SIGNED
QASYMM8_SIGNED QSYMM8_PER_CHANNEL S32 QASYMM8_SIGNED
Parameters
[in]srcSource tensor info. 3 lower dimensions represent a single input [width, height, IFM], while every optional dimension from 4 and above represent a batch of inputs. Data types supported: QASYMM8/QASYMM8_SIGNED/F16/F32.
[in]weightsWeights tensor info. Weights are 4D tensor with dimensions [kernel_x, kernel_y, IFM, OFM]. Data type supported: Same as src, also could be QSYMM8_PER_CHANNEL if input is QASYMM8/QASYMM8_SIGNED.
[in]biasesBiases tensor info. Shared biases supported. Biases are 1D tensor with dimensions [OFM]. Data type supported: Same as src, except for input of QASYMM8/QASYMM8_SIGNED type where biases should be of S32 type.
[out]dstDestination tensor info. 3 lower dimensions represent a single output [width, height, OFM], while the rest represent batch of outputs. Data types supported: Same as src.
[in]conv_infoContains padding and stride information described in PadStrideInfo.
[in]weights_infoSpecifies if the weights tensor has been reshaped with NEWeightsReshapeKernel. If this is not part of the fully connected layer the weights tensor has also been transposed with cpu::kernels::CpuGemmTranspose1xWKernel. Data type supported: Same as input.
[in]dilation(Optional) Dilation, in elements, across x and y. Defaults to (1, 1).
[in]act_info(Optional) Activation layer information in case of a fused activation. Only RELU, BOUNDED_RELU and LU_BOUNDED_RELU supported.
[in]enable_fast_math(Optional) Enable fast math computation. In case this flag were set, the function could dispatch the fastest implementation available which may introduce a drop of accuracy as well. Default is false
[in]num_groups(Optional) Number of groups when performing a grouped convolution. num_groups != 1 is not supported

Definition at line 45 of file CpuConv2d.cpp.

References ARM_COMPUTE_ERROR, ARM_COMPUTE_ERROR_ON_NULLPTR, ARM_COMPUTE_ERROR_THROW_ON, ARM_COMPUTE_LOG_PARAMS, ARM_COMPUTE_UNUSED, arm_compute::DIRECT, arm_compute::GEMM, arm_compute::GEMM_CONV2D, CpuConv2d::get_convolution_method(), arm_compute::test::validation::info, CpuConv2d::validate(), and arm_compute::WINOGRAD.

47 {
48  // Perform validate step
49  ARM_COMPUTE_ERROR_ON_NULLPTR(input, weights, output);
51  ARM_COMPUTE_ERROR_THROW_ON(CpuConv2d::validate(input, weights, biases, output, conv_info, weights_info, dilation, act_info,
52  enable_fast_math, num_groups));
53 
54  ARM_COMPUTE_LOG_PARAMS(input, weights, biases, output, conv_info, weights_info, dilation, act_info, enable_fast_math, num_groups);
55 
56  const Conv2dInfo info(conv_info, dilation, act_info, enable_fast_math, num_groups);
57  switch(CpuConv2d::get_convolution_method(input, weights, output, conv_info, weights_info, dilation, act_info, enable_fast_math))
58  {
60  {
61  auto f = std::make_unique<CpuWinogradConv2d>();
62  f->configure(input, weights, biases, output, conv_info, act_info, enable_fast_math);
63  _function = std::move(f);
64  break;
65  }
67  {
68  auto f = std::make_unique<CpuGemmConv2d>();
69  f->configure(input, weights, biases, output, conv_info, weights_info, dilation, act_info, enable_fast_math);
70  _function = std::move(f);
71  break;
72  }
74  {
75  auto f = std::make_unique<CpuGemmDirectConv2d>();
76  f->configure(input, weights, biases, output, info);
77  _function = std::move(f);
78  break;
79  }
81  {
82  auto f = std::make_unique<CpuDirectConv2d>();
83  f->configure(input, weights, biases, output, conv_info, act_info);
84  _function = std::move(f);
85  break;
86  }
87  default:
88  ARM_COMPUTE_ERROR("Not supported.");
89  break;
90  }
91 
92  _aux_mem = _function->workspace();
93 }
static Status validate(const ITensorInfo *src, const ITensorInfo *weights, const ITensorInfo *biases, const ITensorInfo *output, const PadStrideInfo &conv_info, const WeightsInfo &weights_info=WeightsInfo(), const Size2D &dilation=Size2D(1U, 1U), const ActivationLayerInfo &act_info=ActivationLayerInfo(), bool enable_fast_math=false, unsigned int num_groups=1)
Static function to check if given info will lead to a valid configuration of CpuConv2d.
Definition: CpuConv2d.cpp:95
#define ARM_COMPUTE_ERROR(msg)
Print the given message then throw an std::runtime_error.
Definition: Error.h:352
#define ARM_COMPUTE_ERROR_THROW_ON(status)
Definition: Error.h:455
#define ARM_COMPUTE_UNUSED(...)
To avoid unused variables warnings.
Definition: Error.h:152
const unsigned int num_groups
Definition: Im2Col.cpp:153
static ConvolutionMethod get_convolution_method(const ITensorInfo *src, const ITensorInfo *weights, const ITensorInfo *dst, const PadStrideInfo &conv_info, const WeightsInfo &weights_info=WeightsInfo(), const Size2D &dilation=Size2D(1U, 1U), const ActivationLayerInfo &act_info=ActivationLayerInfo(), bool enable_fast_math=false)
Static function to check if given info will return the convolution called by CpuConv2d.
Definition: CpuConv2d.cpp:123
Convolution using Winograd.
ScaleKernelInfo info(interpolation_policy, default_border_mode, PixelValue(), sampling_policy, false)
#define ARM_COMPUTE_LOG_PARAMS(...)
#define ARM_COMPUTE_ERROR_ON_NULLPTR(...)
Definition: Validate.h:157
Convolution using GEMM.

◆ get_convolution_method()

ConvolutionMethod get_convolution_method ( const ITensorInfo src,
const ITensorInfo weights,
const ITensorInfo dst,
const PadStrideInfo conv_info,
const WeightsInfo weights_info = WeightsInfo(),
const Size2D dilation = Size2D(1U, 1U),
const ActivationLayerInfo act_info = ActivationLayerInfo(),
bool  enable_fast_math = false 
)
static

Static function to check if given info will return the convolution called by CpuConv2d.

Parameters
[in]srcSource tensor info. 3 lower dimensions represent a single input [width, height, IFM], while every optional dimension from 4 and above represent a batch of inputs. Data types supported: QASYMM8/QASYMM8_SIGNED/F16/F32.
[in]weightsWeights tensor info. Weights are 4D tensor with dimensions [kernel_x, kernel_y, IFM, OFM]. Data type supported:Same as src, also could be QSYMM8_PER_CHANNEL if input is QASYMM8/QASYMM8_SIGNED.
[in]dstDestination tensor info. 3 lower dimensions represent a single output [width, height, OFM], while the rest represent batch of outputs. Data types supported: Same as src.
[in]conv_infoContains padding and stride information described in PadStrideInfo.
[in]weights_infoSpecifies if the weights tensor has been reshaped with NEWeightsReshapeKernel. If this is not part of the fully connected layer the weights tensor has also been transposed with cpu::kernels::CpuGemmTranspose1xWKernel. Data type supported: Same as input.
[in]dilation(Optional) Dilation, in elements, across x and y. Defaults to (1, 1).
[in]act_info(Optional) Activation layer information in case of a fused activation.
[in]enable_fast_math(Optional) Enable fast math computation. In case this flag were set, the function could dispatch the fastest implementation available which may introduce a drop of accuracy as well. Default is false
Returns
the Convolution Method Hint

Definition at line 123 of file CpuConv2d.cpp.

References arm_compute::A55r1, ARM_COMPUTE_ERROR_ON_NULLPTR, ARM_COMPUTE_UNUSED, arm_compute::CHANNEL, IScheduler::cpu_info(), ITensorInfo::data_layout(), ITensorInfo::data_type(), ITensorInfo::dimension(), arm_compute::DIRECT, arm_compute::F16, arm_compute::FFT, arm_compute::FLOOR, arm_compute::GEMM, arm_compute::GEMM_CONV2D, Scheduler::get(), CPUInfo::get_cpu_model(), arm_compute::get_data_layout_dimension_index(), arm_compute::HEIGHT, arm_compute::test::validation::info, PadStrideInfo::pad_bottom(), PadStrideInfo::pad_left(), PadStrideInfo::pad_right(), PadStrideInfo::pad_top(), PadStrideInfo::stride(), ITensorInfo::total_size(), arm_compute::utils::cast::U, CpuGemmDirectConv2d::validate(), CpuWinogradConv2d::validate(), CpuDirectConv2d::validate(), NEFFTConvolutionLayer::validate(), arm_compute::WIDTH, and arm_compute::WINOGRAD.

Referenced by CpuConv2d::configure(), NEConvolutionLayer::configure(), arm_compute::test::validation::DATA_TEST_CASE(), NEConvolutionLayer::get_convolution_method(), CpuConv2d::validate(), and NEConvolutionLayer::validate().

126 {
127  ARM_COMPUTE_ERROR_ON_NULLPTR(input, output, weights);
129 
130  const size_t idx_w = get_data_layout_dimension_index(input->data_layout(), DataLayoutDimension::WIDTH);
131  const size_t idx_h = get_data_layout_dimension_index(input->data_layout(), DataLayoutDimension::HEIGHT);
132  const size_t idx_c = get_data_layout_dimension_index(input->data_layout(), DataLayoutDimension::CHANNEL);
133 
134  const Conv2dInfo info(conv_info, dilation, act_info, enable_fast_math, 1);
135 
136  /* Input spatial dims, kernel size, IFM/OFM, conv info*/
137  using ConvolutionConfiguration = std::tuple<Size2D, Size2D, Size2D, PadStrideInfo>;
138  using ConfigurationMethod = std::pair<ConvolutionConfiguration, ConvolutionMethod>;
139 
140  const std::vector<ConfigurationMethod> known_configs =
141  {
142  // Alexnet
143  ConfigurationMethod(ConvolutionConfiguration(Size2D(27U, 27U), Size2D(5U, 5U), Size2D(48U, 128U), PadStrideInfo(1U, 1U, 2U, 2U)), ConvolutionMethod::GEMM),
144  // VGG16 / VGG19
145  ConfigurationMethod(ConvolutionConfiguration(Size2D(224U, 224U), Size2D(3U, 3U), Size2D(3U, 64U), PadStrideInfo(1U, 1U, 1U, 1U)), ConvolutionMethod::GEMM),
146  // Mobilenet 224
147  ConfigurationMethod(ConvolutionConfiguration(Size2D(224U, 224U), Size2D(3U, 3U), Size2D(3U, 32U), PadStrideInfo(2U, 2U, 0U, 1U, 0U, 1U, DimensionRoundingType::FLOOR)), ConvolutionMethod::GEMM),
148  // Mobilenet 160
149  ConfigurationMethod(ConvolutionConfiguration(Size2D(160U, 160U), Size2D(3U, 3U), Size2D(3U, 24U), PadStrideInfo(2U, 2U, 0U, 1U, 0U, 1U, DimensionRoundingType::FLOOR)), ConvolutionMethod::GEMM)
150  };
151 
152  const auto find_config = [&](ConfigurationMethod c)
153  {
154  const ConvolutionConfiguration config = c.first;
155  const PadStrideInfo info = std::get<3>(config);
156 
157  return std::get<0>(config) == Size2D(input->dimension(idx_w), input->dimension(idx_h)) && std::get<1>(config) == Size2D(weights->dimension(idx_w), weights->dimension(idx_h))
158  && std::get<2>(config) == Size2D(weights->dimension(idx_c), weights->dimension(3)) && info.pad_top() == conv_info.pad_top() && info.pad_right() == conv_info.pad_right()
159  && info.pad_bottom() == conv_info.pad_bottom() && info.pad_left() == conv_info.pad_left() && info.stride() == conv_info.stride();
160  };
161 
162  std::vector<ConfigurationMethod>::const_iterator found;
163  if((found = std::find_if(known_configs.begin(), known_configs.end(), find_config)) != known_configs.end())
164  {
165  return (*found).second;
166  }
167 
168  if(dilation != Size2D(1U, 1U))
169  {
171  }
172  else
173  {
174  // SRGAN
175  // Output might not be initialized when it is an internal tensor of the layer using the convolution
176  if(input->total_size() > 1e7 && (weights->dimension(idx_h) > 7)
177  && (CpuDirectConv2d::validate(input, weights, nullptr, output, conv_info, act_info)))
178  {
180  }
181  if((weights->dimension(idx_h) > 7) && (input->dimension(idx_c) > output->dimension(idx_c)) && (NEFFTConvolutionLayer::validate(input, weights, nullptr, output, conv_info, act_info)))
182  {
183  return ConvolutionMethod::FFT;
184  }
185  if(input->dimension(idx_c) < 16)
186  {
188  }
189 
190 #ifdef __ARM_FEATURE_FP16_VECTOR_ARITHMETIC
191  // This heuristics only applies to F16 data type on A55r1
192  if(NEScheduler::get().cpu_info().get_cpu_model() == CPUModel::A55r1 && enable_fast_math && input->data_type() == DataType::F16)
193  {
194  // Exclude known bad winograd configs (and defaults to GEMM)
195  const std::vector<ConvolutionConfiguration> known_bad_winograd_f16_with_fastmath_configs =
196  {
197  // Squeezenet_V1_1 fire2 and fire3
198  ConvolutionConfiguration(Size2D(56U, 56U), Size2D(3U, 3U), Size2D(16U, 64U), PadStrideInfo(1U, 1U, 1U, 1U)),
199  // Squeezenet_V1_1 fire6 and fire7
200  ConvolutionConfiguration(Size2D(14U, 14U), Size2D(3U, 3U), Size2D(48U, 192U), PadStrideInfo(1U, 1U, 1U, 1U)),
201  // Squeezenet_V1_1 fire8 and fire9
202  ConvolutionConfiguration(Size2D(14U, 14U), Size2D(3U, 3U), Size2D(64U, 256U), PadStrideInfo(1U, 1U, 1U, 1U)),
203  };
204  const auto find_conv_config = [&](ConvolutionConfiguration c)
205  {
206  const PadStrideInfo info = std::get<3>(c);
207 
208  return std::get<0>(c) == Size2D(input->dimension(idx_w), input->dimension(idx_h)) && std::get<1>(c) == Size2D(weights->dimension(idx_w), weights->dimension(idx_h))
209  && std::get<2>(c) == Size2D(weights->dimension(idx_c), weights->dimension(3)) && info.pad_top() == conv_info.pad_top() && info.pad_right() == conv_info.pad_right()
210  && info.pad_bottom() == conv_info.pad_bottom() && info.pad_left() == conv_info.pad_left() && info.stride() == conv_info.stride();
211  };
212 
213  bool found_bad = std::find_if(known_bad_winograd_f16_with_fastmath_configs.begin(), known_bad_winograd_f16_with_fastmath_configs.end(),
214  find_conv_config)
215  != known_bad_winograd_f16_with_fastmath_configs.end();
216  if(found_bad)
217  {
219  }
220  }
221 #endif // __ARM_FEATURE_FP16_VECTOR_ARITHMETIC
222  // For 1x1 convolutions run the default GEMM
223  if(weights->dimension(idx_w) == 1 && weights->dimension(idx_h) == 1)
224  {
226  }
227 
228  if(bool(CpuWinogradConv2d::validate(input, weights, nullptr, output, conv_info, act_info, enable_fast_math)))
229  {
231  }
232  if(bool(CpuGemmDirectConv2d::validate(input, weights, nullptr, output, info)))
233  {
235  }
237  }
238 }
static Status validate(const ITensorInfo *src, const ITensorInfo *weights, const ITensorInfo *bias, 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.
CPUInfo & cpu_info()
Get CPU info.
Definition: IScheduler.cpp:41
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 NEFFTConvolutionLayer.
CPUModel get_cpu_model(unsigned int cpuid) const
Gets the cpu model for a given cpuid.
Definition: CPPTypes.cpp:119
1 channel, 1 F16 per channel
#define ARM_COMPUTE_UNUSED(...)
To avoid unused variables warnings.
Definition: Error.h:152
static Status validate(const ITensorInfo *src, const ITensorInfo *weights, const ITensorInfo *biases, const ITensorInfo *dst, const Conv2dInfo &info)
Static function to check if given info will lead to a valid configuration of CpuGemmDirectConv2d.
Convolution using Winograd.
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 of CpuWinogradConv2d.
ScaleKernelInfo info(interpolation_policy, default_border_mode, PixelValue(), sampling_policy, false)
size_t get_data_layout_dimension_index(const DataLayout &data_layout, const DataLayoutDimension &data_layout_dimension)
Get the index of the given dimension.
Definition: Helpers.inl:193
#define ARM_COMPUTE_ERROR_ON_NULLPTR(...)
Definition: Validate.h:157
Convolution using GEMM.
static IScheduler & get()
Access the scheduler singleton.
Definition: Scheduler.cpp:94

◆ prepare()

void prepare ( ITensorPack constants)
overridevirtual

Prepare the function for executing.

Any one off pre-processing step required by the function is handled here

Parameters
[in]constantsVector that contains the constants tensors.
Note
Prepare stage might not need all the function's buffers' backing memory to be available in order to execute

Reimplemented from INEOperator.

Definition at line 246 of file CpuConv2d.cpp.

Referenced by CpuConv2d::run().

247 {
248  _function->prepare(tensors);
249 }

◆ run()

void run ( ITensorPack tensors)
overridevirtual

Run the kernels contained in the function.

Parameters
[in]tensorsVector that contains the tensors to operate on.

Reimplemented from INEOperator.

Definition at line 240 of file CpuConv2d.cpp.

References CpuConv2d::prepare().

241 {
242  prepare(tensors);
243  _function->run(tensors);
244 }
void prepare(ITensorPack &constants) override
Prepare the function for executing.
Definition: CpuConv2d.cpp:246

◆ validate()

Status validate ( const ITensorInfo src,
const ITensorInfo weights,
const ITensorInfo biases,
const ITensorInfo output,
const PadStrideInfo conv_info,
const WeightsInfo weights_info = WeightsInfo(),
const Size2D dilation = Size2D(1U, 1U),
const ActivationLayerInfo act_info = ActivationLayerInfo(),
bool  enable_fast_math = false,
unsigned int  num_groups = 1 
)
static

Static function to check if given info will lead to a valid configuration of CpuConv2d.

Similar to CpuConv2d::configure()

Returns
a status

Definition at line 95 of file CpuConv2d.cpp.

References ARM_COMPUTE_ERROR, ARM_COMPUTE_RETURN_ERROR_ON_MSG, ARM_COMPUTE_RETURN_ON_ERROR, arm_compute::DIRECT, arm_compute::GEMM, arm_compute::GEMM_CONV2D, CpuConv2d::get_convolution_method(), arm_compute::test::validation::info, CpuGemmDirectConv2d::validate(), CpuDirectConv2d::validate(), CpuWinogradConv2d::validate(), CpuGemmConv2d::validate(), and arm_compute::WINOGRAD.

Referenced by CpuConv2d::configure(), and NEConvolutionLayer::validate().

97 {
98  ARM_COMPUTE_RETURN_ERROR_ON_MSG((num_groups != 1), "Grouping (num_groups != 1) is not supported on Neon");
99 
100  const Conv2dInfo info(conv_info, dilation, act_info, enable_fast_math, num_groups);
101  switch(CpuConv2d::get_convolution_method(input, weights, output, conv_info, weights_info, dilation, act_info, enable_fast_math))
102  {
104  ARM_COMPUTE_RETURN_ON_ERROR(CpuWinogradConv2d::validate(input, weights, biases, output, conv_info, act_info, enable_fast_math));
105  break;
107  ARM_COMPUTE_RETURN_ON_ERROR(CpuGemmConv2d::validate(input, weights, biases, output, conv_info, weights_info, dilation, act_info, enable_fast_math));
108  break;
111  break;
113  ARM_COMPUTE_RETURN_ON_ERROR(CpuDirectConv2d::validate(input, weights, biases, output, conv_info, act_info));
114  break;
115  default:
116  ARM_COMPUTE_ERROR("Not supported.");
117  break;
118  }
119 
120  return Status{};
121 }
static Status validate(const ITensorInfo *src, const ITensorInfo *weights, const ITensorInfo *bias, 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.
#define ARM_COMPUTE_ERROR(msg)
Print the given message then throw an std::runtime_error.
Definition: Error.h:352
#define ARM_COMPUTE_RETURN_ON_ERROR(status)
Checks if a status contains an error and returns it.
Definition: Error.h:204
static Status validate(const ITensorInfo *src, const ITensorInfo *weights, const ITensorInfo *biases, const ITensorInfo *output, const PadStrideInfo &conv_info, const WeightsInfo &weights_info=WeightsInfo(), const Size2D &dilation=Size2D(1U, 1U), const ActivationLayerInfo &act_info=ActivationLayerInfo(), bool enable_fast_math=false, unsigned int num_groups=1)
Static function to check if given info will lead to a valid configuration.
static Status validate(const ITensorInfo *src, const ITensorInfo *weights, const ITensorInfo *biases, const ITensorInfo *dst, const Conv2dInfo &info)
Static function to check if given info will lead to a valid configuration of CpuGemmDirectConv2d.
const unsigned int num_groups
Definition: Im2Col.cpp:153
static ConvolutionMethod get_convolution_method(const ITensorInfo *src, const ITensorInfo *weights, const ITensorInfo *dst, const PadStrideInfo &conv_info, const WeightsInfo &weights_info=WeightsInfo(), const Size2D &dilation=Size2D(1U, 1U), const ActivationLayerInfo &act_info=ActivationLayerInfo(), bool enable_fast_math=false)
Static function to check if given info will return the convolution called by CpuConv2d.
Definition: CpuConv2d.cpp:123
Convolution using Winograd.
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 of CpuWinogradConv2d.
ScaleKernelInfo info(interpolation_policy, default_border_mode, PixelValue(), sampling_policy, false)
#define ARM_COMPUTE_RETURN_ERROR_ON_MSG(cond, msg)
If the condition is true, an error is returned.
Definition: Error.h:244
Convolution using GEMM.

◆ workspace()

experimental::MemoryRequirements workspace ( ) const
overridevirtual

Return the memory requirements required by the workspace.

Reimplemented from INEOperator.

Definition at line 251 of file CpuConv2d.cpp.

252 {
253  return _aux_mem;
254 }

The documentation for this class was generated from the following files: