-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Prefilter graphs in the uploader #3497
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
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
dd8e8dc
Prefilter graphs in the uploader (stopgap proposal)
davidsoergel bbe4a03
Add test and cleanup
davidsoergel 69dd0b6
Remove redundant asserts
davidsoergel 2940eb9
Clarify test
davidsoergel ef7a10b
Actually trigger the graph filtering in the uploader
davidsoergel 95da811
Simplify test, and other reviewer comments
davidsoergel 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
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
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 |
|---|---|---|
|
|
@@ -25,7 +25,10 @@ | |
| from __future__ import division | ||
| from __future__ import print_function | ||
|
|
||
|
|
||
| from tensorboard.backend import process_graph | ||
| from tensorboard.compat.proto import event_pb2 | ||
| from tensorboard.compat.proto import graph_pb2 | ||
| from tensorboard.compat.proto import summary_pb2 | ||
| from tensorboard.compat.proto import types_pb2 | ||
| from tensorboard.plugins.graph import metadata as graphs_metadata | ||
|
|
@@ -37,30 +40,44 @@ | |
| from tensorboard.util import tensor_util | ||
|
|
||
|
|
||
| def migrate_event(event): | ||
| def migrate_event(event, experimental_filter_graph=False): | ||
|
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. Please add doc string for the new kwarg.
Member
Author
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. Oops, done. |
||
| """Migrate an event to a sequence of events. | ||
|
|
||
| Args: | ||
| event: An `event_pb2.Event`. The caller transfers ownership of the | ||
| event to this method; the event may be mutated, and may or may | ||
| not appear in the returned sequence. | ||
| experimental_filter_graph: When a graph event is encountered, process the | ||
| GraphDef to filter out attributes that are too large to be shown in the | ||
| graph UI. | ||
|
|
||
| Returns: | ||
| A sequence of `event_pb2.Event`s to use instead of `event`. | ||
| """ | ||
| if event.HasField("graph_def"): | ||
| return _migrate_graph_event(event) | ||
| return _migrate_graph_event( | ||
| event, experimental_filter_graph=experimental_filter_graph | ||
| ) | ||
| if event.HasField("summary"): | ||
| return _migrate_summary_event(event) | ||
| return (event,) | ||
|
|
||
|
|
||
| def _migrate_graph_event(old_event): | ||
| def _migrate_graph_event(old_event, experimental_filter_graph=False): | ||
| result = event_pb2.Event() | ||
| result.wall_time = old_event.wall_time | ||
| result.step = old_event.step | ||
| value = result.summary.value.add(tag=graphs_metadata.RUN_GRAPH_NAME) | ||
| graph_bytes = old_event.graph_def | ||
|
|
||
| # TODO(@davidsoergel): Move this stopgap to a more appropriate place. | ||
| if experimental_filter_graph: | ||
| graph_def = graph_pb2.GraphDef().FromString(graph_bytes) | ||
| # Use the default filter parameters: | ||
| # limit_attr_size=1024, large_attrs_key="_too_large_attrs" | ||
| process_graph.prepare_graph_for_ui(graph_def) | ||
| graph_bytes = graph_def.SerializeToString() | ||
|
|
||
| value.tensor.CopyFrom(tensor_util.make_tensor_proto([graph_bytes])) | ||
| value.metadata.plugin_data.plugin_name = graphs_metadata.PLUGIN_NAME | ||
| # `value.metadata.plugin_data.content` left as the empty proto | ||
|
|
||
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
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.
To make this TODO item clearer, I believe you can say in addition: "if it is already filtered, return immediately".
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.
Done.