Skip to content

Commit

Permalink
[onert-micro] Fix training configure tool UB
Browse files Browse the repository at this point in the history
This commit fixes undefined behavior in training configure tool.

ONE-DCO-1.0-Signed-off-by: Vyacheslav Bazhenov <[email protected]>
  • Loading branch information
Vyacheslav Bazhenov committed Dec 11, 2024
1 parent a850110 commit 97943dd
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 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,8 @@ OMStatus onert_micro::train::train_kernel_CircleMaxPool2D(const OMBackpropExecut
params.filter_w = options->filter_width();

// Set input grad to zero
std::memset(dloss_dinput_data, 0, sizeof(OMDataType(output->type())) * input_shape.flatSize());
for (size_t i = 0; i < input_shape.flatSize(); i += sizeof(float))
*static_cast<float *>(static_cast<void *>(dloss_dinput_data + i)) = 0;

// Calculate input grad
pal::MaxPool2D(params, input_shape, core::utils::castInputData<float>(input_data), output_shape,
Expand Down

0 comments on commit 97943dd

Please sign in to comment.