[][src]Trait tension::Tensor

pub trait Tensor<T: Prm>: Sized {
    type Buffer: Buffer<T>;
    unsafe fn new_uninit_in(
        context: &<Self::Buffer as Buffer<T>>::Context,
        shape: &Shape
    ) -> Self;
fn new_filled_in(
        context: &<Self::Buffer as Buffer<T>>::Context,
        shape: &Shape,
        value: T
    ) -> Self;
fn new_zeroed_in(
        context: &<Self::Buffer as Buffer<T>>::Context,
        shape: &Shape
    ) -> Self;
fn shape(&self) -> &Shape;
fn reshape(&self, shape: &Shape) -> Self;
fn load(&self, dst: &mut [T]);
fn store(&mut self, src: &[T]); }

Tensor a.k.a. N-dimensional array.

Associated Types

type Buffer: Buffer<T>

Inner buffer type.

Loading content...

Required methods

unsafe fn new_uninit_in(
    context: &<Self::Buffer as Buffer<T>>::Context,
    shape: &Shape
) -> Self

Create unitialized tensor

fn new_filled_in(
    context: &<Self::Buffer as Buffer<T>>::Context,
    shape: &Shape,
    value: T
) -> Self

Create tensor filled with value on the specified hardware

fn new_zeroed_in(
    context: &<Self::Buffer as Buffer<T>>::Context,
    shape: &Shape
) -> Self

Create tensor filled with zeros on the specified hardware

fn shape(&self) -> &Shape

Shape of the tensor - a slice containing all tensor dimensions.

fn reshape(&self, shape: &Shape) -> Self

Returns a new tensor that shares the same data but has other shape. Failed if the product of all shape dimensions is not equal to buffer size.

fn load(&self, dst: &mut [T])

Load flattened data from tensor to slice.

fn store(&mut self, src: &[T])

Store data from slice to a tensor in a flattened manner.

Loading content...

Implementors

impl<T: Prm + Interop> Tensor<T> for DeviceTensor<T>[src]

type Buffer = DeviceBuffer<T>

impl<T: Prm> Tensor<T> for HostTensor<T>[src]

type Buffer = HostBuffer<T>

impl<T: Prm, Buf: Buffer<T>> Tensor<T> for CommonTensor<T, Buf>[src]

type Buffer = Buf

Loading content...