Skip to content

Commit a6f2df4

Browse files
author
Zonglin Peng
committed
[executorch][PR] Adding fixes for im2row and conv1d, link im2row
Summary Adding fixes for im2row and conv1d Differential Revision: [D90351463](https://our.internmc.facebook.com/intern/diff/D90351463/) [ghstack-poisoned]
1 parent 593775b commit a6f2df4

12 files changed

+891
-83
lines changed

backends/cadence/aot/functions_hifi.yaml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,11 @@
267267
- arg_meta: null
268268
kernel_name: impl::HiFi::tanh_out
269269

270+
- op: transpose_copy.int_out
271+
kernels:
272+
- arg_meta: null
273+
kernel_name: impl::HiFi::transpose_copy_int_out
274+
270275
- op: view_copy.out
271276
kernels:
272277
- arg_meta: null
@@ -278,6 +283,16 @@
278283
kernel_name: impl::HiFi::where_self_out
279284

280285
# custom ops
286+
- func: cadence::im2row.out(Tensor input, int[2] kernel_size, int[2] dilation, int[2] padding, int[2] stride, Tensor in_zero_point, bool channel_last=False, *, Tensor(a!) out) -> Tensor(a!)
287+
kernels:
288+
- arg_meta: null
289+
kernel_name: impl::HiFi::native::im2row_out
290+
291+
- func: cadence::im2row.per_tensor_out(Tensor input, int[2] kernel_size, int[2] dilation, int[2] padding, int[2] stride, int in_zero_point, bool channel_last=False, *, Tensor(a!) out) -> Tensor(a!)
292+
kernels:
293+
- arg_meta: null
294+
kernel_name: impl::HiFi::native::im2row_per_tensor_out
295+
281296
- func: cadence::quantize_per_tensor.out(Tensor input, float scale, int zero_point, int quant_min, int quant_max, ScalarType dtype, *, Tensor(a!) out) -> Tensor(a!)
282297
variants: function
283298
kernels:

backends/cadence/hifi/kernels/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ add_library(
1818
${EXECUTORCH_ROOT}/backends/cadence/hifi/third-party/nnlib/xa_nn_elm_div_mode_f32_broadcast.c
1919
${EXECUTORCH_ROOT}/backends/cadence/hifi/third-party/nnlib/xa_nn_elm_fmod_broadcast_f32.c
2020
${EXECUTORCH_ROOT}/backends/cadence/hifi/third-party/nnlib/xa_nn_greater_lesser_equal_f32.c
21+
${EXECUTORCH_ROOT}/backends/cadence/hifi/third-party/nnlib/xa_nn_im2row.c
2122
${EXECUTORCH_ROOT}/backends/cadence/hifi/third-party/nnlib/xa_nn_elm_logicalxor_bool_bool.c
2223
${EXECUTORCH_ROOT}/backends/cadence/hifi/third-party/nnlib/xa_nn_elm_minimum_maximum_f32.c
2324
${EXECUTORCH_ROOT}/backends/cadence/hifi/third-party/nnlib/xa_nn_elm_mul_f32_broadcast.c

backends/cadence/hifi/kernels/kernels.h

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,28 @@ extern "C" WORD32 xa_nn_elm_where_broadcast_4D_f32xf32_f32(
196196
const unsigned char* __restrict__ p_condition,
197197
const WORD32* const p_condition_shape);
198198

199+
extern "C" WORD32 xa_nn_im2row_quantized(
200+
const WORD8* __restrict__ data_im,
201+
const WORD32 in_zero_point,
202+
/* input parameters*/
203+
const WORD32 channels,
204+
const WORD32 height,
205+
const WORD32 width,
206+
/* output parameters */
207+
const WORD32 out_height,
208+
const WORD32 out_width,
209+
/* convolution parameters */
210+
const WORD32 kernel_h,
211+
const WORD32 kernel_w,
212+
const WORD32 pad_h,
213+
const WORD32 pad_w,
214+
const WORD32 stride_h,
215+
const WORD32 stride_w,
216+
const WORD32 dilation_h,
217+
const WORD32 dilation_w,
218+
WORD8* __restrict__ data_col,
219+
WORD32 channels_last);
220+
199221
extern "C" WORD32 xa_nn_reduce_mean_4D_f32_f32(
200222
FLOAT32* __restrict__ p_out,
201223
const WORD32* const p_out_shape,

backends/cadence/hifi/operators/CMakeLists.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ include(${EXECUTORCH_ROOT}/tools/cmake/Codegen.cmake)
1616

1717
# ATen compliant ops that are needed to run this model.
1818
set(_aten_ops__srcs
19+
"${EXECUTORCH_ROOT}/backends/cadence/hifi/operators/op_im2row_out.cpp"
1920
"${EXECUTORCH_ROOT}/backends/cadence/hifi/operators/op_add.cpp"
2021
"${EXECUTORCH_ROOT}/backends/cadence/hifi/operators/op_atan2.cpp"
2122
"${EXECUTORCH_ROOT}/backends/cadence/hifi/operators/op_bitwise_and.cpp"
@@ -52,6 +53,7 @@ set(_aten_ops__srcs
5253
"${EXECUTORCH_ROOT}/backends/cadence/hifi/operators/op_sigmoid.cpp"
5354
"${EXECUTORCH_ROOT}/backends/cadence/hifi/operators/op_sub.cpp"
5455
"${EXECUTORCH_ROOT}/backends/cadence/hifi/operators/op_tanh.cpp"
56+
"${EXECUTORCH_ROOT}/backends/cadence/hifi/operators/op_transpose_copy.cpp"
5557
"${EXECUTORCH_ROOT}/backends/cadence/hifi/operators/op_view_copy.cpp"
5658
"${EXECUTORCH_ROOT}/backends/cadence/hifi/operators/op_where.cpp"
5759
"${EXECUTORCH_ROOT}/kernels/portable/cpu/op_clone.cpp"
@@ -96,6 +98,10 @@ add_library(
9698
"op_quantize_per_tensor.cpp"
9799
"op_quantized_relu_out.cpp"
98100
"op_dequantize_per_tensor.cpp"
101+
"op_quantized_conv1d_ncl_asym8sxsym8s_asym8s_per_tensor_out"
102+
"op_quantized_conv1d_ncl_asym8uxsym8u_asym8u_per_tensor_out"
103+
"op_quantized_conv1d_nlc_asym8sxsym8s_asym8s_per_tensor_out"
104+
"op_quantized_conv1d_nlc_asym8uxsym8u_asym8u_per_tensor_out"
99105
"op_quantized_conv2d_nchw_out.cpp"
100106
"op_quantized_conv2d_nhwc_out.cpp"
101107
"op_quantized_fully_connected_out"

0 commit comments

Comments
 (0)