You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Following #89, implement support for ND arrays in ILP.
Guidelines
Rust API
We should introduce a new trait for what constitutes an ND array.
Via feature flags, we should introduce optional support the ndarray crate.
Something like this:
use ndarray::array;let arr = array![[1,2,3],[4,5,6]];
buf.column_arr(arr)?;
pubtraitNdArrayView<T>whereT:ArrayElement,{/// Return the rank of the arrayfnndim(&self) -> usize;/// Return the size of the `index` dimensionfndim(&self,index:usize) -> Option<usize>;/// Write the array data in row-major order to the provided buffer./// The provided `buffer` will be pre-sized to the exact size as computed/// from the shape and element size./// You may _not_ assume that the buffer's start is aligned to `T`.fnwrite_row_major_buf(&self,buff:&mut[u8]);}pubtraitArrayElement:Copy + 'static{}implArrayElementfori32{}implArrayElementfori64{}implArrayElementforf32{}implArrayElementforf64{}pubfncolumn_arr<T,A>(arr:&A) -> Result<...>
whereT:ArrayElement,A:NdArrayView<T>,{
...}
Then the impl:
#[cfg(feature = "ndarray")]impl<T>NdArrayView<T>for ndarray::ArrayView<'_,T,'_>whereT:ArrayElement,{fnndim(&self) -> usize{self.ndim()}fndim(&self,index:usize) -> Option<usize>{self.shape().get(index)}fnwrite_row_major_buf(&self,buf:&mut[u8]){// figure out if already in standard layout row major:// -> do a byte copy// if strided:// -> iterate in row major order, copy value by value}}
C and C++ APIs:
The other API will need an exploded set of APIs for different types.
Each type (integer double etc) will take a buffer for the strides and a buffer for the data.
E.g.:
In C++ we can use some template specialisation to go back to an API more similar to Rust's.
We should also use std::byte instead of uint8_t to refer to the buffer.
The text was updated successfully, but these errors were encountered:
Following #89, implement support for ND arrays in ILP.
Guidelines
Rust API
ndarray
crate.Something like this:
Then the impl:
C and C++ APIs:
The other API will need an exploded set of APIs for different types.
Each type (integer double etc) will take a buffer for the strides and a buffer for the data.
E.g.:
In C++ we can use some template specialisation to go back to an API more similar to Rust's.
We should also use
std::byte
instead ofuint8_t
to refer to the buffer.The text was updated successfully, but these errors were encountered: