pub fn try_tensor_to_ndarray<T: Scalar>(tensor: Tensor<T>) -> Result<ArrayD<T>>Expand description
Fallibly converts a typed tenferro tensor into an owned ndarray array.
The canonical bridge always materializes a standard row-major owned ndarray result. This keeps row-major downstream integrations simple while tenferro continues to use column-major canonical tensors internally.
§Examples
ⓘ
use tenferro_device::LogicalMemorySpace;
use tenferro_ext_ndarray::try_tensor_to_ndarray;
use tenferro_tensor::{MemoryOrder, Tensor};
let tensor = Tensor::<f64>::zeros(&[2, 2], LogicalMemorySpace::MainMemory, MemoryOrder::RowMajor).unwrap();
let array = try_tensor_to_ndarray(tensor).unwrap();
assert_eq!(array.shape(), &[2, 2]);