-
Notifications
You must be signed in to change notification settings - Fork 757
Allow substring matching in nnx.PathContains
#5094
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
base: main
Are you sure you want to change the base?
Conversation
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
vfdev-5
left a comment
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.
Thanks for the PR @thijs-vanweezel !
Can you please add a test for the exact=False case?
|
Check out this pull request on See visual diffs & provide feedback on Jupyter Notebooks. Powered by ReviewNB |
|
@vfdev-5 good suggestion. It has been added now. |
|
Please rebase your PR on the latest |
9cfc17b to
124ddec
Compare
|
The failure of the CI is related to the broken |
124ddec to
12b2e42
Compare
vfdev-5
left a comment
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.
LGTM, thanks @thijs-vanweezel !
What does this PR do?
As per issue #5075, this PR slightly modifies nnx.PathContains to allow for substring matching. This is important in order to match all layers which have been given a similar name (e.g., "conv1", "conv2", etc.). As suggested, the modification implements an
exactparameter, which, if set toFalse, ensures thatkeyis matched against each element ofpath. Note; since aKeyinstance is not guaranteed to implement.__contains__, thePathPartsare first converted to string.P.S.: Although the tests were eventually passed, it appeared that JAX had to be built from source to satisfy recently added imports (an instruction perhaps worth adding to this guide), and that pre-existing typing errors in mypy required setting RUN_MYPY=false.
Fixes #5075
Example
Checklist