tensorflow/lite/kernels/dynamic_update_slice.cc
// A helper function to compute the clamped start indices to ensure they are
// not out of bounds.
A helper function to compute the clamped start indices to ensure they are
not out of bounds.
A helper function to compute the clamped start indices to ensure they are not out of bounds .
std::vector<int> ClampStartIndices(int input_dims, const int32_t* indices_data,
                                   const RuntimeShape& input_shape,
                                   const RuntimeShape& update_shape) {
  std::vector<int> clamped_start_indices(input_dims, 0);
  for (int i = 0; i < input_dims; i++) {
    clamped_start_indices[i] =
        std::min(std::max(0, indices_data[i]),
                 input_shape.Dims(i) - update_shape.Dims(i));
  }
  return clamped_start_indices;
}
std :: vector < int > ClampStartIndices ( int input_dims , const int32_t * indices_data , const RuntimeShape & input_shape , const RuntimeShape & update_shape ) { std :: vector < int > clamped_start_indices ( input_dims , 0 ) ; for ( int i = 0 ; i < input_dims ; i ++ ) { clamped_start_indices [ i ] = std :: min ( std :: max ( 0 , indices_data [ i ] ) , input_shape . Dims ( i ) - update_shape . Dims ( i ) ) ; } return clamped_start_indices ; }
A helper function to compute the clamped start indices to ensure they are
not out of bounds.
A helper function to compute the clamped start indices to ensure they are not out of bounds .