-
Notifications
You must be signed in to change notification settings - Fork 5.7k
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
(refactor): pass fn as first argument to nested_map to follow convention and remove redundant logic from nested functions #23538
Conversation
If you are working on an open task, please edit the PR description to link to the issue you've created. For more information, please check ToDo List Issues Guide. Thank you 🤗 |
ivy/functional/ivy/gradients.py
Outdated
@@ -279,16 +277,16 @@ def _process_func_ret_and_grads(func_ret, grads, retain_grads): | |||
def _variable(x): | |||
x = ivy.to_native(x, nested=True) | |||
ret = ivy.nested_map( | |||
x, current_backend(x).variable, include_derived=True, shallow=False | |||
current_backend(x).variable, x, include_derived=True, shallow=False | |||
) | |||
return ivy.nested_map(ret, ivy.to_ivy, include_derived=True) |
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.
could you please change the function call here as well? Rest seems good to merge, thanks @mattbarrett98 😄
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! Feel free to merge, thanks @mattbarrett98 😄
(I went through most of the failing tests in the CI and they don't seem to be related to these changes)
…ion and remove redundant logic from nested functions (ivy-llc#23538)
…ion and remove redundant logic from nested functions (ivy-llc#23538)
Some cleaning up of nested functions, removed functionality relating to
max_depth
andextra_nest_types
which just seem to be there for the sake of it, and have no uses in any repos.Also changing the order of arguments in
nested_map
to pass the function to apply in first, which is consistent with python'smap
function, and basically any other equivalent function you can find (for example https://www.tensorflow.org/api_docs/python/tf/nest/map_structure , https://jax.readthedocs.io/en/latest/_autosummary/jax.tree_util.tree_map.html).Let me know your thoughts @vedpatwardhan