TensorFlow Serving C++ API Documentation
platform_config_util.cc
1 /* Copyright 2016 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 #include "tensorflow_serving/model_servers/platform_config_util.h"
17 
18 #include "google/protobuf/any.pb.h"
19 #include "tensorflow_serving/model_servers/model_platform_types.h"
20 #include "tensorflow_serving/servables/tensorflow/saved_model_bundle_source_adapter.pb.h"
21 
22 namespace tensorflow {
23 namespace serving {
24 
25 PlatformConfigMap CreateTensorFlowPlatformConfigMap(
26  const SessionBundleConfig& session_bundle_config) {
27  PlatformConfigMap platform_config_map;
28  ::google::protobuf::Any source_adapter_config;
29  SavedModelBundleSourceAdapterConfig saved_model_bundle_source_adapter_config;
30  *saved_model_bundle_source_adapter_config.mutable_legacy_config() =
31  session_bundle_config;
32  source_adapter_config.PackFrom(saved_model_bundle_source_adapter_config);
33  (*(*platform_config_map.mutable_platform_configs())[kTensorFlowModelPlatform]
34  .mutable_source_adapter_config()) = source_adapter_config;
35  return platform_config_map;
36 }
37 
38 } // namespace serving
39 } // namespace tensorflow