-
Notifications
You must be signed in to change notification settings - Fork 75.3k
support run_options and run_metadata for tf.keras.function #19932
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
Merged
tensorflow-copybara
merged 7 commits into
tensorflow:master
from
facaiy:ENH/support_run_configs_for_keras_model
Aug 21, 2018
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
ffc5c4e
TST: add test case
facaiy a584096
ENH: support run options for function
facaiy 13241bb
Merge remote-tracking branch 'upstream/master' into ENH/support_run_c…
facaiy 4bb5c26
Revert "TST: add test case"
facaiy c551451
ENH: add run_metadata argument
facaiy e12a33c
CLN: remove redundant if...else
facaiy 144ffee
Merge remote-tracking branch 'upstream/master' into ENH/support_run_c…
facaiy File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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()`: | ||
| `fetches`, `feed_dict`, `options`, `run_metadata`. | ||
| """ | ||
|
|
||
| def __init__(self, inputs, outputs, updates=None, name=None, | ||
|
|
@@ -2796,6 +2797,8 @@ def __init__(self, inputs, outputs, updates=None, name=None, | |
| self.fetches = session_kwargs.pop('fetches', []) | ||
| if not isinstance(self.fetches, list): | ||
| self.fetches = [self.fetches] | ||
| self.run_options = session_kwargs.pop('options', None) | ||
| self.run_metadata = session_kwargs.pop('run_metadata', None) | ||
| # The main use case of `fetches` being passed to a model is the ability | ||
| # to run custom updates | ||
| # This requires us to wrap fetches in `identity` ops. | ||
|
|
@@ -2853,6 +2856,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: | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As mentioned above, handle |
||
| callable_opts.run_options.CopyFrom(self.run_options) | ||
| # Create callable. | ||
| callable_fn = session._make_callable_from_options(callable_opts) | ||
| # Cache parameters corresponding to the generated callable, so that | ||
|
|
@@ -2911,7 +2917,8 @@ def __call__(self, inputs): | |
| session != self._session): | ||
| self._make_callable(feed_arrays, feed_symbols, symbol_vals, session) | ||
|
|
||
| fetched = self._callable_fn(*array_vals) | ||
| fetched = self._callable_fn(*array_vals, | ||
| run_metadata=self.run_metadata) | ||
| self._call_fetch_callbacks(fetched[-len(self._fetches):]) | ||
| return fetched[:len(self.outputs)] | ||
|
|
||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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_kwargis not precise. It should be calledsession_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.