23.11
|
Go to the documentation of this file.
54 bool enable_fast_math,
72 auto f = std::make_unique<CpuWinogradConv2d>();
74 _function = std::move(f);
79 auto f = std::make_unique<CpuGemmConv2d>();
81 _function = std::move(f);
86 auto f = std::make_unique<CpuGemmDirectConv2d>();
87 f->configure(
input, weights, biases, output,
info);
88 _function = std::move(f);
93 auto f = std::make_unique<CpuDirectConv2d>();
95 _function = std::move(f);
103 _aux_mem = _function->workspace();
114 bool enable_fast_math,
129 dilation,
act_info, enable_fast_math));
152 bool enable_fast_math)
164 using ConvolutionConfiguration = std::tuple<Size2D, Size2D, Size2D, PadStrideInfo>;
165 using ConfigurationMethod = std::pair<ConvolutionConfiguration, ConvolutionMethod>;
167 const std::vector<ConfigurationMethod> known_configs = {
187 const auto find_config = [&](ConfigurationMethod c)
189 const ConvolutionConfiguration config = c.first;
192 return std::get<0>(config) ==
Size2D(
input->dimension(idx_w),
input->dimension(idx_h)) &&
200 std::vector<ConfigurationMethod>::const_iterator found;
201 if ((found = std::find_if(known_configs.begin(), known_configs.end(), find_config)) != known_configs.end())
203 return (*found).second;
214 if (
input->total_size() > 1e7 && (weights->
dimension(idx_h) > 7) &&
219 if (
input->dimension(idx_c) < 16)
224 #ifdef __ARM_FEATURE_FP16_VECTOR_ARITHMETIC
230 const std::vector<ConvolutionConfiguration> known_bad_winograd_f16_with_fastmath_configs = {
241 const auto find_conv_config = [&](ConvolutionConfiguration c)
245 return std::get<0>(c) ==
Size2D(
input->dimension(idx_w),
input->dimension(idx_h)) &&
253 bool found_bad = std::find_if(known_bad_winograd_f16_with_fastmath_configs.begin(),
254 known_bad_winograd_f16_with_fastmath_configs.end(),
255 find_conv_config) != known_bad_winograd_f16_with_fastmath_configs.end();
261 #endif // __ARM_FEATURE_FP16_VECTOR_ARITHMETIC
284 _function->run(tensors);
289 _function->prepare(tensors);
std::vector< MemoryInfo > MemoryRequirements
Convolution Layer Weights Information class.
#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.
Descriptor used by the 2d Convolution function.
void run(ITensorPack &tensors) override
Run the kernels contained in the function.
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_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.
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.
#define ARM_COMPUTE_ERROR_ON_NULLPTR(...)
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.
#define ARM_COMPUTE_ERROR_THROW_ON(status)
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.
static IScheduler & get()
Access the scheduler singleton.
void prepare(ITensorPack &constants) override
Prepare the function for executing.
@ WINOGRAD
Convolution using Winograd.
@ GEMM_CONV2D
Direct 2D GEMM convolution.
@ GEMM
Convolution using GEMM.
#define ARM_COMPUTE_UNUSED(...)
To avoid unused variables warnings.
@ DIRECT
Direct convolution.
size_t get_data_layout_dimension_index(const DataLayout &data_layout, const DataLayoutDimension &data_layout_dimension)
Get the index of the given dimension.
const unsigned int num_groups
#define ARM_COMPUTE_RETURN_ERROR_ON_MSG(cond, msg)
If the condition is true, an error is returned.
Copyright (c) 2017-2023 Arm Limited.
@ F16
16-bit floating-point number
experimental::MemoryRequirements workspace() const override
Return the memory requirements required by the workspace.
~CpuConv2d()
Default destructor.
Store the tensor's metadata.
ScaleKernelInfo info(interpolation_policy, default_border_mode, PixelValue(), sampling_policy, false)
#define ARM_COMPUTE_LOG_PARAMS(...)
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 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.
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.