Skip to content

Commit

Permalink
[onert-micro] Fix MaxPool2D and FullyConnected training kernels
Browse files Browse the repository at this point in the history
This commit fixes errors in MaxPool2D and FullyConnected training kernels.

ONE-DCO-1.0-Signed-off-by: Vyacheslav Bazhenov <[email protected]>
  • Loading branch information
Vyacheslav Bazhenov committed Dec 19, 2024
1 parent 82e7d9a commit 8df2ce4
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 2 additions & 1 deletion onert-micro/onert-micro/src/train/kernels/FullyConnected.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,8 @@ OMStatus onert_micro::train::train_kernel_CircleFullyConnected(const OMBackpropE

// 2. Calculate weight gradient
// Init weight grads with zeros
for (int i = 0; i < output_shape.dims(1) * input_shape.dims(1); i += sizeof(float))
const auto kDlossSizeInBytes = output_shape.dims(1) * input_shape.dims(1) * sizeof(float);
for (int i = 0; i < kDlossSizeInBytes; i += sizeof(float))
*static_cast<float *>(static_cast<void *>(dloss_dweight_data + i)) = 0;

pal::FullyConnectedWeightGrad(
Expand Down
2 changes: 1 addition & 1 deletion onert-micro/onert-micro/src/train/kernels/MaxPool2D.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ OMStatus onert_micro::train::train_kernel_CircleMaxPool2D(const OMBackpropExecut
params.filter_w = options->filter_width();

// Set input grad to zero
for (size_t i = 0; i < input_shape.flatSize(); i += sizeof(float))
for (size_t i = 0; i < input_shape.flatSize() * sizeof(float); i += sizeof(float))
*static_cast<float *>(static_cast<void *>(dloss_dinput_data + i)) = 0;

// Calculate input grad
Expand Down

0 comments on commit 8df2ce4

Please sign in to comment.