Skip to content

Commit

Permalink
Change channel and bits with w_in_stride for set_ptrs
Browse files Browse the repository at this point in the history
  • Loading branch information
lukamac committed Jan 30, 2024
1 parent 9145445 commit 6d24dd8
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 20 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
### Changed

- `ne16_task_init` got split into smaller parts: `ne16_task_init`, `ne16_task_set_op_to_conv`, `ne16_task_set_weight_offset`, `ne16_task_set_bits`, `ne16_task_set_norm_quant`
- strides in `ne16_task_set_strides`, and `ne16_task_set_dims` are now strides between consecutive elements in that dimension
- strides in `ne16_task_set_strides`, `ne16_task_set_dims`, and `ne16_task_set_ptrs` are now strides between consecutive elements in that dimension
- `ne16_task_queue_size` is now `NE16_TASK_QUEUE_SIZE`

### Removed
Expand Down
9 changes: 4 additions & 5 deletions ne16/hal/ne16_task.c
Original file line number Diff line number Diff line change
Expand Up @@ -108,19 +108,18 @@ void ne16_task_set_weight_offset(ne16_task_t *task,
* it was the start to the padded data.
* Necessary for input pointer when it's padded.
*/
uint32_t ne16_pad_ptr(uint32_t ptr, const uint32_t width,
const uint32_t channel, const uint8_t bits,
uint32_t ne16_pad_ptr(uint32_t ptr, const uint32_t width, uint32_t width_stride,
const uint8_t padding_top, const uint8_t padding_left) {
return ptr - (padding_top * width + padding_left) * channel * bits / 8;
return ptr - (padding_top * width + padding_left) * width_stride;
}

void ne16_task_set_ptrs(ne16_task_t *task, uint32_t input_ptr, uint32_t w_in,
uint32_t k_in, uint8_t bits_in, uint8_t padding_top,
uint32_t w_in_stride, uint8_t padding_top,
uint8_t padding_left, uint32_t output_ptr,
uint32_t weights_ptr, uint32_t scale_ptr,
uint32_t shift_ptr, uint32_t bias_ptr) {
task->data.infeat_ptr =
ne16_pad_ptr(input_ptr, w_in, k_in, bits_in, padding_top, padding_left);
ne16_pad_ptr(input_ptr, w_in, w_in_stride, padding_top, padding_left);
task->data.outfeat_ptr = output_ptr;
task->data.weights_ptr = weights_ptr;
task->data.scale_ptr = scale_ptr;
Expand Down
6 changes: 3 additions & 3 deletions ne16/hal/ne16_task.h
Original file line number Diff line number Diff line change
Expand Up @@ -131,10 +131,10 @@ uint32_t ne16_get_tile_padding(uint32_t padding, uint32_t i_height,
uint32_t i_width, uint32_t n_height,
uint32_t n_width);
uint32_t ne16_pad_ptr(uint32_t ptr, const uint32_t width,
const uint32_t channel, const uint8_t bits,
const uint8_t padding_top, const uint8_t padding_left);
const uint32_t width_stride, const uint8_t padding_top,
const uint8_t padding_left);
void ne16_task_set_ptrs(ne16_task_t *task, uint32_t input_ptr, uint32_t w_in,
uint32_t k_in, uint8_t bits_in, uint8_t padding_top,
uint32_t w_in_stride, uint8_t padding_top,
uint8_t padding_left, uint32_t output_ptr,
uint32_t weights_ptr, uint32_t scale_ptr,
uint32_t shift_ptr, uint32_t bias_ptr);
Expand Down
11 changes: 5 additions & 6 deletions neureka/hal/neureka_task.c
Original file line number Diff line number Diff line change
Expand Up @@ -122,20 +122,19 @@ void neureka_task_set_weight_source(neureka_task_t *task,
* Necessary for input pointer when it's padded.
*/
uint32_t neureka_pad_ptr(uint32_t ptr, const uint32_t width,
const uint32_t channel, const uint8_t bits,
const uint8_t padding_top,
const uint32_t width_stride, const uint8_t padding_top,
const uint8_t padding_left) {
return ptr - (padding_top * width + padding_left) * channel * bits / 8;
return ptr - (padding_top * width + padding_left) * width_stride;
}

void neureka_task_set_ptrs(neureka_task_t *task, uint32_t input_ptr,
uint32_t w_in, uint32_t k_in, uint8_t bits_in,
uint32_t w_in, uint32_t w_in_stride,
uint8_t padding_top, uint8_t padding_left,
uint32_t output_ptr, uint32_t weights_ptr,
uint32_t scale_ptr, uint32_t shift_ptr,
uint32_t bias_ptr) {
task->data.infeat_ptr = neureka_pad_ptr(input_ptr, w_in, k_in, bits_in,
padding_top, padding_left);
task->data.infeat_ptr =
neureka_pad_ptr(input_ptr, w_in, w_in_stride, padding_top, padding_left);
task->data.outfeat_ptr = output_ptr;
task->data.weights_ptr = weights_ptr;
task->data.scale_ptr = scale_ptr;
Expand Down
6 changes: 3 additions & 3 deletions neureka/hal/neureka_task.h
Original file line number Diff line number Diff line change
Expand Up @@ -140,10 +140,10 @@ uint32_t neureka_get_tile_padding(uint32_t padding, uint32_t i_height,
uint32_t i_width, uint32_t n_height,
uint32_t n_width);
uint32_t neureka_pad_ptr(uint32_t ptr, const uint32_t width,
const uint32_t channel, const uint8_t bits,
const uint8_t padding_top, const uint8_t padding_left);
const uint32_t width_stride, const uint8_t padding_top,
const uint8_t padding_left);
void neureka_task_set_ptrs(neureka_task_t *task, uint32_t input_ptr,
uint32_t w_in, uint32_t k_in, uint8_t bits_in,
uint32_t w_in, uint32_t w_in_stride,
uint8_t padding_top, uint8_t padding_left,
uint32_t output_ptr, uint32_t weights_ptr,
uint32_t scale_ptr, uint32_t shift_ptr,
Expand Down
4 changes: 2 additions & 2 deletions test/app/src/nnx_layer.c
Original file line number Diff line number Diff line change
Expand Up @@ -167,8 +167,8 @@ static void task_prepare(nnx_task_t *task) {
PADDING_LEFT);
#endif

nnx_task_set_ptrs(task, (uint32_t)input, INPUT_WIDTH, INPUT_CHANNEL,
INPUT_BITS, PADDING_TOP, PADDING_LEFT, (uint32_t)output,
nnx_task_set_ptrs(task, (uint32_t)input, INPUT_WIDTH, w_in_stride,
PADDING_TOP, PADDING_LEFT, (uint32_t)output,
(uint32_t)weight,
#if HAS_NORM_QUANT == 1
(uint32_t)scale, NULL,
Expand Down

0 comments on commit 6d24dd8

Please sign in to comment.