XNNPACK icon indicating copy to clipboard operation
XNNPACK copied to clipboard

Add fused operators support to convolution operators

Open copybara-service[bot] opened this issue 2 years ago • 0 comments

Add fused operators support to convolution operators

A specified set of operators can be fused into convolution using the new function xnn_create_convolution2d_nhwc_f32_fused, this creates a convolution operator with a list of operators to be applied after the convolution. The list of operators are applied in order. Currently fusion is only supported for F32 convolution. We also also limited to convolutions which use GEMM kernels, because we rely on JIT for fusion and JIT currently only generates GEMM microkernels, this restriction can be lifted later.

Introduce a new enum xnn_fused_operator_type which lists the kind of operators that can be fused into a convolution. Callers provided a xnn_fused_operator which contains xnn_fused_operator_type and associated data (such as clamp min max values). We have a new constant param init function that can be used for initializing params for the operators that are fused into the convolution, this can be used for addition (or other binary element-wise operation) with constant.

A new union xnn_fused_operator_params describes all the params that can be passed to the generated microkernel. When a convolution has fused operators, we call the microkernel with a pointer to an array of xnn_fused_operator_params.

copybara-service[bot] avatar Aug 03 '22 18:08 copybara-service[bot]