• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_CORE_LIB_MONITORING_MOBILE_PERCENTILE_SAMPLER_H_
17 #define TENSORFLOW_CORE_LIB_MONITORING_MOBILE_PERCENTILE_SAMPLER_H_
18 
19 #include "tensorflow/core/lib/core/status.h"
20 #include "tensorflow/core/lib/monitoring/collection_registry.h"
21 #include "tensorflow/core/lib/monitoring/metric_def.h"
22 #include "tensorflow/core/lib/monitoring/types.h"
23 #include "tensorflow/core/platform/macros.h"
24 
25 namespace tensorflow {
26 namespace monitoring {
27 
28 class PercentileSamplerCell {
29  public:
Add(double sample)30   void Add(double sample) {}
31 
value()32   Percentiles value() const { return Percentiles(); }
33 };
34 
35 template <int NumLabels>
36 class PercentileSampler {
37  public:
38   static PercentileSampler* New(
39       const MetricDef<MetricKind::kCumulative, Percentiles, NumLabels>&
40           metric_def,
41       std::vector<double> percentiles, size_t max_samples);
42 
43   template <typename... Labels>
GetCell(const Labels &...labels)44   PercentileSamplerCell* GetCell(const Labels&... labels) {
45     return &default_cell_;
46   }
47 
GetStatus()48   Status GetStatus() { return Status::OK(); }
49 
50  private:
51   PercentileSamplerCell default_cell_;
52 
53   TF_DISALLOW_COPY_AND_ASSIGN(PercentileSampler);
54 };
55 
56 template <int NumLabels>
New(const MetricDef<MetricKind::kCumulative,Percentiles,NumLabels> &,std::vector<double>,size_t)57 PercentileSampler<NumLabels>* PercentileSampler<NumLabels>::New(
58     const MetricDef<MetricKind::kCumulative, Percentiles, NumLabels>&
59     /* metric_def */,
60     std::vector<double> /* percentiles */, size_t /* max_samples */) {
61   return new PercentileSampler<NumLabels>();
62 }
63 
64 }  // namespace monitoring
65 }  // namespace tensorflow
66 
67 #endif  // TENSORFLOW_CORE_LIB_MONITORING_MOBILE_PERCENTILE_SAMPLER_H_
68