TensorFlow Serving C++ API Documentation
availability_preserving_policy.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 #ifndef TENSORFLOW_SERVING_CORE_AVAILABILITY_PRESERVING_POLICY_H_
17 #define TENSORFLOW_SERVING_CORE_AVAILABILITY_PRESERVING_POLICY_H_
18 
19 #include <vector>
20 
21 #include "tensorflow_serving/core/aspired_version_policy.h"
22 #include "tensorflow_serving/core/loader_harness.h"
23 
24 namespace tensorflow {
25 namespace serving {
26 
27 // AspiredVersionPolicy that provides servable availability with the trade-off
28 // of temporary increased resource consumption while newly-aspired versions load
29 // followed by newly-un-aspired versions unloading. At the same time, it tries
30 // to minimize the resource usage caused by loading more versions than needed to
31 // maintain availability.
32 //
33 // Here is a detailed description of how this policy works:
34 // First, if there are any unaspired loaded versions, we unload the smallest
35 // such version, *unless* that is the only loaded version (to avoid compromising
36 // availability).
37 // Second, if there are no non-aspired versions we are permitted to unload, we
38 // load the aspired new version with the highest version number.
40  public:
41  absl::optional<ServableAction> GetNextAction(
42  const std::vector<AspiredServableStateSnapshot>& all_versions)
43  const override;
44 };
45 
46 } // namespace serving
47 } // namespace tensorflow
48 
49 #endif // TENSORFLOW_SERVING_CORE_AVAILABILITY_PRESERVING_POLICY_H_
absl::optional< ServableAction > GetNextAction(const std::vector< AspiredServableStateSnapshot > &all_versions) const override