ndarray_to_tensor

Function ndarray_to_tensor 

Source
pub fn ndarray_to_tensor<T, S, D>(array: ArrayBase<S, D>) -> Tensor<T>
where T: Scalar + Clone, S: Data<Elem = T>, D: Dimension,
Expand description

Converts an owned ndarray array into a typed tenferro tensor, panicking on conversion failure.

§Examples

use ndarray::Array2;
use tenferro_ext_ndarray::ndarray_to_tensor;

let array = Array2::from_shape_vec((1, 2), vec![1.0_f64, 2.0]).unwrap();
let tensor = ndarray_to_tensor(array);
assert_eq!(tensor.dims(), &[1, 2]);