Skip to content

Commit

Permalink
Refactored xnn_indirection_init_subconv2d to not use operator object.
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 728152402
  • Loading branch information
Aelphy authored and xnnpack-bot committed Feb 18, 2025
1 parent 634f773 commit 59daa3e
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 21 deletions.
33 changes: 15 additions & 18 deletions src/indirection.c
Original file line number Diff line number Diff line change
Expand Up @@ -131,26 +131,23 @@ void xnn_indirection_init_deconv2d(
}

void xnn_indirection_init_subconv2d(
xnn_operator_t op,
size_t output_tile_size,
uint32_t log2_element_size)
const void** indirection_buffer,
struct subconvolution_params* subconvolution_params,
const void* input,
const size_t input_pixel_stride,
const void* zero,
const size_t input_height,
const size_t input_width,
const size_t output_height,
const size_t output_width,
const size_t kernel_height,
const size_t kernel_width,
const size_t stride_height,
const size_t stride_width,
const size_t padding_top,
const size_t padding_left)
{
const void** indirection_buffer = op->indirection_buffer;
struct subconvolution_params* subconvolution_params = op->subconvolution_buffer;
const void* input = op->input;
const size_t input_pixel_stride = op->input_pixel_stride << log2_element_size;
const void* zero = op->zero_buffer;
const size_t input_height = op->input_height;
const size_t input_width = op->input_width;
const size_t output_height = op->output_height;
const size_t output_width = op->output_width;
const size_t kernel_height = op->kernel_height;
const size_t kernel_width = op->kernel_width;
const size_t stride_height = op->stride_height;
const size_t stride_width = op->stride_width;
const size_t padding_top = op->padding_top;
const size_t padding_left = op->padding_left;

const size_t modulo_padding_top = padding_top % stride_height;
const size_t modulo_padding_left = padding_left % stride_width;
for (size_t offset_y = 0; offset_y < stride_height; offset_y++) {
Expand Down
11 changes: 10 additions & 1 deletion src/operators/deconvolution-nhwc.c
Original file line number Diff line number Diff line change
Expand Up @@ -1562,7 +1562,16 @@ static enum xnn_status reshape_subconv2d_path(
// Set a dummy input first, the actual input offset is calculated in setup when we have the input pointer.
// This offset must be aligned properly because inputs and input offsets need to be aligned.
deconvolution_op->input = (void*) ((uintptr_t) deconvolution_op->zero_buffer + XNN_ALLOCATION_ALIGNMENT);
xnn_indirection_init_subconv2d(deconvolution_op, mr, log2_input_element_size);
xnn_indirection_init_subconv2d(
mr, deconvolution_op->indirection_buffer,
deconvolution_op->subconvolution_buffer, deconvolution_op->input,
deconvolution_op->input_pixel_stride << log2_input_element_size,
deconvolution_op->zero_buffer, deconvolution_op->input_height,
deconvolution_op->input_width, deconvolution_op->output_height,
deconvolution_op->output_width, deconvolution_op->kernel_height,
deconvolution_op->kernel_width, deconvolution_op->stride_height,
deconvolution_op->stride_width, deconvolution_op->padding_top,
deconvolution_op->padding_left);

deconvolution_op->last_input = deconvolution_op->input;
deconvolution_op->last_input_height = input_height;
Expand Down
17 changes: 15 additions & 2 deletions src/xnnpack/indirection.h
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,22 @@ XNN_INTERNAL void xnn_indirection_init_deconv2d(
size_t padding_left);

XNN_INTERNAL void xnn_indirection_init_subconv2d(
xnn_operator_t op,
size_t output_tile_size,
uint32_t log2_element_size);
const void** indirection_buffer,
struct subconvolution_params* subconvolution_params,
const void* input,
size_t input_pixel_stride,
const void* zero,
size_t input_height,
size_t input_width,
size_t output_height,
size_t output_width,
size_t kernel_height,
size_t kernel_width,
size_t stride_height,
size_t stride_width,
size_t padding_top,
size_t padding_left);

XNN_INTERNAL void xnn_indirection_init_maxpool2d(
const void** indirection_buffer,
Expand Down

0 comments on commit 59daa3e

Please sign in to comment.