diff --git a/tensorflow/core/BUILD b/tensorflow/core/BUILD index 32fb8762aa8..3ccd209a40e 100644 --- a/tensorflow/core/BUILD +++ b/tensorflow/core/BUILD @@ -159,6 +159,7 @@ cc_library( "lib/monitoring/collected_metrics.h", "lib/monitoring/collection_registry.h", "lib/monitoring/counter.h", + "lib/monitoring/mobile_counter.h", "lib/monitoring/metric_def.h", "lib/random/distribution_sampler.h", "lib/random/philox_random.h", diff --git a/tensorflow/core/lib/monitoring/counter.h b/tensorflow/core/lib/monitoring/counter.h index 2b4689d11bf..0a722a1c5ee 100644 --- a/tensorflow/core/lib/monitoring/counter.h +++ b/tensorflow/core/lib/monitoring/counter.h @@ -13,8 +13,15 @@ See the License for the specific language governing permissions and limitations under the License. ==============================================================================*/ -#ifndef THIRD_PARTY_TENSORFLOW_CORE_LIB_MONITORING_ACCUMULATOR_H_ -#define THIRD_PARTY_TENSORFLOW_CORE_LIB_MONITORING_ACCUMULATOR_H_ +#ifndef THIRD_PARTY_TENSORFLOW_CORE_LIB_MONITORING_COUNTER_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 #include @@ -59,7 +66,7 @@ class 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 // metric). Each value is identified by a tuple of labels. The class allows the @@ -159,4 +166,5 @@ CounterCell* Counter::GetCell(const Labels&... labels) } // namespace monitoring } // namespace tensorflow -#endif // THIRD_PARTY_TENSORFLOW_CORE_LIB_MONITORING_ACCUMULATOR_H_ +#endif // IS_MOBILE_PLATFORM +#endif // THIRD_PARTY_TENSORFLOW_CORE_LIB_MONITORING_COUNTER_H_ diff --git a/tensorflow/core/lib/monitoring/mobile_counter.h b/tensorflow/core/lib/monitoring/mobile_counter.h new file mode 100644 index 00000000000..5847249248d --- /dev/null +++ b/tensorflow/core/lib/monitoring/mobile_counter.h @@ -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 +class Counter { + public: + ~Counter() {} + + static Counter* New( + const MetricDef& metric_def) { + return new Counter(); + } + + template + 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_