TensorFlow Serving C++ API Documentation
session_bundle_util.cc
1 /* Copyright 2019 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/session_bundle/session_bundle_util.h"
17 
18 #include <functional>
19 #include <unordered_set>
20 
21 #include "tensorflow/cc/saved_model/loader.h"
22 #include "tensorflow/core/lib/core/errors.h"
23 #include "tensorflow/core/platform/env.h"
24 #include "tensorflow/core/platform/path.h"
25 #include "tensorflow_serving/session_bundle/manifest_proto.h"
26 
27 namespace tensorflow {
28 namespace serving {
29 
30 namespace session_bundle {
31 
32 Status ConvertSignaturesToSignatureDefs(MetaGraphDef* meta_graph_def) {
33  return errors::Unimplemented("Session Bundle is deprecated and removed.");
34 }
35 
36 Status ConvertSessionBundleToSavedModelBundle(
37  SessionBundle& session_bundle, SavedModelBundle* saved_model_bundle) {
38  return errors::Unimplemented("Session Bundle is deprecated and removed.");
39 }
40 
41 Status LoadSessionBundleOrSavedModelBundle(
42  const SessionOptions& session_options, const RunOptions& run_options,
43  const string& export_dir, const std::unordered_set<string>& tags,
44  bool maybe_load_saved_model_config, SavedModelBundle* bundle,
45  bool* is_session_bundle) {
46  if (maybe_load_saved_model_config) {
47  return errors::Unimplemented(
48  "Saved model config functionality is not implemented.");
49  }
50  return LoadSessionBundleOrSavedModelBundle(session_options, run_options,
51  export_dir, tags, bundle,
52  is_session_bundle);
53 }
54 
55 Status LoadSessionBundleOrSavedModelBundle(
56  const SessionOptions& session_options, const RunOptions& run_options,
57  const string& export_dir, const std::unordered_set<string>& tags,
58  SavedModelBundle* bundle, bool* is_session_bundle) {
59  if (is_session_bundle != nullptr) {
60  *is_session_bundle = false;
61  }
62  if (Env::Default()
63  ->FileExists(io::JoinPath(export_dir, "export.meta"))
64  .ok()) {
65  return errors::Unimplemented("Session Bundle is deprecated and removed.");
66  }
67  if (MaybeSavedModelDirectory(export_dir)) {
68  return LoadSavedModel(session_options, run_options, export_dir, tags,
69  bundle);
70  }
71  return Status(
72  static_cast<absl::StatusCode>(absl::StatusCode::kNotFound),
73  strings::StrCat("Specified file path does not appear to contain a "
74  "SavedModel bundle (should have a file called "
75  "`saved_model.pb`)\n"
76  "Specified file path: ",
77  export_dir));
78 }
79 
80 Status LoadSessionBundleFromPathUsingRunOptions(
81  const SessionOptions& session_options, const RunOptions& run_options,
82  const StringPiece export_dir, SessionBundle* bundle) {
83  return errors::Unimplemented("Session Bundle is deprecated and removed.");
84 }
85 
86 Status SetSignatures(const Signatures& signatures,
87  tensorflow::MetaGraphDef* meta_graph_def) {
88  return errors::Unimplemented("Session Bundle is deprecated and removed.");
89 }
90 
91 Status GetClassificationSignature(
92  const tensorflow::MetaGraphDef& meta_graph_def,
93  ClassificationSignature* signature) {
94  return errors::Unimplemented("Session Bundle is deprecated and removed.");
95 }
96 
97 Status GetRegressionSignature(const tensorflow::MetaGraphDef& meta_graph_def,
98  RegressionSignature* signature) {
99  return errors::Unimplemented("Session Bundle is deprecated and removed.");
100 }
101 
102 Status RunClassification(const ClassificationSignature& signature,
103  const Tensor& input, Session* session, Tensor* classes,
104  Tensor* scores) {
105  return errors::Unimplemented("Session Bundle is deprecated and removed.");
106 }
107 
108 Status RunRegression(const RegressionSignature& signature, const Tensor& input,
109  Session* session, Tensor* output) {
110  return errors::Unimplemented("Session Bundle is deprecated and removed.");
111 }
112 
113 Status GetNamedSignature(const string& name,
114  const tensorflow::MetaGraphDef& meta_graph_def,
115  Signature* default_signature) {
116  return errors::Unimplemented("Session Bundle is deprecated and removed.");
117 }
118 
119 } // namespace session_bundle
120 } // namespace serving
121 } // namespace tensorflow