-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Defer image/audio/histogram v2 summary preprocessing using LazyTensorCreator #2899
Conversation
@@ -29,11 +29,14 @@ | |||
from __future__ import division | |||
from __future__ import print_function | |||
|
|||
import functools |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unused?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed, thanks.
|
||
def test_reentrant_callable_does_not_deadlock(self): | ||
@lazy_tensor_creator.LazyTensorCreator | ||
def lazy_tensor(nested_call=False): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this nested_call=False
vestigial?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, removed. Thanks for the catch.
To defer image/audio/histogram v2 summary preprocessing. See tensorflow#2899 for more details.
* use LazyTensorCreator To defer image/audio/histogram v2 summary preprocessing. See #2899 for more details. * add _buckets_v3 skeleton It's currently just a copy of _buckets(), modification for single value case handling will be added later.
…low#5352) * use LazyTensorCreator To defer image/audio/histogram v2 summary preprocessing. See tensorflow#2899 for more details. * add _buckets_v3 skeleton It's currently just a copy of _buckets(), modification for single value case handling will be added later.
…low#5352) * use LazyTensorCreator To defer image/audio/histogram v2 summary preprocessing. See tensorflow#2899 for more details. * add _buckets_v3 skeleton It's currently just a copy of _buckets(), modification for single value case handling will be added later.
Continuation of PRs #2893, #2894, #2895 by @hongjunChoi .
This takes advantage of a recent change in
tf.summary.write()
as of tensorflow/tensorflow@661f0ac that allows passing a callable as thetensor
argument instead of an actualtf.Tensor
. With this functionality,write()
will call the callable to get the tensor only if the tensor is going to be used (i.e. the summary writer exists and the summary recording condition is met). This avoids overhead in executing preprocessing steps when they are not needed. Among V2 summaries, only image, audio, and histogram do any real preprocessing, so those are the only ones changed in this PR.In order to maintain backwards compatibility with the previous
write()
API, this introduces a shim layer calledLazyTensorCreator
that usestf.register_tensor_conversion_function()
to ensure that the callable we pass in can be automatically converted to atf.Tensor
in many contexts (and in particular, in the context of the call totf.identity()
which is used insidewrite()
). That way a version skew (e.g. TensorBoard 2.1 but TensorFlow 2.0) won't break the summary API integration; while technically we don't guarantee that a skew in this direction will work, this is a likely enough situation and a confusing enough error that it's worth a bit of work to avoid.cc @alextp FYI