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

(refactor): pass fn as first argument to nested_map to follow convention and remove redundant logic from nested functions #23538

Merged
merged 3 commits into from
Sep 15, 2023

Conversation

mattbarrett98
Copy link
Contributor

@mattbarrett98 mattbarrett98 commented Sep 13, 2023

Some cleaning up of nested functions, removed functionality relating to max_depth and extra_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's map 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

@ivy-leaves ivy-leaves added Array API Conform to the Array API Standard, created by The Consortium for Python Data API Standards PaddlePaddle Backend Developing the Paddle Paddle Backend. JAX Frontend Developing the JAX Frontend, checklist triggered by commenting add_frontend_checklist NumPy Frontend Developing the NumPy Frontend, checklist triggered by commenting add_frontend_checklist Paddle Frontend Developing the Paddle Frontend, checklist triggered by commenting add_frontend_checklist TensorFlow Frontend Developing the TensorFlow Frontend, checklist triggered by commenting add_frontend_checklist PyTorch Frontend Developing the PyTorch Frontend, checklist triggered by commenting add_frontend_checklist Ivy Functional API labels Sep 13, 2023
@ivy-leaves
Copy link

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 🤗

@@ -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)
Copy link
Contributor

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 😄

@mattbarrett98 mattbarrett98 changed the title clean up nested_map (refactor): clean up nested_map Sep 14, 2023
@mattbarrett98 mattbarrett98 changed the title (refactor): clean up nested_map (refactor): pass fn as first argument to nested_map to follow convention and remove redundant logic from nested functions Sep 14, 2023
@a0m0rajab a0m0rajab modified the milestone: #10388 Sep 14, 2023
Copy link
Contributor

@vedpatwardhan vedpatwardhan left a 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)

@mattbarrett98 mattbarrett98 merged commit ef493e4 into ivy-llc:main Sep 15, 2023
13 of 271 checks passed
@mattbarrett98 mattbarrett98 deleted the nest branch September 15, 2023 08:30
iababio pushed a commit to iababio/ivy that referenced this pull request Sep 27, 2023
…ion and remove redundant logic from nested functions (ivy-llc#23538)
druvdub pushed a commit to druvdub/ivy that referenced this pull request Oct 14, 2023
…ion and remove redundant logic from nested functions (ivy-llc#23538)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Array API Conform to the Array API Standard, created by The Consortium for Python Data API Standards Ivy Functional API JAX Frontend Developing the JAX Frontend, checklist triggered by commenting add_frontend_checklist NumPy Frontend Developing the NumPy Frontend, checklist triggered by commenting add_frontend_checklist Paddle Frontend Developing the Paddle Frontend, checklist triggered by commenting add_frontend_checklist PaddlePaddle Backend Developing the Paddle Paddle Backend. PyTorch Frontend Developing the PyTorch Frontend, checklist triggered by commenting add_frontend_checklist TensorFlow Frontend Developing the TensorFlow Frontend, checklist triggered by commenting add_frontend_checklist
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants