TensorFlow Serving C++ API Documentation
tfrt_classifier.h
1 /* Copyright 2020 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 // TensorFlow implementation of the ClassifierInterface.
17 
18 #ifndef TENSORFLOW_SERVING_SERVABLES_TENSORFLOW_TFRT_CLASSIFIER_H_
19 #define TENSORFLOW_SERVING_SERVABLES_TENSORFLOW_TFRT_CLASSIFIER_H_
20 
21 #include <memory>
22 
23 #include "absl/types/optional.h"
24 #include "tensorflow/cc/saved_model/loader.h"
25 #include "tensorflow/core/lib/core/status.h"
26 #include "tensorflow/core/platform/threadpool_options.h"
27 #include "tensorflow/core/tfrt/saved_model/saved_model.h"
28 #include "tensorflow_serving/apis/classifier.h"
29 
30 namespace tensorflow {
31 namespace serving {
32 // Validate function's input and output.
33 Status PreProcessClassification(
34  const tfrt::FunctionMetadata& function_metadata);
35 
36 // Validate all results and populate a ClassificationResult.
37 Status PostProcessClassificationResult(
38  int num_examples, const std::vector<string>& output_names,
39  const std::vector<Tensor>& output_tensors, ClassificationResult* result);
40 
41 // Run Classification.
42 Status RunClassify(const tfrt::SavedModel::RunOptions& run_options,
43  const absl::optional<int64_t>& servable_version,
44  tfrt::SavedModel* saved_model,
45  const ClassificationRequest& request,
46  ClassificationResponse* response);
47 
48 } // namespace serving
49 } // namespace tensorflow
50 
51 #endif // TENSORFLOW_SERVING_SERVABLES_TENSORFLOW_TFRT_CLASSIFIER_H_