Adds a null implementation for Counter metric for mobile platforms.
- Using counters in mobiles will do nothing now. Change: 130066962
This commit is contained in:
parent
579438b835
commit
9f17b70887
@ -159,6 +159,7 @@ cc_library(
|
|||||||
"lib/monitoring/collected_metrics.h",
|
"lib/monitoring/collected_metrics.h",
|
||||||
"lib/monitoring/collection_registry.h",
|
"lib/monitoring/collection_registry.h",
|
||||||
"lib/monitoring/counter.h",
|
"lib/monitoring/counter.h",
|
||||||
|
"lib/monitoring/mobile_counter.h",
|
||||||
"lib/monitoring/metric_def.h",
|
"lib/monitoring/metric_def.h",
|
||||||
"lib/random/distribution_sampler.h",
|
"lib/random/distribution_sampler.h",
|
||||||
"lib/random/philox_random.h",
|
"lib/random/philox_random.h",
|
||||||
|
@ -13,8 +13,15 @@ See the License for the specific language governing permissions and
|
|||||||
limitations under the License.
|
limitations under the License.
|
||||||
==============================================================================*/
|
==============================================================================*/
|
||||||
|
|
||||||
#ifndef THIRD_PARTY_TENSORFLOW_CORE_LIB_MONITORING_ACCUMULATOR_H_
|
#ifndef THIRD_PARTY_TENSORFLOW_CORE_LIB_MONITORING_COUNTER_H_
|
||||||
#define THIRD_PARTY_TENSORFLOW_CORE_LIB_MONITORING_ACCUMULATOR_H_
|
#define THIRD_PARTY_TENSORFLOW_CORE_LIB_MONITORING_COUNTER_H_
|
||||||
|
|
||||||
|
// We replace this implementation with a null implementation for mobile
|
||||||
|
// platforms.
|
||||||
|
#include "tensorflow/core/platform/platform.h"
|
||||||
|
#ifdef IS_MOBILE_PLATFORM
|
||||||
|
#include "tensorflow/core/lib/monitoring/mobile/counter.h"
|
||||||
|
#else
|
||||||
|
|
||||||
#include <array>
|
#include <array>
|
||||||
#include <atomic>
|
#include <atomic>
|
||||||
@ -59,7 +66,7 @@ class CounterCell {
|
|||||||
TF_DISALLOW_COPY_AND_ASSIGN(CounterCell);
|
TF_DISALLOW_COPY_AND_ASSIGN(CounterCell);
|
||||||
};
|
};
|
||||||
|
|
||||||
// A stateful class for updating a cumulative metric.
|
// A stateful class for updating a cumulative integer metric.
|
||||||
//
|
//
|
||||||
// This class encapsulates a set of values (or a single value for a label-less
|
// This class encapsulates a set of values (or a single value for a label-less
|
||||||
// metric). Each value is identified by a tuple of labels. The class allows the
|
// metric). Each value is identified by a tuple of labels. The class allows the
|
||||||
@ -159,4 +166,5 @@ CounterCell* Counter<NumLabels>::GetCell(const Labels&... labels)
|
|||||||
} // namespace monitoring
|
} // namespace monitoring
|
||||||
} // namespace tensorflow
|
} // namespace tensorflow
|
||||||
|
|
||||||
#endif // THIRD_PARTY_TENSORFLOW_CORE_LIB_MONITORING_ACCUMULATOR_H_
|
#endif // IS_MOBILE_PLATFORM
|
||||||
|
#endif // THIRD_PARTY_TENSORFLOW_CORE_LIB_MONITORING_COUNTER_H_
|
||||||
|
67
tensorflow/core/lib/monitoring/mobile_counter.h
Normal file
67
tensorflow/core/lib/monitoring/mobile_counter.h
Normal file
@ -0,0 +1,67 @@
|
|||||||
|
/* Copyright 2016 The TensorFlow Authors. All Rights Reserved.
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
==============================================================================*/
|
||||||
|
|
||||||
|
// Null implementation of the Counter metric for mobile platforms.
|
||||||
|
|
||||||
|
#ifndef THIRD_PARTY_TENSORFLOW_CORE_LIB_MONITORING_MOBILE_COUNTER_H_
|
||||||
|
#define THIRD_PARTY_TENSORFLOW_CORE_LIB_MONITORING_MOBILE_COUNTER_H_
|
||||||
|
|
||||||
|
#include "tensorflow/core/lib/monitoring/metric_def.h"
|
||||||
|
#include "tensorflow/core/platform/macros.h"
|
||||||
|
|
||||||
|
namespace tensorflow {
|
||||||
|
namespace monitoring {
|
||||||
|
|
||||||
|
// CounterCell which has a null implementation.
|
||||||
|
class CounterCell {
|
||||||
|
public:
|
||||||
|
CounterCell() {}
|
||||||
|
~CounterCell() {}
|
||||||
|
|
||||||
|
void IncrementBy(int64 step) {}
|
||||||
|
int64 value() const { return 0; }
|
||||||
|
|
||||||
|
private:
|
||||||
|
TF_DISALLOW_COPY_AND_ASSIGN(CounterCell);
|
||||||
|
};
|
||||||
|
|
||||||
|
// Counter which has a null implementation.
|
||||||
|
template <int NumLabels>
|
||||||
|
class Counter {
|
||||||
|
public:
|
||||||
|
~Counter() {}
|
||||||
|
|
||||||
|
static Counter* New(
|
||||||
|
const MetricDef<MetricKind::kCumulative, int64, NumLabels>& metric_def) {
|
||||||
|
return new Counter<NumLabels>();
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename... Labels>
|
||||||
|
CounterCell* GetCell(const Labels&... labels) {
|
||||||
|
return &default_counter_cell_;
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
Counter() {}
|
||||||
|
|
||||||
|
CounterCell default_counter_cell_;
|
||||||
|
|
||||||
|
TF_DISALLOW_COPY_AND_ASSIGN(Counter);
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace monitoring
|
||||||
|
} // namespace tensorflow
|
||||||
|
|
||||||
|
#endif // THIRD_PARTY_TENSORFLOW_CORE_LIB_MONITORING_MOBILE_COUNTER_H_
|
Loading…
x
Reference in New Issue
Block a user