tensor_to_ndarray

Function tensor_to_ndarray 

Source
pub fn tensor_to_ndarray<T: Scalar>(tensor: Tensor<T>) -> ArrayD<T>
Expand description

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

§Examples

use tenferro_device::LogicalMemorySpace;
use tenferro_ext_ndarray::tensor_to_ndarray;
use tenferro_tensor::{MemoryOrder, Tensor};

let tensor = Tensor::<f64>::zeros(&[2], LogicalMemorySpace::MainMemory, MemoryOrder::ColumnMajor).unwrap();
let array = tensor_to_ndarray(tensor);
assert_eq!(array.shape(), &[2]);