-
Notifications
You must be signed in to change notification settings - Fork 5.8k
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: remove infer_device and rename handle_device_shifting decorator #23373
refactor: remove infer_device and rename handle_device_shifting decorator #23373
Conversation
Thanks for contributing to Ivy! 😊👏 |
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 🤗 |
infer_device
and rename handle_device_shifting decorator
infer_device
and rename handle_device_shifting decoratorThere 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.
Looks good to me on a high level, but I'll leave this with @sherry30 to review as he's the author of the task. Thanks @ShreyanshBardia @sherry30 😄
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 Shreyansh,
can you run the following tests and make sure its working fine on your PR.
# testing device argument ##full_like ##arange
import ivy
# ivy.set_backend("paddle")
# ivy.set_backend("tensorflow")
# ivy.set_backend("jax")
ivy.set_backend("torch")
# ivy.set_backend("numpy")
ivy.set_soft_device_mode(False)
ivy.set_default_device("cpu")
x = ivy.array([1, 2, 3], device="cpu")
gpu_dev = "gpu:0"
# device is passed with arrays ## device
y = ivy.full_like(x, 3, device=gpu_dev)
print(y.device)
# device is passed without arrays ##device
y = ivy.arange(0, 10, device=gpu_dev)
print(y.device)
# device is not passed with arrays ##array dev
y = ivy.full_like(x, 3)
print(y.device)
# device is not passed without arryas ##default
y = ivy.arange(0, 10)
print(y.device)
# testing device argument ##full_like ##arange # soft_device mode True
import ivy
# ivy.set_backend("paddle")
# ivy.set_backend("tensorflow")
# ivy.set_backend("jax")
ivy.set_backend("torch")
# ivy.set_backend("numpy")
ivy.set_soft_device_mode(True)
ivy.set_default_device("gpu:0")
x = ivy.array([1, 2, 3], device="cpu")
cpu_dev = "cpu"
# device is passed with arrays ## device
y = ivy.full_like(x, 3, device=cpu_dev)
print(y.device)
# device is passed without arrays ##device
y = ivy.arange(0, 10, device=cpu_dev)
print(y.device)
# device is not passed with arrays ##default
y = ivy.full_like(x, 3)
print(y.device)
# device is not passed without arryas ##default
y = ivy.arange(0, 10)
print(y.device)
If it works fine on these then its good to merge
Another thing we have to make sure.
In all the backend functions, the device argument is not being used anywhere (for functions that accept a device argument).
torch is an exception of this.
Let me know if you have any questions
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
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.
PR Compliance Checks
Thank you for your Pull Request! We have run several checks on this pull request in order to make sure it's suitable for merging into this project. The results are listed in the following section.
Issue Reference
In order to be considered for merging, the pull request description must refer to a specific issue number. This is described in our contributing guide and our PR template.
This check is looking for a phrase similar to: "Fixes #XYZ" or "Resolves #XYZ" where XYZ is the issue number that this PR is meant to address.
This comment was marked as resolved.
This comment was marked as resolved.
I don't understand this statement of yours Do you mean we shouldn't be passing |
No what I meant was, the functions will still have the About the other problem, yea I guess we can give it a default value of |
I'm not completely sure if I understand this, but do you mean given that we've got the context manager working with the device shifting decorator we wouldn't need to pass the |
@vedpatwardhan Yep that's what I meant, the corner cases are in torch, but we can still pass in the default value of |
sounds good! As long as the op for functions using |
@sherry30 should I update default values to |
Yes, you can set them as |
@sherry30 can you take a look now |
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!
Lets get one final review from @vedpatwardhan before merging
Thanks
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.
I haven't one through the code line by line but seems good to merge, thanks @ShreyanshBardia @sherry30 😄
PR Description
Related Issue
Close task
Checklist
Socials: