Replies: 3 comments 5 replies
-
|
For the dependencies:
|
Beta Was this translation helpful? Give feedback.
-
|
Building on the bullet point above about the minimal interface, here is a new interface proposal:
I'm not certain that covers everything we need so we'll have to try it out and see. Note that the names are meant to stick as close as possible to the corresponding Footnotes
|
Beta Was this translation helpful? Give feedback.
-
|
I forgot about this discussion, this is pretty outdated and I think mostly implemented so I'll close it, we can open a new discussion if needed. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
To-do list for splitting off
NDTensors.SparseArraysBaseas a separate registered packageSparseArraysBase.jl:AnyAbstractSparseArraytype union in favor of an@derivemacro, similar toMoshi.@derive, the Rust derive attribute for implementing traits, andArrayLayouts.@layoutmatrixand related macros inArrayLayouts.jl. This would basically automatically definegetindex,map!, etc. assparse_getindex,sparse_map!, etc. on a specified type or wrapper.NDTensors.jlthatSparseArraysBasedepends on, and either remove those dependencies or assess what we need to do to split off those libraries into packages as well, or maybe merge them intoSparseArraysBase. For example, right now it relies on:BroadcastMapConversion, which converts broadcast calls to map calls (which is heavily inspired by the broadcasting code logic inStrided.jl). That library is also used in other sub-modules ofNDTensors.jl, such asBlockSparseArraysandNamedDimsArrays.TypeParameterAccessorsfor generically accessing type parameters, in particular it uses functionality for generically getting the type of the parent of a wrapper type. We've been planning to split that off for a while, though I think there are still some type instability issues and interface questions to decide on so I'm not sure how comfortable I am doing that right now.NestedPermutedDimsArrays. This dependency could get turned into a package extension with the sparse array interface getting overloaded with@derive.ait could beFillArrays.Zeros(eltype(a), size(a))(based onFillArrays.Zeros), but for a block sparse array it could beMappedArrays.mappedarray(I -> zeros(eltype(a), blocksizes(a)[I]), CartesianIndices(blocksize(a)))(based onMappedArrays.MappedArray).storage_index_to_index,index_to_storage_index,stored_indices, etc. (both the names and functionality). For example, what should be assumed aboutstored_indices? Should it list the indices in the same order that the corresponding values are stored in thesparse_storage? Should they be expected to have fast (in the DOK case,O(1)) lookup of indices?SparseArraysBasecorresponds to the current or planned functions in theSparseArrays.jlstandard library, such asnnz,nonzerovals(proposed to be changed tostoredvals),nonzeroinds(proposed to be changed tostoredinds),isstored, etc.@avoid_allocthat changes the behavior ofa[B]for block sparse arrayaso that if the blockBdoesn't exist in the storage, it returns an unallocatedFillArrays.ZerosorUnallocatedArrays.UnallocatedZerosobject of the correct size. This can help with optimizing map operations, for example expressions likea[B] += xright now have an unnecessary intermediate allocation, since for the defaulta::BlockSparseArray(with the default zero constructor),a[B]allocates an array filled with zeros.@avoid_alloc a[B] += xcould rewrite that expression as@avoid_alloc BlockSparseArray(blocks(a), z)[B] += xwherez = mappedarray(I -> Zeros(eltype(a), blocksizes(a)[I]), CartesianIndices(blocksize(a))), i.e. an array defining the zero elements such that the zero elements of each index are a lazy zero array.VectorInterface.jl,Zeros.jl,StaticNumbers.jl,Static.jl, etc. Alternatively, if the elements are arrays, we could useFillArrays.Zeros. However, these approaches have failure modes, for example if the function being passed isn't generic enough to accept those types, or we can't determine which types or array sizes to use based on the input array.Beta Was this translation helpful? Give feedback.
All reactions