rust-ndarray / ndarray

ndarray: an N-dimensional array with array views, multidimensional slicing, and efficient operations
https://docs.rs/ndarray/
Apache License 2.0
3.6k stars 306 forks source link

Support for no alloc #1049

Open vadixidav opened 3 years ago

vadixidav commented 3 years ago

This may seem like a strange ask, but in the computer vision community we are currently working on trying to develop an abstraction over various color models for images. A very effective way to work with images is to create ArrayView2 for each layer/channel of the image, especially for images which have interpolated components (like YUV420). At least one person (@astraw) in the Rust CV org is working with microcontrollers where alloc is not currently available. Since we are only interested in ArrayView2 specifically, we theoretically should be able to use that without alloc, but currently ndarray unconditionally brings in the alloc crate.

So, the ask is this: if I put in the work and set up a PR, can we add a new alloc feature, where without that feature extern crate alloc; is gated out, and all of the types which require alloc (like Array2) are no longer included? Thanks!

vhakulinen commented 2 years ago

I'm facing similar problem. Did you ever make progress with some no alloc feature gate?

vadixidav commented 2 years ago

No, I was hoping to get a response here first from a maintainer before proceeding with work on this.

vhakulinen commented 2 years ago

I'm doing some research on the topic, and fwiw, nalgebra seems to have support for statically sized arrays (based on documentation at least).

astraw commented 2 years ago

Yes, nalgebra is fine for this. The cam-geom crate, for example uses nalgebra and compiles e.g. on the target thumbv7em-none-eabihf which has no alloc available. This is run git the github CI actions if you want to have a look or of course you can download it yourself.

sainteckes commented 1 year ago

Any news on this? :)