Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[onert-micro] Fix training configure tool UB #14406

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions onert-micro/onert-micro/src/train/kernels/FullyConnected.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,9 @@ OMStatus onert_micro::train::train_kernel_CircleFullyConnected(const OMBackpropE

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

pal::FullyConnectedWeightGrad(
core::utils::castInputData<float>(dloss_doutput_data), output_shape,
core::utils::castInputData<float>(input_data), input_shape,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ void writeTrainConfigFileDataIntoBuffer(
const auto &train_op_indexes_with_ranks = train_data.trainable_op_indexes_with_ranks;

// Resize to calculated size
auto buffer_size = 8 + train_op_indexes_with_ranks.size() * 2;
// 8 Bytes - handler + U16 indexes + U8 ranks
auto buffer_size = 8 + train_op_indexes_with_ranks.size() * (sizeof(uint16_t) + sizeof(uint8_t));
buffer.resize(buffer_size);

// Point to start of the buffer
Expand Down