tensorflow/core/tpu/tpu_embedding_configuration_proto_rewrite.cc
// Validates that the feature_descriptor fields have been correctly filled in.
// All tables must have at least one input feature.
Validates that the feature_descriptor fields have been correctly filled in.
All tables must have at least one input feature.
Validates that the feature_descriptor fields have been correctly filled in . All tables must have at least one input feature .
Status ValidateFeatureDescriptors(
    const tpu::TPUEmbeddingConfiguration& config) {
  const int table_count = config.table_descriptor_size();
  std::vector<bool> tables_present(table_count, false);
  for (const auto& feature_config : config.feature_descriptor()) {
    const int table_id = feature_config.table_id();
    const auto& input_shape = feature_config.input_shape();
    if (table_id < 0 || table_id >= table_count) {
      return errors::InvalidArgument(absl::StrFormat(
          "Invalid table_id: %d found in feature_descriptor: %s, all table_ids "
          "must be in the range[0, %d)",
          table_id, feature_config.ShortDebugString(), table_count));
    }
    if (input_shape.empty()) {
      return errors::InvalidArgument(absl::StrFormat(
          "The input_shape field cannot be empty in feature_descriptor: %s",
          feature_config.ShortDebugString()));
    }
    for (const int dim_size : input_shape) {
      if (dim_size <= 0) {
        return errors::InvalidArgument(absl::StrFormat(
            "The input_shape dimension sizes must all be >0 in "
            "feature_descriptor: %s, found dimension size set to %d",
            feature_config.ShortDebugString(), dim_size));
      }
    }
    tables_present[table_id] = true;
  }  
  for (int table_id = 0; table_id < table_count; ++table_id) {
    if (!tables_present[table_id]) {
      return errors::InvalidArgument(absl::StrFormat(
          "No feature_descriptor fields found for table: %s (ID: %d) in "
          "the TPU embedding configuration.",
          config.table_descriptor(table_id).name(), table_id));
    }
  }
  return Status::OK();
}
Status ValidateFeatureDescriptors ( const tpu :: TPUEmbeddingConfiguration & config ) { const int table_count = config . table_descriptor_size ( ) ; std :: vector < bool > tables_present ( table_count , false ) ; for ( const auto & feature_config : config . feature_descriptor ( ) ) { const int table_id = feature_config . table_id ( ) ; const auto & input_shape = feature_config . input_shape ( ) ; if ( table_id < 0 || table_id >= table_count ) { return errors :: InvalidArgument ( absl :: StrFormat ( " " " " , table_id , feature_config . ShortDebugString ( ) , table_count ) ) ; } if ( input_shape . empty ( ) ) { return errors :: InvalidArgument ( absl :: StrFormat ( " " , feature_config . ShortDebugString ( ) ) ) ; } for ( const int dim_size : input_shape ) { if ( dim_size <= 0 ) { return errors :: InvalidArgument ( absl :: StrFormat ( " " " " , feature_config . ShortDebugString ( ) , dim_size ) ) ; } } tables_present [ table_id ] = true ; } for ( int table_id = 0 ; table_id < table_count ; ++ table_id ) { if ( ! tables_present [ table_id ] ) { return errors :: InvalidArgument ( absl :: StrFormat ( " " " " , config . table_descriptor ( table_id ) . name ( ) , table_id ) ) ; } } return Status :: OK ( ) ; }
Validates that the feature_descriptor fields have been correctly filled in.
Validates that the feature_descriptor fields have been correctly filled in .
// feature_config