Struct collenchyma::tensor::SharedTensor [] [src]

pub struct SharedTensor<T> {
    // some fields omitted
}

Container that handles synchronization of Memory of type T.

Methods

impl<T> SharedTensor<T>

fn new<D: IntoTensorDesc>(dev: &DeviceType, desc: &D) -> Result<SharedTensor<T>, Error>

Create new Tensor by allocating Memory on a Device.

fn reshape<D: IntoTensorDesc>(&mut self, desc: &D) -> Result<(), Error>

Change the shape of the Tensor.

Will return an Error if size of new shape is not equal to the old shape. If you want to change the shape to one of a different size, use resize.

fn resize<D: IntoTensorDesc>(&mut self, desc: &D) -> Result<(), Error>

Change the size and shape of the Tensor.

Caution: Drops all copies which are not on the current device.

'reshape' is preffered over this method if the size of the old and new shape are identical because it will not reallocate memory.

fn sync(&mut self, destination: &DeviceType) -> Result<(), Error>

Synchronize memory from latest location to destination.

fn get(&self, device: &DeviceType) -> Option<&MemoryType>

Get a reference to the memory copy on the provided device.

Returns None if there is no memory copy on the device.

fn get_mut(&mut self, device: &DeviceType) -> Option<&mut MemoryType>

Get a mutable reference to the memory copy on the provided device.

Returns None if there is no memory copy on the device.

fn remove_copy(&mut self, destination: &DeviceType) -> Result<MemoryType, Error>

Removes Copy from SharedTensor and therefore aquires ownership over the removed memory copy for synchronizing.

fn add_device(&mut self, device: &DeviceType) -> Result<&mut Self, Error>

Track a new device and allocate memory on it.

Returns an error if the Tensor is already tracking the device.

fn latest_device(&self) -> &DeviceType

Returns the device that contains the up-to-date memory copy.

fn capacity(&self) -> usize

Returns the number of elements for which the Tensor has been allocated.

fn desc(&self) -> &TensorDesc

Returns the descriptor of the Tensor.

fn mem_size(capacity: usize) -> usize

Returns the allocated Memory size in bytes.

Trait Implementations

Derived Implementations

impl<T: Debug> Debug for SharedTensor<T>

fn fmt(&self, __arg_0: &mut Formatter) -> Result