-
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
feat: added Ivy.unflatten #28079
feat: added Ivy.unflatten #28079
Conversation
2942d7f
to
854f6be
Compare
34f312d
to
8272232
Compare
Hi @joaozenobio , would you mind taking a look if this is how it's meant to be set up? I also noticed that a similar function (take) has some extra arguments (mode, fill_value) to deal with some special cases of inputs and outputs. But it seems to come from one of the backends or at least from its implementation in ivy.take(), so it's probably not necessary currently in the unflatten() function? I've also noticed that If I understood the code correctly, ivy.Container has methods which automatically handle the structure of the container and map the function from ivy onto the leaves? |
Hey, @KareemMAX , it seems that I have some problems with making it work. Pytest throws errors both on the _static_unflatten and unflatten for containers. In the traceback, the error says that there is something wrong with shape kwarg (I think it was written that it was too long?)- I'm rerunning tests to give more detailed description of the issue. Edit: All errors got dealt with, the PR is ready for review & merge. |
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.
Hi @Kacper-W-Kozdon ! Thanks for your new PR! 🚀 The functions look great, I've noted down some of the corrections in the code that should be done. One thing you need to be sure of is if the dim argument is Optional or not. If one of the backends provides the an optional dim argument, all your functions should provide support for an optional dim too so we can establish the superset behavior. Please check this for each backend and pin me whenever you ready 😄
Ok, got it- I'll go through the code to ensure that dim is correctly defined. |
Only paddle and torch have natively implemented unflatten(), in neither of them dim is optional, so I fixed that. Shape is required as well. Since both are as positional/keyword and both are required, I removed default values from dim and shape. I did that for all the backgrounds covered by pytest. |
Hi @Kacper-W-Kozdon ! Perfect, all tests are passing and the code looks in good shape 😄 I'll merge your PR now. Thanks for the contribution and keep up with the hard work 🚀 |
PR Description
Adds support for unflatten to the methods of data classes (ivy.Container, ivy.Array).
Related Issue
Closes #28054
Checklist
Socials