ITensor / ITensor/SparseArraysBase.jl
[ENHANCEMENT] Improve logic for checking if map/broadcast calls preserve zeros
Nobody has claimed this yet.
- Dominant language
- Julia
- Stars
- 1
- Forks
- 1
- Avg merge
- 21m
- Merged PRs (30d)
- 1
Description
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:
function preserves_unstored(f, a_dest::AbstractArray, as::AbstractArray...)
I = first(eachindex(as...))
return iszero(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.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reviewing the current preserves_unstored function and the map/broadcast logic introduced in #21, including getunstoredindex. Investigate how preservation of unstored zeros can be determined without constructing or checking potentially expensive values; done should avoid unnecessary destination instantiation while preserving correct map/broadcast behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- julia
- Domain
- data, performance
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100