-
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
test(backend handler): added tests for inplace update warnings. #26067
Conversation
…ing-fix # Conflicts: # ivy/utils/exceptions.py
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.
@vedpatwardhan I noticed you have provided a solution before I had a chance create a PR. ivy.set_tensorflow_backend()
UserWarning: The current backend: 'tensorflow' does not support inplace updates natively. Ivy would quietly create new arrays when using inplace updates with this backend, leading to memory overhead (same applies for views). If you want to control your memory management, consider doing ivy.set_inplace_mode('strict') which should raise an error whenever an inplace update is attempted with this backend.
warnings.warn(
ivy.set_tensorflow_backend() so the second time we call |
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.
@vedpatwardhan I noticed you have provided a solution before I had a chance create a PR. at least we can add the tests I added, also using the
_inplace_update_cache
will make the warning of a given backend appear only once even when setting the backend for a second time:ivy.set_tensorflow_backend() UserWarning: The current backend: 'tensorflow' does not support inplace updates natively. Ivy would quietly create new arrays when using inplace updates with this backend, leading to memory overhead (same applies for views). If you want to control your memory management, consider doing ivy.set_inplace_mode('strict') which should raise an error whenever an inplace update is attempted with this backend. warnings.warn( ivy.set_tensorflow_backend()so the second time we call
ivy.set_tensorflow_backend()
no warning is raised. Do we want this behavior ?
Yep exactly, given that the user has already seen the warning once, throwing the warning a second time could be annoying. Could you please revert the changes except for the tests? Thanks @Madjid-CH 😄
sure |
… the warning only once.
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 @Madjid-CH 😄
(Given that the tests aren't running in the CI due to a docker issue, I'd suggest running these tests and ensuring that they're passing before you merge)
you don't have to ask 🙌 |
PR Description
when we introduced a warning when a backend does not support inplace update in
previous_backend
function here that made the warning being throwed multiple times when setting a backend because we are iterating thebackend_stack
and callingprevious_backend
here so I added a flag to avoid this behavior.