-
Notifications
You must be signed in to change notification settings - Fork 5
Description
As mentioned in #11, this is a proposed reorganization to merge the Array and Tensor types.
Currently the Array and Tensor types are both owned arrays with inline or dynamic allocation. With the change there is a single Array type, where the allocation depends on the shape type. Inline allocation is used for static rank and if all dimensions have constant size.
The purpose is to simplify the API and improve writing generic code. For example now when evaluating expressions with generic shape, the result is an implementation of the Owned trait which has limited functionality. With the change, the result is an Array type and Owned is no longer needed. It is possible to create new arrays with generic shape, for example with Array::uninit().
The internal implementation consists of a buffer type, which is either StaticBuffer or DynBuffer. Some methods on Array only works on a certain buffer type, for example the ones related to dynamic allocation. Conversions between shape and buffer types can be done with into_shape(), into_buffer() and into_dyn().
Macro names are changed to match the new array types, with array!/darray! for arrays with constant/dynamic size and similarly for view!/dview!.
The change is rather large (see the branch merge-array), but hopefully the interface changes have limited impact. The existing tensor types and macros are kept for now. The mdarray-linalg and sparse-ir-rs crates build without errors, and matamorph needs an update to handle inline allocation.
Please comment if this makes sense or if you see any issues!
cc @grothesque, @pwulles, @shinaoka