-
Notifications
You must be signed in to change notification settings - Fork 74k
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
support run_options and run_metadata for tf.keras.function #19932
support run_options and run_metadata for tf.keras.function #19932
Conversation
f = keras.backend.function(inputs=[x_placeholder, y_placeholder], | ||
outputs=[x_placeholder + y_placeholder], | ||
updates=[(x, x_placeholder + 1.)], | ||
fetches=[keras.backend.update(y, 5.)]) | ||
fetches=[keras.backend.update(y, 5.)], | ||
options=run_options) |
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.
I'd argue that this test is inadequate because it doesn't verify the effect of sending the run_options.
I suggest you use both the options
and run_metadata
keywords here and set output_partition_graphs
of RunOptions
to True
. Then you can verify that the partition_graphs
of run_metadata
is set after the call.
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.
I agree that it's better to add run_metadata
keyword, however I'm afraid _make_callable_from_options
doesn't support run_metadata
yet.
callable_fn = session._make_callable_from_options(callable_opts)
The solution I can see is
- to replace
session._make_callable_from_options
bysession.make_callable
, - or, to add
run_metadata
support for TF_SessionMakeCallable.
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.
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.
Thank you for letting me know. I'd like to add the argument in the weekend.
tensorflow/python/keras/backend.py
Outdated
@@ -2759,7 +2759,8 @@ class Function(object): | |||
outputs: Output tensors to fetch. | |||
updates: Additional update ops to be run at function call. | |||
name: A name to help users identify what this function does. | |||
session_kwargs: Arguments to `tf.Session.run()`: `fetches`, `feed_dict`. | |||
session_kwargs: Arguments to `tf.Session.run()`: | |||
`fetches`, `feed_dict`, `options`. |
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.
There is run_metadata
as well, which is useful for things like getting the partition graphs and step_stats
.
@@ -2844,6 +2846,9 @@ def _make_callable(self, feed_arrays, feed_symbols, symbol_vals, session): | |||
callable_opts.fetch.append(x.name) | |||
# Handle updates. | |||
callable_opts.target.append(self.updates_op.name) | |||
# Handle run_options. | |||
if self.run_options: |
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.
As mentioned above, handle run_metadata
as well.
@mrry could you please take a look? Thank you! |
Looks fine to me, but none of this is in code I own, so is there anything specific you'd like me to review? |
…onfigs_for_keras_model
This reverts commit ffc5c4e.
tensorflow/python/keras/backend.py
Outdated
fetched = self._callable_fn(*array_vals) | ||
if self.run_metadata: | ||
fetched = self._callable_fn(*array_vals, | ||
run_metadata=self.run_metadata) |
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 it possible to always use lines 2908-2099? I'm guessing (and not sure) that if self.run_metadata
is None
, it'll be handled correctly?
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.
Thank you, I think so.
Nagging Assignee @caisq: It has been 15 days with no activity and this issue has an assignee. Please update the label and/or status accordingly. |
…onfigs_for_keras_model
tensorflow/tensorflow#19932 metadata can only be passed to the callable when the session is instrumented
tensorflow/tensorflow#19932 metadata can only be passed to the callable when the session is instrumented
tensorflow/tensorflow#19932 metadata can only be passed to the callable when the session is instrumented
Nagging Assignee @caisq: It has been 14 days with no activity and this issue has an assignee. Please update the label and/or status accordingly. |
Hi, could anyone take a look? I think the PR has been pending for a long time. Thanks. |
This would definitely be useful to have. |
@martinwicke Could you take a look? I think the PR is pending for a long time. |
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.
The code looks good to me. I am not very familiar with run_options
so I will wait for one more person to review.
@pavithrasv Thank you. Could you ping a reviewer who you think is available now? |
@@ -2762,7 +2762,8 @@ class Function(object): | |||
outputs: Output tensors to fetch. | |||
updates: Additional update ops to be run at function call. | |||
name: A name to help users identify what this function does. | |||
session_kwargs: Arguments to `tf.Session.run()`: `fetches`, `feed_dict`. | |||
session_kwargs: Arguments to `tf.Session.run()`: |
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.
Sorry for the delay in getting back. This PR LGTM except for a minor comment.
session_kwarg
is not precise. It should be called session_run_kwarg
, otherwise it may be confused with kwargs that you can use when creating a session (e.g., https://www.tensorflow.org/api_docs/python/tf/Session)
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.
Never mind. This is an existing name and changing it would be breaking.
many thanks. Py2 Build failed. Could you restart it? |
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.
Looks good to me, thank you! Sorry for the delayed review.
tensorflow/tensorflow#19932 metadata can only be passed to the callable when the session is instrumented
…as_model PiperOrigin-RevId: 209546715
Fix #19911.
cc @fchollet