try_tensor_to_mdarray

Function try_tensor_to_mdarray 

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

Fallibly converts a tenferro Tensor<T> into an mdarray Array<T, DynRank>.

This conversion copies all element data from the tenferro tensor into a newly allocated mdarray array. The shape is preserved.

§Examples

use mdarray::{Array, DynRank};
use tenferro_tensor::Tensor;
use tenferro_ext_mdarray::try_tensor_to_mdarray;

use tenferro_device::LogicalMemorySpace;
use tenferro_tensor::MemoryOrder;

let t: Tensor<f64> = Tensor::zeros(
    &[3, 4],
    LogicalMemorySpace::MainMemory,
    MemoryOrder::ColumnMajor,
);
let md: Array<f64, DynRank> = try_tensor_to_mdarray(t).unwrap();