Skip to content
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

[nnx] add some optimizations to graph.py #4377

Merged
merged 2 commits into from
Nov 16, 2024

Conversation

cgarciae
Copy link
Collaborator

What does this PR do?

  • Adds a PYTREE_REGISTRY contianing specialized implementations of PytreeNodeImpl for common pytrees like list, tuple, dict, and None.
  • Some other minor optimizations.

Base automatically changed from nnx-benchmark to main November 13, 2024 02:29
@cgarciae cgarciae force-pushed the nnx-pytree-optimization branch 4 times, most recently from 22458b5 to 6ab7800 Compare November 15, 2024 00:24
elif isinstance(x, (VariableState, State)):
return True
else:
return not jax.tree_util.all_leaves((x,))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can use tree_util.tree_leaves

@copybara-service copybara-service bot merged commit 6382a2b into main Nov 16, 2024
19 checks passed
@copybara-service copybara-service bot deleted the nnx-pytree-optimization branch November 16, 2024 01:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants