tensorflow/lite/toco/graph_transformations/hardcode_min_max.cc
// Propagates MinMax from any of the listed arrays, to all others.
// If multiple of these arrays have MinMax, then these are required
// to agree with each other.
Propagates MinMax from any of the listed arrays, to all others.
If multiple of these arrays have MinMax, then these are required
to agree with each other.
Propagates MinMax from any of the listed arrays to all others . If multiple of these arrays have MinMax then these are required to agree with each other .
bool PropagateMinMaxAmongArrays(Model* model,
                                const std::vector<std::string>& array_names) {
  std::string reference_array_name;
  MinMax* reference_minmax = nullptr;
  for (const std::string& array_name : array_names) {
    if (model->GetArray(array_name).minmax) {
      reference_array_name = array_name;
      reference_minmax = model->GetArray(array_name).minmax.get();
      break;
    }
  }
  if (!reference_minmax) {
    return false;
  }
  bool changed = false;
  for (const std::string& array_name : array_names) {
    auto& array = model->GetArray(array_name);
    if (array.minmax) {
      CHECK(MinMaxApproximatelyEqual(*array.minmax, *reference_minmax))
          << "Both the following arrays have minmax, and they disagree: "
          << reference_array_name << " (" << reference_minmax->min << ","
          << reference_minmax->max << ") and " << array_name << " ("
          << array.minmax->min << "," << array.minmax->max
          << "). Expected that either only one of them would have minmax, or "
             "at "
             "least that they would agree.";
    } else {
      array.GetOrCreateMinMax() = *reference_minmax;
      changed = true;
    }
  }
  return changed;
}
bool PropagateMinMaxAmongArrays ( Model * model , const std :: vector < std :: string > & array_names ) { std :: string reference_array_name ; MinMax * reference_minmax = nullptr ; for ( const std :: string & array_name : array_names ) { if ( model -> GetArray ( array_name ) . minmax ) { reference_array_name = array_name ; reference_minmax = model -> GetArray ( array_name ) . minmax . get ( ) ; break ; } } if ( ! reference_minmax ) { return false ; } bool changed = false ; for ( const std :: string & array_name : array_names ) { auto & array = model -> GetArray ( array_name ) ; if ( array . minmax ) { CHECK ( MinMaxApproximatelyEqual ( * array . minmax , * reference_minmax ) ) << " " << reference_array_name << " " << reference_minmax -> min << " " << reference_minmax -> max << " " << array_name << " " << array . minmax -> min << " " << array . minmax -> max << " " " " " " ; } else { array . GetOrCreateMinMax ( ) = * reference_minmax ; changed = true ; } } return changed ; }
Propagates MinMax from any of the listed arrays, to all others.
Propagates MinMax from any of the listed arrays to all others .
// No MinMax info is available to propagate.