Skip to content
Open
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
12 changes: 7 additions & 5 deletions tensorflow/lite/micro/kernels/gather.cc
Original file line number Diff line number Diff line change
Expand Up @@ -82,14 +82,16 @@ TfLiteStatus Gather(const TfLiteGatherParams* params,
for (int batch = 0; batch < batch_size; ++batch) {
for (int outer = 0; outer < outer_size; ++outer) {
for (int coord = 0; coord < coord_size; ++coord) {
TFLITE_DCHECK_GE(coords_data[coord], 0);
TFLITE_DCHECK_LT(coords_data[coord], axis_size);
const CoordsT idx = coords_data[batch * coord_size + coord];
if (idx < 0 || idx >= axis_size) {
return kTfLiteError;
}
std::memcpy(output_data +
(((batch * outer_size) + outer) * coord_size + coord) *
inner_size,
input_data + (((batch * outer_size) + outer) * axis_size +
coords_data[batch * coord_size + coord]) *
inner_size,
input_data +
(((batch * outer_size) + outer) * axis_size + idx) *
inner_size,
sizeof(InputT) * inner_size);
}
}
Expand Down
Loading