1 /* Copyright 2021 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 // APIs for accessing SavedModel and checkpoint metric objects. 16 // 17 // In order to collect the data from these metrics, please add the metrics to 18 // the provided monitoring platform. Unless configured with a user-specified 19 // monitoring platform, the data is not collected in OSS. 20 21 #ifndef TENSORFLOW_CC_SAVED_MODEL_METRICS_H_ 22 #define TENSORFLOW_CC_SAVED_MODEL_METRICS_H_ 23 #include <string> 24 25 #include "tensorflow/core/lib/monitoring/counter.h" 26 #include "tensorflow/core/lib/monitoring/sampler.h" 27 28 namespace tensorflow { 29 namespace metrics { 30 31 // Returns "/tensorflow/core/saved_model/write/count" cell. This metric 32 // has 1 field "write_version", which is equal to the 33 // `tensorflow::libexport::GetWriteVersion` of the protobuf and should be 34 // incremented when a SavedModel has been successfully written. 35 monitoring::CounterCell& SavedModelWrite(absl::string_view write_version); 36 37 // Returns "/tensorflow/core/saved_model/read/count" cell. This metric 38 // has 1 field "write_version", which is equal to the 39 // `tensorflow::libexport::GetWriteVersion` of the protobuf, and should be 40 // incremented when a SavedModel has been successfully read. 41 monitoring::CounterCell& SavedModelRead(absl::string_view write_version); 42 43 // Returns "/tensorflow/core/saved_model/write/api" cell. This metric has 1 44 // field "api_label" which corresponds to a SavedModel write API. The cell for 45 // `foo` should be incremented when the write API `foo` is called. 46 monitoring::CounterCell& SavedModelWriteApi(absl::string_view api_label); 47 48 // Returns "/tensorflow/core/saved_model/read/api" cell. This metric has 1 49 // field "api_label" which corresponds to a SavedModel read API. The cell for 50 // `foo` should be incremented when the read API `foo` is called. 51 monitoring::CounterCell& SavedModelReadApi(absl::string_view api_label); 52 53 // Returns "/tensorflow/core/checkpoint/read/read_durations" cell belonging to 54 // field `api_label`. 55 monitoring::SamplerCell& CheckpointReadDuration(absl::string_view api_label); 56 57 // Returns "/tensorflow/core/checkpoint/write/write_durations" cell belonging to 58 // field `api_label`. 59 monitoring::SamplerCell& CheckpointWriteDuration(absl::string_view api_label); 60 61 // Returns "/tensorflow/core/checkpoint/write/training_time_saved" cell 62 // belonging to field `api_label`. 63 monitoring::CounterCell& TrainingTimeSaved(absl::string_view api_label); 64 65 } // namespace metrics 66 } // namespace tensorflow 67 68 #endif // TENSORFLOW_CC_SAVED_MODEL_METRICS_H_ 69