xref: /aosp_15_r20/external/tensorflow/tensorflow/core/tpu/tpu_embedding_configuration_proto_rewrite.h (revision b6fb3261f9314811a0f4371741dbb8839866f948)
1 /* Copyright 2021 The TensorFlow Authors. All Rights Reserved.
2 
3 Licensed under the Apache License, Version 2.0 (the "License");
4 you may not use this file except in compliance with the License.
5 You may obtain a copy of the License at
6 
7     http://www.apache.org/licenses/LICENSE-2.0
8 
9 Unless required by applicable law or agreed to in writing, software
10 distributed under the License is distributed on an "AS IS" BASIS,
11 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 See the License for the specific language governing permissions and
13 limitations under the License.
14 ==============================================================================*/
15 
16 #ifndef TENSORFLOW_CORE_TPU_TPU_EMBEDDING_CONFIGURATION_PROTO_REWRITE_H_
17 #define TENSORFLOW_CORE_TPU_TPU_EMBEDDING_CONFIGURATION_PROTO_REWRITE_H_
18 
19 #include "tensorflow/compiler/xla/status_macros.h"
20 #include "tensorflow/core/protobuf/tpu/tpu_embedding_configuration.pb.h"
21 
22 namespace tensorflow {
23 
24 // Validates the TPU embedding configuration has been populated correctly and
25 // fills in missing fields. The user model is expected to fill in exactly one of
26 // the following:
27 //
28 // (1) batch_size_per_tensor_core and TableDescriptor.num_features, or
29 // (2) feature_descriptor.
30 //
31 // (1) If the user model fills in batch_size_per_tensor_core and
32 // TableDescriptor.num_features, this function validates that the
33 // feature_descriptor has not been filled in, and then populates
34 // feature_descriptor with appropriate values.
35 //
36 // (2) If the user model fills in feature_descriptor, this function validates
37 // that batch_size_per_tensor_core and TableDescriptor.num_features have not
38 // been filled in, and then populated them with appropriate values.
39 Status PopulateMissingFieldsInTPUEmbeddingConfig(
40     tpu::TPUEmbeddingConfiguration* config);
41 
42 }  // namespace tensorflow
43 
44 #endif  // TENSORFLOW_CORE_TPU_TPU_EMBEDDING_CONFIGURATION_PROTO_REWRITE_H_
45