46 struct FuseBatchNormalizeSelectorData
51 cpuinfo::CpuIsaInfo
isa;
55 using FBNUKernelPtr = std::add_pointer<void(
const ITensor *,
const ITensor *, ITensor *, ITensor *,
56 const ITensor *,
const ITensor *,
const ITensor *,
const ITensor *,
float,
const Window &)>
::type;
65 static const FBNUKernel available_kernels[] =
68 "fused_batch_normalization_conv_NHWC_F16",
69 [](
const FuseBatchNormalizeSelectorData & data)
76 "fused_batch_normalization_conv_NCHW_F16",
77 [](
const FuseBatchNormalizeSelectorData & data)
84 "fused_batch_normalization_dwc_NHWC_F16",
85 [](
const FuseBatchNormalizeSelectorData & data)
92 "fused_batch_normalization_dwc_NCHW_F16",
93 [](
const FuseBatchNormalizeSelectorData & data)
100 "fused_batch_normalization_conv_NHWC_F32",
101 [](
const FuseBatchNormalizeSelectorData & data)
108 "fused_batch_normalization_conv_NCHW_F32",
109 [](
const FuseBatchNormalizeSelectorData & data)
116 "fused_batch_normalization_dwc_NHWC_F32",
117 [](
const FuseBatchNormalizeSelectorData & data)
124 "fused_batch_normalization_dwc_NCHW_F32",
125 [](
const FuseBatchNormalizeSelectorData & data)
141 const FBNUKernel *get_implementation(
const FuseBatchNormalizeSelectorData &data)
143 for(
const auto &uk : available_kernels)
145 if(uk.is_selected(data))
153 Status
validate_arguments(
const ITensorInfo *input_weights,
const ITensorInfo *bn_mean,
const ITensorInfo *bn_var,
154 const ITensorInfo *fused_weights,
const ITensorInfo *fused_bias,
155 const ITensorInfo *input_bias,
const ITensorInfo *bn_beta,
const ITensorInfo *bn_gamma,
177 if(input_bias !=
nullptr)
183 if(bn_beta !=
nullptr)
189 if(bn_gamma !=
nullptr)
196 if(fused_weights !=
nullptr && fused_weights->total_size() != 0)
203 if(fused_bias !=
nullptr && fused_bias->total_size() != 0)
215 : _input_weights(nullptr), _input_bias(nullptr), _bn_mean(nullptr), _bn_var(nullptr), _bn_gamma(nullptr), _bn_beta(nullptr), _fused_weights(nullptr), _fused_bias(nullptr), _epsilon(),
216 _run_in_place_weights(false), _run_in_place_bias(false), _func(nullptr)
227 _input_weights = input_weights;
228 _input_bias = input_bias;
232 _bn_gamma = bn_gamma;
233 _fused_weights = fused_weights;
234 _fused_bias = fused_bias;
237 _run_in_place_weights = (fused_weights ==
nullptr) || (fused_weights == input_weights);
238 _run_in_place_bias = (fused_bias ==
nullptr) || (input_bias !=
nullptr && fused_bias == input_bias);
241 if(_fused_weights !=
nullptr)
246 if(_fused_bias !=
nullptr)
254 (fused_weights !=
nullptr) ? fused_weights->
info() :
nullptr,
255 (fused_bias !=
nullptr) ? fused_bias->
info() :
nullptr,
256 (input_bias !=
nullptr) ? input_bias->
info() :
nullptr,
257 (bn_beta !=
nullptr) ? bn_beta->
info() :
nullptr,
258 (bn_gamma !=
nullptr) ? bn_gamma->
info() :
nullptr,
268 INEKernel::configure(win);
287 (*_func)(_input_weights, _input_bias, _fused_weights, _fused_bias, _bn_mean, _bn_var, _bn_beta, _bn_gamma, _epsilon,
window);
static Status validate(const ITensorInfo *input_weights, const ITensorInfo *bn_mean, const ITensorInfo *bn_var, const ITensorInfo *fused_weights, const ITensorInfo *fused_bias, const ITensorInfo *input_bias=nullptr, const ITensorInfo *bn_beta=nullptr, const ITensorInfo *bn_gamma=nullptr, float epsilon=0.001f, FuseBatchNormalizationType fbn_type=FuseBatchNormalizationType::CONVOLUTION)
Static function to check if given info will lead to a valid configuration of NEFuseBatchNormalization...
Window calculate_max_window(const ValidRegion &valid_region, const Steps &steps, bool skip_border, BorderSize border_size)
const Window & window() const
The maximum window the kernel can be executed on.
FuseBatchNormalizationType fbn_type
#define ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_DATA_LAYOUT(...)
#define ARM_COMPUTE_RETURN_ERROR_ON_CPU_F16_UNSUPPORTED(tensor)
#define REGISTER_FP16_NEON(func_name)
const FBNSelectorPtr is_selected
void fused_batch_normalization_conv_f32(const ITensor *conv_weights, const ITensor *conv_bias, ITensor *fused_weights, ITensor *fused_bias, const ITensor *bn_mean, const ITensor *bn_var, const ITensor *bn_beta, const ITensor *bn_gamma, float epsilon, const Window &window)
#define REGISTER_FP32_NEON(func_name)
#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.
1 channel, 1 F32 per channel
void fused_batch_normalization_dwc_nhwc_f16(const ITensor *dwc_weights, const ITensor *dwc_bias, ITensor *fused_weights, ITensor *fused_bias, const ITensor *bn_mean, const ITensor *bn_var, const ITensor *bn_beta, const ITensor *bn_gamma, float epsilon, const Window &window)
#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.
#define ARM_COMPUTE_ERROR_THROW_ON(status)
Status validate_arguments(const ITensorInfo *src, const ITensorInfo *weights, const ITensorInfo *dst, const PadStrideInfo &conv_info)
#define ARM_COMPUTE_RETURN_ERROR_ON(cond)
If the condition is true, an error is returned.
decltype(strategy::transforms) typedef type
Interface for CPU tensor.
Copyright (c) 2017-2022 Arm Limited.
1 channel, 1 F16 per channel
void run(const Window &window, const ThreadInfo &info) override
Execute the kernel on the passed window.
#define ARM_COMPUTE_RETURN_ERROR_ON_NULLPTR(...)
FuseBatchNormalizationType
Available FuseBatchNormalizationType.
#define ARM_COMPUTE_UNUSED(...)
To avoid unused variables warnings.
void configure(const ITensor *input_weights, const ITensor *bn_mean, const ITensor *bn_var, ITensor *fused_weights, ITensor *fused_bias, const ITensor *input_bias=nullptr, const ITensor *bn_beta=nullptr, const ITensor *bn_gamma=nullptr, float epsilon=0.001f, FuseBatchNormalizationType fbn_type=FuseBatchNormalizationType::CONVOLUTION)
Set the source, destination of the kernel.
bool auto_init_if_empty(ITensorInfo &info, const TensorShape &shape, int num_channels, DataType data_type, QuantizationInfo quantization_info=QuantizationInfo())
Auto initialize the tensor info (shape, number of channels and data type) if the current assignment i...
virtual std::unique_ptr< T > clone() const =0
Provide a clone of the current object of class T.
virtual ITensorInfo * info() const =0
Interface to be implemented by the child class to return the tensor's metadata.
void fused_batch_normalization_dwc_nchw_f32(const ITensor *dwc_weights, const ITensor *dwc_bias, ITensor *fused_weights, ITensor *fused_bias, const ITensor *bn_mean, const ITensor *bn_var, const ITensor *bn_beta, const ITensor *bn_gamma, float epsilon, const Window &window)
#define ARM_COMPUTE_ERROR_ON_UNCONFIGURED_KERNEL(k)
Num samples, channels, height, width.
ScaleKernelInfo info(interpolation_policy, default_border_mode, PixelValue(), sampling_policy, false)
Information about executing thread and CPU.
#define ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_SHAPES(...)
NEFuseBatchNormalizationKernel()
Default constructor.
size_t get_data_layout_dimension_index(const DataLayout &data_layout, const DataLayoutDimension &data_layout_dimension)
Get the index of the given dimension.
#define ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_DATA_TYPES(...)
Num samples, height, width, channels.
#define ARM_COMPUTE_RETURN_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(t, c,...)
void fused_batch_normalization_conv_f16(const ITensor *conv_weights, const ITensor *conv_bias, ITensor *fused_weights, ITensor *fused_bias, const ITensor *bn_mean, const ITensor *bn_var, const ITensor *bn_beta, const ITensor *bn_gamma, float epsilon, const Window &window)
For Depthwise Convolution weights.
#define ARM_COMPUTE_ERROR_ON_NULLPTR(...)
void fused_batch_normalization_dwc_nhwc_f32(const ITensor *dwc_weights, const ITensor *dwc_bias, ITensor *fused_weights, ITensor *fused_bias, const ITensor *bn_mean, const ITensor *bn_var, const ITensor *bn_beta, const ITensor *bn_gamma, float epsilon, const Window &window)
Includes all wrapper headers at once.
static CPUInfo & get()
Access the KernelLibrary singleton.
void fused_batch_normalization_dwc_nchw_f16(const ITensor *dwc_weights, const ITensor *dwc_bias, ITensor *fused_weights, ITensor *fused_bias, const ITensor *bn_mean, const ITensor *bn_var, const ITensor *bn_beta, const ITensor *bn_gamma, float epsilon, const Window &window)
DataType
Available data types.
DataLayout
[DataLayout enum definition]
Describe a multidimensional execution window.
#define ARM_COMPUTE_ERROR_ON_INVALID_SUBWINDOW(f, s)
cpuinfo::CpuIsaInfo get_isa() const
Gets the current cpu's ISA information.
virtual DataLayout data_layout() const =0
Get the data layout of the tensor.