TensorFlow Serving C++ API Documentation
simple_servers.h
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 // Bootstrapping and configuration utilities for creating simple servers of
17 // TensorFlow models. Intended for basic instantiation with default configs.
18 //
19 // Note: All methods expect TensorFlow SavedModel conforming to the format
20 // specified at third_party/tensorflow/python/saved_model/README.md.
21 #ifndef TENSORFLOW_SERVING_SERVABLES_TENSORFLOW_SIMPLE_SERVERS_H_
22 #define TENSORFLOW_SERVING_SERVABLES_TENSORFLOW_SIMPLE_SERVERS_H_
23 
24 #include <memory>
25 #include <string>
26 
27 #include "tensorflow/cc/saved_model/loader.h"
28 #include "tensorflow/core/lib/core/status.h"
29 #include "tensorflow/core/platform/types.h"
30 #include "tensorflow_serving/core/manager.h"
31 #include "tensorflow_serving/core/storage_path.h"
32 #include "tensorflow_serving/core/target.h"
33 
34 namespace tensorflow {
35 namespace serving {
36 namespace simple_servers {
37 
38 // TODO(b/25969594): Add full test coverage.
39 
40 // Creates a Manager and associated Source for a single TensorFlow model that
41 // automatically loads new versions over time. All versions of the model will be
42 // loaded from new directories under the specified base path. Uses default
43 // SessionOptions.
44 //
45 // The servables loaded and served from this manager are of type
46 // tensorflow::SavedModelBundle.
47 //
48 // When new versions arrive the Manager will unload the previous version before
49 // loading the new version. This is preferable from a resource utilization
50 // perspective, but has reduced availability.
51 Status CreateSingleTFModelManagerFromBasePath(
52  const string& base_path, std::unique_ptr<Manager>* manager);
53 
54 } // namespace simple_servers
55 } // namespace serving
56 } // namespace tensorflow
57 
58 #endif // TENSORFLOW_SERVING_SERVABLES_TENSORFLOW_SIMPLE_SERVERS_H_