TensorFlow Serving C++ API Documentation
saved_model_config_util.h
1 /* Copyright 2023 Google Inc. 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_SERVING_SERVABLES_TENSORFLOW_SAVED_MODEL_CONFIG_UTIL_H_
17 #define TENSORFLOW_SERVING_SERVABLES_TENSORFLOW_SAVED_MODEL_CONFIG_UTIL_H_
18 
19 #include <string>
20 
21 #include "absl/status/statusor.h"
22 #include "tensorflow/core/protobuf/rewriter_config.pb.h"
23 #include "tensorflow_serving/servables/tensorflow/saved_model_config.pb.h"
24 
25 namespace tensorflow {
26 namespace serving {
27 
28 // Name of the additional asset file containing a per model configuration proto.
29 inline constexpr char kSavedModelConfigPath[] = "saved_model_config.pb";
30 
31 inline constexpr char kRemoteOpConfigRewriter[] = "remote_op_config_rewrite";
32 inline constexpr char kBatchOpRewriter[] = "batch_op_rewriter";
33 
34 inline constexpr char kRemoteOpRewriteConfigParamKey[] =
35  "remote_op_rewrite_config";
36 inline constexpr char kBatchOpRewriteConfigParamKey[] =
37  "batch_op_rewrite_config";
38 
39 // Extracts a `SavedModelConfig` proto from the optional asset file in the
40 // given directory. If the asset file does not exist, it returns an empty
41 // proto.
42 absl::StatusOr<SavedModelConfig> LoadSavedModelConfigOrDefault(
43  const std::string& export_dir);
44 
45 // Updates `rewrite_options` based on optimizers options in `session_overrides`.
46 void UpdateRewriterConfig(
47  const tensorflow::serving::SessionOverrides& session_overrides,
48  tensorflow::RewriterConfig* rewrite_options);
49 
50 } // namespace serving
51 } // namespace tensorflow
52 
53 #endif // #define
54  // TENSORFLOW_SERVING_SERVABLES_TENSORFLOW_SAVED_MODEL_CONFIG_UTIL_H_