diff options
author | 2018-09-05 22:20:40 -0700 | |
---|---|---|
committer | 2018-09-05 22:24:53 -0700 | |
commit | 5393c8f0dc57857c93482bff67f1134aae9af594 (patch) | |
tree | 328238d0953ecee9e4fa3341189857846985dd1d /tensorflow/core/platform | |
parent | f4ae136265d3d3116a008b98ccf21d0791b878fd (diff) |
Add `TraceCollector::IsEnabled(bool)` method in order to test when tracing is enabled.
Some builds install a `TraceCollector` at process startup, but it is mostly not enabled. This inhibits the recent optimization to avoid accessing `OpKernel::name()` and `OpKernel::type_string()` every time a kernel is launched. By caching the `TraceCollector` in the `TracingDevice` and adding a method to enquire about its state, we increase the applicability of the optimization.
PiperOrigin-RevId: 211752728
Diffstat (limited to 'tensorflow/core/platform')
-rw-r--r-- | tensorflow/core/platform/default/device_tracer.cc | 5 | ||||
-rw-r--r-- | tensorflow/core/platform/tracing.h | 4 |
2 files changed, 9 insertions, 0 deletions
diff --git a/tensorflow/core/platform/default/device_tracer.cc b/tensorflow/core/platform/default/device_tracer.cc index ccddf1eafc..0389149469 100644 --- a/tensorflow/core/platform/default/device_tracer.cc +++ b/tensorflow/core/platform/default/device_tracer.cc @@ -321,6 +321,11 @@ class DeviceTracerImpl : public DeviceTracer, return nullptr; } + bool IsEnabled(bool is_expensive) const override { + // We don't do anything with 'Activities' so we are never 'enabled'. + return false; + } + protected: // This callback is used exclusively by CUPTIManager. friend class CUPTIManager; diff --git a/tensorflow/core/platform/tracing.h b/tensorflow/core/platform/tracing.h index e5851f1dfe..9974bbbb4e 100644 --- a/tensorflow/core/platform/tracing.h +++ b/tensorflow/core/platform/tracing.h @@ -155,6 +155,10 @@ class TraceCollector { StringPiece name_part1, StringPiece name_part2, bool is_expensive) const = 0; + // Returns true if this activity handle tracking is enabled for an op of the + // given expensiveness. + virtual bool IsEnabled(bool is_expensive) const = 0; + protected: static string ConcatenateNames(StringPiece first, StringPiece second); |