Skip to content
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

Support for dynamic number of dimensions #4

Closed
grothesque opened this issue Sep 17, 2024 · 3 comments
Closed

Support for dynamic number of dimensions #4

grothesque opened this issue Sep 17, 2024 · 3 comments

Comments

@grothesque
Copy link

I reference a discussion from rust-ndarray/ndarray#1272 (comment):

@fre-hu wrote:

I think the simplest way is to add dynamic rank as a new shape type and keep the existing layout types. The shape types for static rank are tuples of dimensions (each static or dynamic), and the new type will instead consist of a Box/Vec. The resulting layout mapping will then use Box/Vec for both shape and strides.

There can be limitations and for some operations like creating array views and permuting dimensions the rank must be static. But yes you can always convert to static rank for calculations.

Please correct me if I'm wrong, but with today's mdarray it is simply not possible to have arrays beyond a certain rank.

Of course there is no way around this with today's Rust given that macros need to be instantiated for each supported number of dimensions. And also the value of supporting static shapes beyond, say, 10 dimensions, seems marginal.

But for completeness and interfacing with other general array libraries, I think that supporting a fully generic layout would be very valuable.

@grothesque
Copy link
Author

I'm working on a new library for tensor network computations. See there for a design sketch. (Comments are most welcome!)

I think that mdarray could be ideal as the dense array backend for my library, but the one crucial missing feature is support for dynamic number of dimensions.

Would you be open to adding support for dynamic number of dimensions (following the idea you sketch out above) to mdarray?

@fre-hu
Copy link
Owner

fre-hu commented Oct 4, 2024

Yes, I have a prototype that just needs to be cleaned up.

fre-hu added a commit that referenced this issue Oct 12, 2024
@fre-hu
Copy link
Owner

fre-hu commented Oct 12, 2024

Please see the latest commit for dynamic rank support.

@fre-hu fre-hu closed this as completed Nov 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants