Struct CudaVec

Source
pub struct CudaVec<U, T>{ /* private fields */ }

Implementations§

Source§

impl<U, T> CudaVec<U, T>

Source

pub fn new( size: usize, memory_pool: &Arc<Mutex<MemoryPool>>, ) -> Result<CudaVec<U, T>, CudaError>

Create an instance of CudaVec

§Arguments
  • size- Number of value elements to be allocated
  • memory_pool - memory pool object
§Errors

This function may return the following errors

Source

pub fn with_initializer<I: FnMut() -> U>( size: usize, memory_pool: &Arc<Mutex<MemoryPool>>, initializer: I, ) -> Result<CudaVec<U, T>, CudaError>

Create an instance of CudaVec

§Arguments
  • size- Number of value elements to be allocated
  • memory_pool - memory pool object
  • initializer - Repeatedly called function to initialize each element
§Errors

This function may return the following errors

Trait Implementations§

Source§

impl<U, T> AsCudaMutPtr for CudaVec<U, T>

Source§

type Pointer = CudaMemoryPoolPtr<U>

Returned Cuda smart pointer type
Source§

fn as_cuda_mut_ptr<'a>(&'a mut self) -> CudaMutPtr<'a, Self::Pointer>

Source§

impl<U, T> AsCudaPtrRef for CudaVec<U, T>

Source§

type Pointer = CudaMemoryPoolPtr<U>

Returned Cuda smart pointer type
Source§

fn as_cuda_ptr_ref(&self) -> &Self::Pointer

Source§

impl<'a, U, const N: usize> BatchActivation<U, CudaVecView<'a, U, CudaTensor1dPtr<U, N>>, CudaVec<U, CudaTensor1dPtr<U, N>>, DeviceGpu<U>> for Identity<U, DeviceGpu<U>>
where U: UnitValue<U>, DeviceGpu<U>: Device<U>,

Source§

fn batch_apply( &self, _: &DeviceGpu<U>, input: &CudaVecView<'a, U, CudaTensor1dPtr<U, N>>, ) -> Result<CudaVec<U, CudaTensor1dPtr<U, N>>, TrainingError>

Apply the activation function Read more
Source§

fn batch_derive( &self, _: &DeviceGpu<U>, _: &CudaVecView<'a, U, CudaTensor1dPtr<U, N>>, loss: &CudaVecView<'a, U, CudaTensor1dPtr<U, N>>, _: &CudaVecView<'a, U, CudaTensor1dPtr<U, N>>, ) -> Result<CudaVec<U, CudaTensor1dPtr<U, N>>, TrainingError>

Apply derivatives of the activation function Read more
Source§

impl<'a, U, const N: usize> BatchActivation<U, CudaVecView<'a, U, CudaTensor1dPtr<U, N>>, CudaVec<U, CudaTensor1dPtr<U, N>>, DeviceGpu<U>> for ReLu<U, DeviceGpu<U>>
where U: UnitValue<U> + DataTypeInfo, DeviceGpu<U>: Device<U>, for<'b> ReLuBatchForward<'b, U, N>: Kernel<Args = ActivationBatchForwardArgs<'b, U, N>>, for<'b> ReLuBatchBackward<'b, U, N>: Kernel<Args = ActivationBatchBackwardArgs<'b, U, N>>,

Source§

fn batch_apply( &self, device: &DeviceGpu<U>, input: &CudaVecView<'a, U, CudaTensor1dPtr<U, N>>, ) -> Result<CudaVec<U, CudaTensor1dPtr<U, N>>, TrainingError>

Apply the activation function Read more
Source§

fn batch_derive( &self, device: &DeviceGpu<U>, o: &CudaVecView<'a, U, CudaTensor1dPtr<U, N>>, loss: &CudaVecView<'a, U, CudaTensor1dPtr<U, N>>, u: &CudaVecView<'a, U, CudaTensor1dPtr<U, N>>, ) -> Result<CudaVec<U, CudaTensor1dPtr<U, N>>, TrainingError>

Apply derivatives of the activation function Read more
Source§

impl<'a, U, const N: usize> BatchActivation<U, CudaVecView<'a, U, CudaTensor1dPtr<U, N>>, CudaVec<U, CudaTensor1dPtr<U, N>>, DeviceGpu<U>> for Sigmoid<U, DeviceGpu<U>>
where U: UnitValue<U> + DataTypeInfo, DeviceGpu<U>: Device<U>, for<'b> SigmoidBatchForward<'b, U, N>: Kernel<Args = ActivationBatchForwardArgs<'b, U, N>>, for<'b> SigmoidBatchBackward<'b, U, N>: Kernel<Args = ActivationBatchBackwardArgs<'b, U, N>>,

Source§

fn batch_apply( &self, device: &DeviceGpu<U>, input: &CudaVecView<'a, U, CudaTensor1dPtr<U, N>>, ) -> Result<CudaVec<U, CudaTensor1dPtr<U, N>>, TrainingError>

Apply the activation function Read more
Source§

fn batch_derive( &self, device: &DeviceGpu<U>, o: &CudaVecView<'a, U, CudaTensor1dPtr<U, N>>, loss: &CudaVecView<'a, U, CudaTensor1dPtr<U, N>>, u: &CudaVecView<'a, U, CudaTensor1dPtr<U, N>>, ) -> Result<CudaVec<U, CudaTensor1dPtr<U, N>>, TrainingError>

Apply derivatives of the activation function Read more
Source§

impl<'a, U, const N: usize> BatchActivation<U, CudaVecView<'a, U, CudaTensor1dPtr<U, N>>, CudaVec<U, CudaTensor1dPtr<U, N>>, DeviceGpu<U>> for SoftMax<U, DeviceGpu<U>>
where U: UnitValue<U> + DataTypeInfo, DeviceGpu<U>: Device<U>, for<'b> SoftMaxBatchForward<'b, U, N>: Kernel<Args = ActivationBatchForwardArgs<'b, U, N>>, for<'b> SoftMaxBatchBackward<'b, U, N>: Kernel<Args = ActivationBatchBackwardArgs<'b, U, N>>,

Source§

fn batch_apply( &self, device: &DeviceGpu<U>, input: &CudaVecView<'a, U, CudaTensor1dPtr<U, N>>, ) -> Result<CudaVec<U, CudaTensor1dPtr<U, N>>, TrainingError>

Apply the activation function Read more
Source§

fn batch_derive( &self, device: &DeviceGpu<U>, o: &CudaVecView<'a, U, CudaTensor1dPtr<U, N>>, loss: &CudaVecView<'a, U, CudaTensor1dPtr<U, N>>, u: &CudaVecView<'a, U, CudaTensor1dPtr<U, N>>, ) -> Result<CudaVec<U, CudaTensor1dPtr<U, N>>, TrainingError>

Apply derivatives of the activation function Read more
Source§

impl<'a, U, const N: usize> BatchActivation<U, CudaVecView<'a, U, CudaTensor1dPtr<U, N>>, CudaVec<U, CudaTensor1dPtr<U, N>>, DeviceGpu<U>> for Swish<U, DeviceGpu<U>>
where U: UnitValue<U> + DataTypeInfo, DeviceGpu<U>: Device<U>, for<'b> SwishBatchForward<'b, U, N>: Kernel<Args = ActivationBatchForwardArgs<'b, U, N>>, for<'b> SwishBatchBackward<'b, U, N>: Kernel<Args = ActivationBatchBackwardArgs<'b, U, N>>,

Source§

fn batch_apply( &self, device: &DeviceGpu<U>, input: &CudaVecView<'a, U, CudaTensor1dPtr<U, N>>, ) -> Result<CudaVec<U, CudaTensor1dPtr<U, N>>, TrainingError>

Apply the activation function Read more
Source§

fn batch_derive( &self, device: &DeviceGpu<U>, o: &CudaVecView<'a, U, CudaTensor1dPtr<U, N>>, loss: &CudaVecView<'a, U, CudaTensor1dPtr<U, N>>, u: &CudaVecView<'a, U, CudaTensor1dPtr<U, N>>, ) -> Result<CudaVec<U, CudaTensor1dPtr<U, N>>, TrainingError>

Apply derivatives of the activation function Read more
Source§

impl<'a, U, const N: usize> BatchActivation<U, CudaVecView<'a, U, CudaTensor1dPtr<U, N>>, CudaVec<U, CudaTensor1dPtr<U, N>>, DeviceGpu<U>> for Tanh<U, DeviceGpu<U>>
where U: UnitValue<U> + DataTypeInfo, DeviceGpu<U>: Device<U>, for<'b> TanhBatchForward<'b, U, N>: Kernel<Args = ActivationBatchForwardArgs<'b, U, N>>, for<'b> TanhBatchBackward<'b, U, N>: Kernel<Args = ActivationBatchBackwardArgs<'b, U, N>>,

Source§

fn batch_apply( &self, device: &DeviceGpu<U>, input: &CudaVecView<'a, U, CudaTensor1dPtr<U, N>>, ) -> Result<CudaVec<U, CudaTensor1dPtr<U, N>>, TrainingError>

Apply the activation function Read more
Source§

fn batch_derive( &self, device: &DeviceGpu<U>, o: &CudaVecView<'a, U, CudaTensor1dPtr<U, N>>, loss: &CudaVecView<'a, U, CudaTensor1dPtr<U, N>>, u: &CudaVecView<'a, U, CudaTensor1dPtr<U, N>>, ) -> Result<CudaVec<U, CudaTensor1dPtr<U, N>>, TrainingError>

Apply derivatives of the activation function Read more
Source§

impl<U, T> BatchSize for CudaVec<U, T>

Source§

fn size(&self) -> usize

Source§

impl<U, T> Debug for CudaVec<U, T>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<U, T> IntoConverter for CudaVec<U, T>

Source§

type Converter = CudaVecConverter<U, T>

Converter type to go through when converting to the type being converted
Source§

fn into_converter(self) -> Self::Converter

Source§

impl<U, T> PointerElement for CudaVec<U, T>

Source§

impl<'a, U, T> ToCuda<U> for &'a CudaVec<U, T>

Source§

type Output = CudaVecView<'a, U, T>

Source§

fn to_cuda(self, _: &DeviceGpu<U>) -> Result<Self::Output, TypeConvertError>

Arguments Read more
Source§

impl<U, T> ToCuda<U> for CudaVec<U, T>

Source§

type Output = CudaVec<U, T>

Source§

fn to_cuda(self, _: &DeviceGpu<U>) -> Result<Self::Output, TypeConvertError>

Arguments Read more
Source§

impl<U, T> ToHost<U> for CudaVec<U, T>
where U: Debug + Default + Clone + Copy + Send + UnitValue<U>, SerializedVec<U, <T as ToHost<U>>::Output>: TryFrom<Box<[U]>, Error = TypeConvertError>, for<'a> <T as ToHost<U>>::Output: SliceSize + MakeView<'a, U>, for<'a> T: MemorySize + AsKernelPtr + AsConstKernelPtr + ToHost<U>,

Source§

impl<U, T> TryClone for CudaVec<U, T>

Source§

impl<'a, U, T, R> TryFrom<&'a CudaVec<U, T>> for CudaVecView<'a, U, R>

Source§

type Error = TypeConvertError

The type returned in the event of a conversion error.
Source§

fn try_from(value: &'a CudaVec<U, T>) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl<'a, U, T> TryFrom<&'a CudaVecView<'a, U, T>> for CudaVec<U, T>

Source§

type Error = CudaError

The type returned in the event of a conversion error.
Source§

fn try_from(value: &'a CudaVecView<'a, U, T>) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl<U, T, R> TryFrom<CudaVecConverter<U, T>> for CudaVec<U, R>

Source§

type Error = TypeConvertError

The type returned in the event of a conversion error.
Source§

fn try_from(value: CudaVecConverter<U, T>) -> Result<Self, Self::Error>

Performs the conversion.

Auto Trait Implementations§

§

impl<U, T> Freeze for CudaVec<U, T>

§

impl<U, T> RefUnwindSafe for CudaVec<U, T>

§

impl<U, T> !Send for CudaVec<U, T>

§

impl<U, T> !Sync for CudaVec<U, T>

§

impl<U, T> Unpin for CudaVec<U, T>
where T: Unpin,

§

impl<U, T> UnwindSafe for CudaVec<U, T>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> AsConstKernelPtr for T
where T: AsConstKernelPtrBase,

Source§

impl<T> AsKernelPtr for T
where T: AsKernelPtrBase,

Source§

impl<T> AsMutKernelPtr for T
where T: AsMutKernelPtrBase,