diff options
author | Derek Murray <mrry@google.com> | 2018-09-24 14:34:57 -0700 |
---|---|---|
committer | TensorFlower Gardener <gardener@tensorflow.org> | 2018-09-24 14:39:31 -0700 |
commit | aab3c53e1484404a70565324d1231c4e6ead7425 (patch) | |
tree | ec04217c08795c7a30ee5bf7af86d7f2b81ec53c /tensorflow/core/platform | |
parent | 567a7196494a79988337bcb726c0c5d453298c99 (diff) |
Inline kernel tracing logic into `ExecutorState::Process()`.
All devices implement the same tracing logic in an override of `Device::Compute()`. However, that logic does not have access to the cached `NodeItem::kernel_is_expensive` bit for the kernel, so it must make a virtual call to `OpKernel::IsExpensive()`. By inlining the logic into `ExecutorState::Process()`, we avoid making an unnecessary virtual call on each kernel invocation (when a trace controller is attached).
PiperOrigin-RevId: 214332492
Diffstat (limited to 'tensorflow/core/platform')
-rw-r--r-- | tensorflow/core/platform/default/device_tracer.cc | 7 | ||||
-rw-r--r-- | tensorflow/core/platform/tracing.h | 5 |
2 files changed, 10 insertions, 2 deletions
diff --git a/tensorflow/core/platform/default/device_tracer.cc b/tensorflow/core/platform/default/device_tracer.cc index 0389149469..83c65dbfa9 100644 --- a/tensorflow/core/platform/default/device_tracer.cc +++ b/tensorflow/core/platform/default/device_tracer.cc @@ -321,7 +321,12 @@ class DeviceTracerImpl : public DeviceTracer, return nullptr; } - bool IsEnabled(bool is_expensive) const override { + bool IsEnabledForAnnotations() const override { + // We are always enabled for 'Annotations'. + return true; + } + + bool IsEnabledForActivities(bool is_expensive) const override { // We don't do anything with 'Activities' so we are never 'enabled'. return false; } diff --git a/tensorflow/core/platform/tracing.h b/tensorflow/core/platform/tracing.h index 9974bbbb4e..aefbe64425 100644 --- a/tensorflow/core/platform/tracing.h +++ b/tensorflow/core/platform/tracing.h @@ -155,9 +155,12 @@ class TraceCollector { StringPiece name_part1, StringPiece name_part2, bool is_expensive) const = 0; + // Returns true if this annotation tracing is enabled for any op. + virtual bool IsEnabledForAnnotations() 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; + virtual bool IsEnabledForActivities(bool is_expensive) const = 0; protected: static string ConcatenateNames(StringPiece first, StringPiece second); |