TensorFlow Serving C++ API Documentation
tfrt_prediction_service_impl.h
1 /* Copyright 2022 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_MODEL_SERVERS_TFRT_PREDICTION_SERVICE_IMPL_H_
17 #define TENSORFLOW_SERVING_MODEL_SERVERS_TFRT_PREDICTION_SERVICE_IMPL_H_
18 
19 #include "tensorflow_serving/apis/prediction_service.grpc.pb.h"
20 #include "tensorflow_serving/model_servers/prediction_service_util.h"
21 
22 namespace tensorflow {
23 namespace serving {
24 
26  : public PredictionService::Service {
27  public:
29  : core_(options.server_core),
30  enforce_session_run_timeout_(options.enforce_session_run_timeout),
31  thread_pool_factory_(options.thread_pool_factory) {}
32 
33  ::grpc::Status Predict(::grpc::ServerContext* context,
34  const PredictRequest* request,
35  PredictResponse* response) override;
36 
37  ::grpc::Status GetModelMetadata(::grpc::ServerContext* context,
38  const GetModelMetadataRequest* request,
39  GetModelMetadataResponse* response) override;
40 
41  ::grpc::Status Classify(::grpc::ServerContext* context,
42  const ClassificationRequest* request,
43  ClassificationResponse* response) override;
44 
45  ::grpc::Status Regress(::grpc::ServerContext* context,
46  const RegressionRequest* request,
47  RegressionResponse* response) override;
48 
49  ::grpc::Status MultiInference(::grpc::ServerContext* context,
50  const MultiInferenceRequest* request,
51  MultiInferenceResponse* response) override;
52 
53  private:
54  absl::Time GetRequestDeadline(::grpc::ServerContext* context) const;
55 
56  ServerCore* core_;
57  const bool enforce_session_run_timeout_;
58  ThreadPoolFactory* thread_pool_factory_;
59 };
60 
61 } // namespace serving
62 } // namespace tensorflow
63 
64 #endif // TENSORFLOW_SERVING_MODEL_SERVERS_TFRT_PREDICTION_SERVICE_IMPL_H_