pub fn try_ndarray_to_tensor<T, S, D>(
array: ArrayBase<S, D>,
) -> Result<Tensor<T>>Expand description
Fallibly converts an ndarray array into a typed tenferro tensor.
This is the canonical interop entry point. The bridge first materializes a standard row-major ndarray layout, then normalizes it into tenferro’s internal column-major tensor layout.
§Examples
ⓘ
use ndarray::Array2;
use tenferro_ext_ndarray::try_ndarray_to_tensor;
let array = Array2::from_shape_vec((1, 2), vec![1.0_f64, 2.0]).unwrap();
let tensor = try_ndarray_to_tensor(array).unwrap();
assert_eq!(tensor.dims(), &[1, 2]);