-
Notifications
You must be signed in to change notification settings - Fork 54
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
ht.array()
default to copy=None
(e.g., only if necessary)
#1119
Conversation
Codecov Report
@@ Coverage Diff @@
## main #1119 +/- ##
==========================================
- Coverage 91.85% 91.77% -0.09%
==========================================
Files 74 72 -2
Lines 10712 10505 -207
==========================================
- Hits 9840 9641 -199
+ Misses 872 864 -8
Flags with carried forward coverage won't be shown. Click here to find out more.
... and 6 files with indirect coverage changes 📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
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.
The changes look good to me!
The tests' failing has something to do with the numpy type system. After searching around, I found out that: > np.dtype("int64") == np.int64 # True
> np.dtype("int64") is np.int64 # False WorkaroundIt is to make use of the # Get around the numpy type system (np.dtype[<actual_type_we_want>])
if(hasattr(a_type, "type")):
a_type = a_type.type This solves the issue for me locally. PS: Are there any other objects that might also have a |
The base branch was changed.
Thank you for the PR! |
Thanks a lot for reviewing @Mystic-Slice , and for proposing a solution. I have modified |
ht.array
shall not copy by defaultht.array(copy)
default to None
(e.g., only if necessary) instead of True
@JuanPedroGHM is there a good way of checking for memory usage within the benchmarks? |
Thank you for the PR! |
Thank you for the PR! |
Thank you for the PR! |
Thank you for the PR! |
I think I'm done here @JuanPedroGHM, let me know if something's missing. |
Thank you for the PR! |
Thank you for the PR! |
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.
From my point of view the changes look fine. Therefore, I recommend merging if the CI runs through.
Description
This PR changes the default of the
ht.array(copy)
attribute to None. Previous default wascopy=True
. We introduce a deviation from the NumPy API to reduce the memory footprint of Heat operations. The changes comply with the Python array-API standard.Previous default behaviour when creating a DNDarray:
copy=True
ht.array
by default would make a copy of the underlying data object.copy=False
New default: following the Python array-API standard for
asarray
, the following options are now available for thecopy
attribute:- copy (Optional[bool]) – boolean indicating whether or not to copy the input. If
True
, the function must always copy. IfFalse
, the function must never copy for input which supports the buffer protocol and must raise aValueError
in case a copy would be necessary. IfNone
, the function must reuse existing memory buffer if possible and copy otherwise. Default: None.Issue/s resolved: #1117 #990
Changes proposed:
factories.array()
attributecopy
now defaults toNone
, i.e. existing memory buffer is reused if possible, copied otherwise.copy=False
raises aValueError
if a copy would be necessary. Note: this only holds for "input which supports buffer protocol", i.e. not for scalars.manipulations.diagonal()
modified to return a contiguous local arrayType of change
The underlying local data object of a DNDarray (
dndarray.larray
) might now be a view of a torch tensor. Copy might be necessary before communication.Memory requirements
In progress
Performance
In progress
Due Diligence
Does this change modify the behaviour of other functions? If so, which?
yes
The underlying local data object of a DNDarray (
dndarray.larray
) might now be a view of a torch tensor. Copy might be necessary before communication.