• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* Copyright 2020 The TensorFlow Authors. 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_C_EXPERIMENTAL_SAVED_MODEL_CORE_SAVED_MODEL_API_H_
17 #define TENSORFLOW_C_EXPERIMENTAL_SAVED_MODEL_CORE_SAVED_MODEL_API_H_
18 
19 #include <memory>
20 #include <string>
21 #include <unordered_set>
22 #include <vector>
23 
24 #include "tensorflow/c/experimental/saved_model/core/concrete_function.h"
25 #include "tensorflow/c/experimental/saved_model/core/signature_def_function.h"
26 #include "tensorflow/core/platform/status.h"
27 
28 namespace tensorflow {
29 
30 // Note(bmzhao): This class is only TEMPORARILY virtual, as a way to unblock
31 // TFRT integration with TF Serving. Do not add more virtual implementations of
32 // this class. Eventually we want to remove this virtual base class indirection
33 // and have only a single implementation.
34 class SavedModelAPI {
35  public:
36   // Retrieve a function from the TF2 SavedModel, using the "path" to a function
37   // in a TF2 savedmodel.
38   // Note: `function` is a double pointer, so that implementations are
39   // able to return a pointer to an internal member.
40   virtual Status GetFunction(const std::string& function_path,
41                              ConcreteFunction** function) = 0;
42 
43   // Retrieve a SignatureDefFunction from a SavedModel, using the key of the
44   // SignatureDef map:
45   // https://github.com/tensorflow/tensorflow/blob/69b08900b1e991d84bce31f3b404f5ed768f339f/tensorflow/core/protobuf/meta_graph.proto#L89
46   virtual Status GetSignatureDefFunction(const std::string& signature_def_key,
47                                          SignatureDefFunction** function) = 0;
48 
49   virtual ~SavedModelAPI() = default;
50 };
51 
52 }  // namespace tensorflow
53 
54 #endif  // TENSORFLOW_C_EXPERIMENTAL_SAVED_MODEL_CORE_SAVED_MODEL_API_H_
55