tensor_to_mdarray

Function tensor_to_mdarray 

Source
pub fn tensor_to_mdarray<T: Scalar>(tensor: Tensor<T>) -> Array<T, DynRank>
Expand description

Converts a tenferro Tensor<T> into an mdarray Array<T, DynRank>, panicking if conversion fails.

§Examples

use tenferro_device::LogicalMemorySpace;
use tenferro_ext_mdarray::tensor_to_mdarray;
use tenferro_tensor::{MemoryOrder, Tensor};

let t: Tensor<f64> = Tensor::zeros(
    &[3, 4],
    LogicalMemorySpace::MainMemory,
    MemoryOrder::ColumnMajor,
);
let md = tensor_to_mdarray(t);
assert_eq!(md.shape().ndim(), 2);