You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
An important part of the logic for map/broadcast is first determining if the function preserves zero values (or more generally, stored values, though for now we are focusing on the case where unstored values are zero). If it doesn't, all elements of the destination need to be instantiated, while if it does, we only need to loop over the values that are stored in the arrays being mapped/broadcasted.
functionpreserves_unstored(f, a_dest::AbstractArray, as::AbstractArray...)
I =first(eachindex(as...))
returniszero(f(map(a ->getunstoredindex(a, I), as)...))
end
which has the disadvantage that calling getunstoredindex could be expensive, say if the sparse array is an array of large arrays it could allocate a large array, and additionally checking if it is zero could be expensive as well. It would be good to try to come up with a better system for that.
The text was updated successfully, but these errors were encountered:
mtfishman
changed the title
[ENHANCEMENT] Improve logic for checking of map/broadcast calls preserve zeros
[ENHANCEMENT] Improve logic for checking if map/broadcast calls preserve zeros
Feb 6, 2025
An important part of the logic for map/broadcast is first determining if the function preserves zero values (or more generally, stored values, though for now we are focusing on the case where unstored values are zero). If it doesn't, all elements of the destination need to be instantiated, while if it does, we only need to loop over the values that are stored in the arrays being mapped/broadcasted.
The logic as of #21 is based on a function:
which has the disadvantage that calling
getunstoredindex
could be expensive, say if the sparse array is an array of large arrays it could allocate a large array, and additionally checking if it is zero could be expensive as well. It would be good to try to come up with a better system for that.The text was updated successfully, but these errors were encountered: