TensorFlow Serving C++ API Documentation
saved_model_warmup_test_util.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 #ifndef THIRD_PARTY_TENSORFLOW_SERVING_SERVABLES_TENSORFLOW_SAVED_MODEL_WARMUP_TEST_UTIL_H_
17 #define THIRD_PARTY_TENSORFLOW_SERVING_SERVABLES_TENSORFLOW_SAVED_MODEL_WARMUP_TEST_UTIL_H_
18 
19 #include <string>
20 
21 #include "tensorflow/core/lib/io/path.h"
22 #include "tensorflow/core/lib/io/record_writer.h"
23 #include "tensorflow/core/platform/status.h"
24 #include "tensorflow/core/protobuf/meta_graph.pb.h"
25 #include "tensorflow_serving/apis/classification.pb.h"
26 #include "tensorflow_serving/apis/inference.pb.h"
27 #include "tensorflow_serving/apis/input.pb.h"
28 #include "tensorflow_serving/apis/model.pb.h"
29 #include "tensorflow_serving/apis/predict.pb.h"
30 #include "tensorflow_serving/apis/prediction_log.pb.h"
31 #include "tensorflow_serving/apis/regression.pb.h"
32 #include "tensorflow_serving/servables/tensorflow/session_bundle_config.pb.h"
33 
34 namespace tensorflow {
35 namespace serving {
36 
37 void PopulateInferenceTask(const string& model_name,
38  const string& signature_name,
39  const string& method_name, InferenceTask* task);
40 
41 void PopulateMultiInferenceRequest(MultiInferenceRequest* request);
42 
43 void PopulatePredictRequest(PredictRequest* request);
44 
45 void PopulateClassificationRequest(ClassificationRequest* request);
46 
47 void PopulateRegressionRequest(RegressionRequest* request);
48 
49 Status PopulatePredictionLog(PredictionLog* prediction_log,
50  PredictionLog::LogTypeCase log_type,
51  int num_repeated_values = 1);
52 
53 Status WriteWarmupData(const string& fname,
54  const std::vector<string>& warmup_records,
55  int num_warmup_records);
56 
57 Status WriteWarmupDataAsSerializedProtos(
58  const string& fname, const std::vector<string>& warmup_records,
59  int num_warmup_records);
60 
61 Status AddMixedWarmupData(
62  std::vector<string>* warmup_records,
63  const std::vector<PredictionLog::LogTypeCase>& log_types = {
64  PredictionLog::kRegressLog, PredictionLog::kClassifyLog,
65  PredictionLog::kPredictLog, PredictionLog::kMultiInferenceLog});
66 
67 Status AddToWarmupData(std::vector<string>* warmup_records,
68  PredictionLog::LogTypeCase log_type,
69  int num_repeated_values = 1);
70 
71 // Creates a test SignatureDef with the given parameters
72 SignatureDef CreateSignatureDef(const string& method_name,
73  const std::vector<string>& input_names,
74  const std::vector<string>& output_names);
75 
76 void AddSignatures(MetaGraphDef* meta_graph_def);
77 
78 } // namespace serving
79 } // namespace tensorflow
80 
81 #endif // THIRD_PARTY_TENSORFLOW_SERVING_SERVABLES_TENSORFLOW_SAVED_MODEL_WARMUP_TEST_UTIL_H_