Struct custos_math::custos::CUDA

source ·
pub struct CUDA {
    pub cache: RefCell<Cache<CUDA>>,
    pub kernel_cache: RefCell<KernelCacheCU>,
    pub modules: RefCell<Vec<Module, Global>>,
    pub graph: RefCell<Graph>,
    /* private fields */
}
Expand description

Used to perform calculations with a CUDA capable device. To make new calculations invocable, a trait providing new operations should be implemented for [CudaDevice].

Fields§

§cache: RefCell<Cache<CUDA>>§kernel_cache: RefCell<KernelCacheCU>§modules: RefCell<Vec<Module, Global>>§graph: RefCell<Graph>

Implementations§

source§

impl CUDA

source

pub fn new( idx: usize ) -> Result<CUDA, Box<dyn Error + Sync + Send + 'static, Global>>

source

pub fn device(&self) -> &CudaIntDevice

source

pub fn ctx(&self) -> &Context

source

pub fn handle(&self) -> &CublasHandle

source

pub fn stream(&self) -> &Stream

Trait Implementations§

source§

impl<T: CDatatype> ActivationOps<T, (), CUDA> for CUDA

source§

fn sigmoid(&self, x: &Matrix<'_, T, Self>) -> Matrix<'_, T, Self>

source§

fn sigmoid_grad(&self, x: &Matrix<'_, T, Self>) -> Matrix<'_, T, Self>

source§

fn tanh(&self, x: &Matrix<'_, T, Self>) -> Matrix<'_, T, Self>

source§

fn tanh_grad(&self, x: &Matrix<'_, T, Self>) -> Matrix<'_, T, Self>

source§

fn relu(&self, x: &Matrix<'_, T, Self>) -> Matrix<'_, T, Self>

source§

fn relu_grad(&self, x: &Matrix<'_, T, Self>) -> Matrix<'_, T, Self>

source§

fn relu_mut(&self, x: &mut Matrix<'_, T, Self, ()>)

inplace
source§

fn relu_grad_mut(&self, x: &mut Matrix<'_, T, Self, ()>)

inplace
source§

impl<T: CDatatype> AdditionalOps<T, (), CUDA> for CUDA

source§

fn adds(&self, lhs: &Matrix<'_, T, CUDA>, rhs: T) -> Matrix<'_, T, CUDA>

source§

fn muls(&self, lhs: &Matrix<'_, T, CUDA>, rhs: T) -> Matrix<'_, T, CUDA>

source§

fn divs(&self, lhs: &Matrix<'_, T, CUDA>, rhs: T) -> Matrix<'_, T, CUDA>

source§

fn subs(&self, lhs: &Matrix<'_, T, Self>, rhs: T) -> Matrix<'_, T, Self, ()>

source§

impl<T> Alloc<'_, T, ()> for CUDA

source§

fn alloc(&self, len: usize, flag: AllocFlag) -> CUDAPtr<T>

Allocate memory on the implemented device. Read more
source§

fn with_slice(&self, data: &[T]) -> CUDAPtr<T>

Allocate new memory with data Read more
source§

impl<T: CDatatype> AssignOps<T, (), CUDA> for CUDA

source§

fn add_assign(&self, lhs: &mut Buffer<'_, T, CUDA>, rhs: &Buffer<'_, T, CUDA>)

Add assign Read more
source§

fn sub_assign(&self, lhs: &mut Buffer<'_, T, CUDA>, rhs: &Buffer<'_, T, CUDA>)

source§

fn mul_assign( &self, lhs: &mut Buffer<'_, T, Self, ()>, rhs: &Buffer<'_, T, Self, ()> )

source§

impl<T: CDatatype> BaseOps<T, (), CUDA> for CUDA

source§

fn add( &self, lhs: &Matrix<'_, T, Self>, rhs: &Matrix<'_, T, Self> ) -> Matrix<'_, T, Self>

Element-wise addition Read more
source§

fn sub( &self, lhs: &Matrix<'_, T, Self>, rhs: &Matrix<'_, T, Self> ) -> Matrix<'_, T, Self>

Element-wise subtraction Read more
source§

fn mul( &self, lhs: &Matrix<'_, T, Self>, rhs: &Matrix<'_, T, Self> ) -> Matrix<'_, T, Self>

Element-wise multiplication Read more
source§

fn div( &self, lhs: &Matrix<'_, T, Self>, rhs: &Matrix<'_, T, Self> ) -> Matrix<'_, T, Self>

Element-wise division Read more
source§

impl<'a, T> CacheBuf<'a, T, ()> for CUDA

source§

fn cached(&self, len: usize) -> Buffer<'_, T, CUDA, ()>

Adds a buffer to the cache. Following calls will return this buffer, if the corresponding internal count matches with the id used in the cache. Read more
source§

impl CacheReturn for CUDA

§

type CT = RawCUBuf

source§

fn cache(&self) -> RefMut<'_, Cache<CUDA>>

Returns a device specific Cache.
source§

impl<T> ClearBuf<T, CUDA, ()> for CUDAwhere T: CDatatype,

source§

fn clear(&self, buf: &mut Buffer<'_, T, CUDA, ()>)

Sets all elements of the matrix to zero. Read more
source§

impl<T: CDatatype> ClipOp<T, (), CUDA> for CUDA

source§

fn clip(&self, x: &Matrix<'_, T, CUDA>, min: T, max: T) -> Matrix<'_, T, CUDA>

source§

impl<'a, T> CloneBuf<'a, T, ()> for CUDA

source§

fn clone_buf(&'a self, buf: &Buffer<'a, T, CUDA, ()>) -> Buffer<'a, T, CUDA, ()>

Creates a deep copy of the specified buffer. Read more
source§

impl<T: CDatatype> ColOp<T, CUDA> for CUDA

source§

fn add_col( &self, lhs: &Matrix<'_, T, Self>, rhs: &Matrix<'_, T, Self> ) -> Matrix<'_, T, Self>

source§

fn sub_col( &self, lhs: &Matrix<'_, T, Self>, rhs: &Matrix<'_, T, Self> ) -> Matrix<'_, T, Self>

source§

fn div_col( &self, lhs: &Matrix<'_, T, Self>, rhs: &Matrix<'_, T, Self> ) -> Matrix<'_, T, Self>

source§

impl<T, R> CopySlice<T, R, CUDA> for CUDAwhere R: RangeBounds<usize>,

source§

fn copy_slice( &self, buf: &Buffer<'_, T, CUDA, ()>, range: R ) -> Buffer<'_, T, CUDA, ()>

Copy a slice of the given buffer into a new buffer. Read more
source§

impl Debug for CUDA

source§

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

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

impl Device for CUDA

§

type Ptr = CUDAPtr<U>

§

type Cache = Cache<CUDA>

source§

fn new() -> Result<CUDA, Box<dyn Error + Sync + Send + 'static, Global>>

source§

fn retrieve<T, S>( &self, len: usize, add_node: impl AddGraph ) -> Buffer<'_, T, Self, S>where S: Shape, Self: for<'a> Alloc<'a, T, S>,

source§

impl<T: Copy + Default> DiagflatOp<T, CUDA> for CUDA

source§

fn diagflat(&self, x: &Matrix<'_, T, Self>) -> Matrix<'_, T, Self>

source§

impl Drop for CUDA

source§

fn drop(&mut self)

Executes the destructor for this type. Read more
source§

impl<T: CDatatype> FnsOps<T, (), CUDA> for CUDA

source§

fn exp(&self, x: &Matrix<'_, T, Self>) -> Matrix<'_, T, Self>

source§

fn ln(&self, x: &Matrix<'_, T, Self>) -> Matrix<'_, T, Self>

source§

fn neg(&self, x: &Matrix<'_, T, Self>) -> Matrix<'_, T, Self>

source§

fn powf(&self, x: &Matrix<'_, T, Self>, rhs: T) -> Matrix<'_, T, Self>

source§

fn powi(&self, x: &Matrix<'_, T, Self>, rhs: i32) -> Matrix<'_, T, Self>

source§

impl<T: GenericBlas> Gemm<T, (), (), (), CUDA> for CUDA

source§

fn gemm( &self, lhs: &Matrix<'_, T, CUDA>, rhs: &Matrix<'_, T, CUDA> ) -> Matrix<'_, T, CUDA>

source§

impl GraphReturn for CUDA

source§

fn graph(&self) -> RefMut<'_, Graph>

source§

impl<T: Number> MaxOps<T, CUDA> for CUDA

source§

fn max(&self, x: &Matrix<'_, T, CUDA>) -> T

source§

fn max_rows(&self, x: &Matrix<'_, T, CUDA>) -> Matrix<'_, T, CUDA>

source§

fn max_cols(&self, x: &Matrix<'_, T, CUDA>) -> Matrix<'_, T, CUDA>

source§

impl<T: Float> RandOp<T, (), CUDA> for CUDA

source§

fn rand(&self, x: &mut Buffer<'_, T, CUDA>, lo: T, hi: T)

source§

impl RawConv for CUDA

source§

fn construct<T, S>( ptr: &<CUDA as Device>::Ptr<T, S>, len: usize, node: Node ) -> <CUDA as CacheReturn>::CTwhere S: Shape,

source§

fn destruct<T, S>( ct: &<CUDA as CacheReturn>::CT, flag: AllocFlag ) -> (<CUDA as Device>::Ptr<T, S>, Node)where S: Shape,

source§

impl<T> Read<T, CUDA, ()> for CUDAwhere T: Default + Clone,

§

type Read = Vec<T, Global>

source§

fn read(&self, buf: &Buffer<'_, T, CUDA, ()>) -> Vec<T, Global>

Read the data of the Buffer as type Read. Read more
source§

fn read_to_vec(&self, buf: &Buffer<'_, T, CUDA, ()>) -> Vec<T, Global>where T: Default + Clone,

Read the data of a buffer into a vector Read more
source§

impl<T: CDatatype> RowOp<T, (), (), CUDA> for CUDA

source§

fn add_row( &self, lhs: &Matrix<'_, T, CUDA>, rhs: &Matrix<'_, T, CUDA> ) -> Matrix<'_, T, CUDA>

source§

fn add_row_mut(&self, lhs: &mut Matrix<'_, T, CUDA>, rhs: &Matrix<'_, T, CUDA>)

source§

impl<T: CDatatype> ScalarAssign<T, (), CUDA> for CUDA

source§

fn adds_assign(&self, lhs: &mut Matrix<'_, T, CUDA>, rhs: T)

source§

fn muls_assign(&self, lhs: &mut Matrix<'_, T, CUDA>, rhs: T)

source§

fn divs_assign(&self, lhs: &mut Matrix<'_, T, CUDA>, rhs: T)

source§

fn subs_assign(&self, lhs: &mut Matrix<'_, T, CUDA>, rhs: T)

source§

impl<T: GenericBlas + MatrixMultiply + Float> SoftmaxOps<T, CUDA> for CUDA

source§

fn softmax(&self, inputs: &Matrix<'_, T, Self>) -> Matrix<'_, T, Self>

source§

fn softmax_grad( &self, activated: &Matrix<'_, T, Self>, grads: &Matrix<'_, T, Self> ) -> Matrix<'_, T, Self>

source§

impl StaticGPU for CUDA

source§

fn as_static() -> &'static CUDA

source§

impl<T: CDatatype> SumOps<T, (), CUDA> for CUDA

source§

fn sum(&self, x: &Matrix<'_, T, CUDA>) -> T

source§

fn mean(&self, x: &Matrix<'_, T, CUDA>) -> T

source§

impl<T: CDatatype> SumOverOps<T, (), (), CUDA> for CUDA

source§

fn sum_rows(&self, x: &Matrix<'_, T, CUDA>) -> Matrix<'_, T, CUDA>

source§

fn sum_cols(&self, x: &Matrix<'_, T, CUDA>) -> Matrix<'_, T, CUDA>

source§

impl<T: CudaTranspose> TransposeOp<T, (), (), CUDA> for CUDA

source§

fn transpose(&self, x: &Matrix<'_, T, CUDA>) -> Matrix<'_, T, CUDA>

source§

impl<T> WriteBuf<T, CUDA, ()> for CUDA

source§

fn write(&self, buf: &mut Buffer<'_, T, CUDA, ()>, data: &[T])

Write data to the buffer. Read more
source§

fn write_buf( &self, _dst: &mut Buffer<'_, T, Self, S>, _src: &Buffer<'_, T, Self, S> )

Writes data from Buffer to other Buffer.

Auto Trait Implementations§

§

impl !RefUnwindSafe for CUDA

§

impl !Send for CUDA

§

impl !Sync for CUDA

§

impl Unpin for CUDA

§

impl UnwindSafe for CUDA

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

const: unstable · source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

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

const: unstable · 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, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.
source§

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

§

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

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.
source§

impl<D> IsShapeIndep for Dwhere D: RawConv,