1 /* Copyright 2019 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_COMPILER_XRT_XRT_METRICS_H_ 17 #define TENSORFLOW_COMPILER_XRT_XRT_METRICS_H_ 18 19 #include "tensorflow/compiler/xla/statusor.h" 20 #include "tensorflow/compiler/xrt/xrt.pb.h" 21 #include "tensorflow/core/lib/monitoring/percentile_sampler.h" 22 23 namespace tensorflow { 24 namespace xrt_metrics { 25 26 // Defines the singletons of the metrics populated by the XRT op framework. 27 // Single of a single XRT op there can be many device specific versions (CPU, 28 // GPU, TPU), and since the monitoring subsystem does not allow multiple 29 // registrations of the same metric name, we define them all in this file. 30 monitoring::PercentileSamplerCell* GetAllocateCell(); 31 monitoring::PercentileSamplerCell* GetAllocateUninitializedCell(); 32 monitoring::PercentileSamplerCell* GetAllocateFromTensorCell(); 33 monitoring::PercentileSamplerCell* GetSubTupleCell(); 34 monitoring::PercentileSamplerCell* GetMakeTupleCell(); 35 monitoring::PercentileSamplerCell* GetReadLiteralCell(); 36 monitoring::PercentileSamplerCell* GetReadToTensorCell(); 37 monitoring::PercentileSamplerCell* GetWriteLiteralCell(); 38 monitoring::PercentileSamplerCell* GetReleaseAllocationCell(); 39 monitoring::PercentileSamplerCell* GetReleaseAllAllocationsCell(); 40 monitoring::PercentileSamplerCell* GetCompactAllocationsCell(); 41 monitoring::PercentileSamplerCell* GetCompileCell(); 42 monitoring::PercentileSamplerCell* GetReleaseCompilationCell(); 43 monitoring::PercentileSamplerCell* GetExecuteCell(); 44 monitoring::PercentileSamplerCell* GetExecuteChainedCell(); 45 monitoring::PercentileSamplerCell* GetMemoryCompactCell(); 46 monitoring::PercentileSamplerCell* GetTryFreeMemoryCell(); 47 48 } // namespace xrt_metrics 49 50 xla::StatusOr<xrt::MetricsReport> CollectMetrics( 51 const xrt::XRTMetricsCollect& metrics); 52 53 } // namespace tensorflow 54 55 #endif // TENSORFLOW_COMPILER_XRT_XRT_METRICS_H_ 56