tensorflow/lite/kernels/non_max_suppression.cc
// If num_selected_indices < max_output_size, the output tensor can contain
// garbage values initially present in memory. This causes segfault in
// downstream ops such as GATHER, since one of the outputs denotes indices and
// int garbage values can be pretty large. This method zeroes-out the remaining
// values.
// NOTE: We ensure memory being reset is valid, by setting pertinent output
// tensors to max_output_size length in Prepare.
If num_selected_indices < max_output_size, the output tensor can contain
garbage values initially present in memory. This causes segfault in
downstream ops such as GATHER, since one of the outputs denotes indices and
int garbage values can be pretty large. This method zeroes-out the remaining
values.
NOTE: We ensure memory being reset is valid, by setting pertinent output
tensors to max_output_size length in Prepare.
If num_selected_indices < max_output_size the output tensor can contain garbage values initially present in memory . This causes segfault in downstream ops such as GATHER since one of the outputs denotes indices and int garbage values can be pretty large . This method zeroes - out the remaining values . NOTE : We ensure memory being reset is valid by setting pertinent output tensors to max_output_size length in Prepare .
void ResetUnusedElementsToZeroes(const int max_output_size,
                                 const int num_selected_indices,
                                 int* selected_indices,
                                 float* selected_scores) {
  for (int i = num_selected_indices; i < max_output_size; ++i) {
    selected_indices[i] = 0;
    if (selected_scores) {
      selected_scores[i] = 0.0;
    }
  }
}
void ResetUnusedElementsToZeroes ( const int max_output_size , const int num_selected_indices , int * selected_indices , float * selected_scores ) { for ( int i = num_selected_indices ; i < max_output_size ; ++ i ) { selected_indices [ i ] = 0 ; if ( selected_scores ) { selected_scores [ i ] = 0.0 ; } } }
If num_selected_indices < max_output_size, the output tensor can contain
garbage values initially present in memory.
If num_selected_indices < max_output_size the output tensor can contain garbage values initially present in memory .