pub struct CudaBackend { /* private fields */ }Expand description
A structure of CUDA backend.
Implementations§
Source§impl CudaBackend
impl CudaBackend
Sourcepub fn new() -> Result<CudaBackend>
pub fn new() -> Result<CudaBackend>
Creates a CUDA backend for a first device.
Sourcepub fn new_with_ordinal_and_flags(
ordinal: usize,
is_cublas: bool,
is_mma: bool,
) -> Result<CudaBackend>
pub fn new_with_ordinal_and_flags( ordinal: usize, is_cublas: bool, is_mma: bool, ) -> Result<CudaBackend>
Creates a CUDA backend with the ordinal number and the flags.
This method takes the following flags:
is_cublas- use the cuBLAS library to multiplication of matricesis_mma- use the mma instruction to multiplication of matrices
pub fn has_cublas(&self) -> bool
Trait Implementations§
Source§impl Backend for CudaBackend
impl Backend for CudaBackend
Source§fn has_cublas(&self) -> bool
fn has_cublas(&self) -> bool
Returns
true if the backend uses cuBLAS, otherwise false.Source§fn alloc_and_store_zeros(&self, n: usize) -> Result<BackendArray>
fn alloc_and_store_zeros(&self, n: usize) -> Result<BackendArray>
Allocates a backend array and stores zeros in the backend array.
Source§fn alloc_and_store(&self, elems: &[f32]) -> Result<BackendArray>
fn alloc_and_store(&self, elems: &[f32]) -> Result<BackendArray>
Allocates a backend array and stores the elements in the backend array.
Source§fn load(&self, a: &BackendArray, elems: &mut [f32]) -> Result<()>
fn load(&self, a: &BackendArray, elems: &mut [f32]) -> Result<()>
Loads elements from the backenc array.
Source§fn store(&self, a: &BackendArray, elems: &[f32]) -> Result<()>
fn store(&self, a: &BackendArray, elems: &[f32]) -> Result<()>
Stores elements in the backend array.
Source§fn copy(&self, a: &BackendArray, b: &BackendArray) -> Result<()>
fn copy(&self, a: &BackendArray, b: &BackendArray) -> Result<()>
Copies the
a backend array to the b backend array.Source§fn transpose_a(
&self,
a: &BackendArray,
b: &BackendArray,
n: usize,
m: usize,
) -> Result<()>
fn transpose_a( &self, a: &BackendArray, b: &BackendArray, n: usize, m: usize, ) -> Result<()>
Transposes the
a matrix and then the result is in the b matrix
().Source§fn add_a_b(
&self,
a: &BackendArray,
b: &BackendArray,
c: &BackendArray,
n: usize,
m: usize,
) -> Result<()>
fn add_a_b( &self, a: &BackendArray, b: &BackendArray, c: &BackendArray, n: usize, m: usize, ) -> Result<()>
Adds the
a matrix onto the b matrix and then the result is in the c matrix
().Source§fn add_at_b(
&self,
a: &BackendArray,
b: &BackendArray,
c: &BackendArray,
n: usize,
m: usize,
) -> Result<()>
fn add_at_b( &self, a: &BackendArray, b: &BackendArray, c: &BackendArray, n: usize, m: usize, ) -> Result<()>
Adds the transposed
a matrix onto the b matrix and then the result is in the c matrix
().Source§fn add_a_bt(
&self,
a: &BackendArray,
b: &BackendArray,
c: &BackendArray,
n: usize,
m: usize,
) -> Result<()>
fn add_a_bt( &self, a: &BackendArray, b: &BackendArray, c: &BackendArray, n: usize, m: usize, ) -> Result<()>
Adds the
a matrix onto the transposed b matrix and then the result is in the c matrix
().Source§fn add_at_bt(
&self,
a: &BackendArray,
b: &BackendArray,
c: &BackendArray,
n: usize,
m: usize,
) -> Result<()>
fn add_at_bt( &self, a: &BackendArray, b: &BackendArray, c: &BackendArray, n: usize, m: usize, ) -> Result<()>
Adds the transposed
a matrix onto the transposed b matrix and then the result is in the
c matrix
().Source§fn sub_a_b(
&self,
a: &BackendArray,
b: &BackendArray,
c: &BackendArray,
n: usize,
m: usize,
) -> Result<()>
fn sub_a_b( &self, a: &BackendArray, b: &BackendArray, c: &BackendArray, n: usize, m: usize, ) -> Result<()>
Subtracts the
b matrix from the a matrix and then the result is in the c matrix
().Source§fn sub_at_b(
&self,
a: &BackendArray,
b: &BackendArray,
c: &BackendArray,
n: usize,
m: usize,
) -> Result<()>
fn sub_at_b( &self, a: &BackendArray, b: &BackendArray, c: &BackendArray, n: usize, m: usize, ) -> Result<()>
Subtracts the
b matrix from the transposed a matrix and then the result is in the c
matrix
().Source§fn sub_a_bt(
&self,
a: &BackendArray,
b: &BackendArray,
c: &BackendArray,
n: usize,
m: usize,
) -> Result<()>
fn sub_a_bt( &self, a: &BackendArray, b: &BackendArray, c: &BackendArray, n: usize, m: usize, ) -> Result<()>
Subtracts the transposed
b matrix from the a matrix and then the result is in the c
matrix
().Source§fn sub_at_bt(
&self,
a: &BackendArray,
b: &BackendArray,
c: &BackendArray,
n: usize,
m: usize,
) -> Result<()>
fn sub_at_bt( &self, a: &BackendArray, b: &BackendArray, c: &BackendArray, n: usize, m: usize, ) -> Result<()>
Subtracts the transposed
b matrix from the transposed a matrix and then the result is
in the c matrix
().Source§fn mul_a_b(
&self,
a: &BackendArray,
b: &BackendArray,
c: &BackendArray,
n: usize,
m: usize,
l: usize,
) -> Result<()>
fn mul_a_b( &self, a: &BackendArray, b: &BackendArray, c: &BackendArray, n: usize, m: usize, l: usize, ) -> Result<()>
Multiplies the
a matrix by the b matrix and then the result is in the c matrix
().Source§fn mul_at_b(
&self,
a: &BackendArray,
b: &BackendArray,
c: &BackendArray,
n: usize,
m: usize,
l: usize,
) -> Result<()>
fn mul_at_b( &self, a: &BackendArray, b: &BackendArray, c: &BackendArray, n: usize, m: usize, l: usize, ) -> Result<()>
Multiplies the transposed
a matrix by the b matrix and then the result is in the c
matrix
().Source§fn mul_a_bt(
&self,
a: &BackendArray,
b: &BackendArray,
c: &BackendArray,
n: usize,
m: usize,
l: usize,
) -> Result<()>
fn mul_a_bt( &self, a: &BackendArray, b: &BackendArray, c: &BackendArray, n: usize, m: usize, l: usize, ) -> Result<()>
Multiplies the
a matrix by the transposed b matrix and then the result is in the c
matrix
().Source§fn mul_at_bt(
&self,
a: &BackendArray,
b: &BackendArray,
c: &BackendArray,
n: usize,
m: usize,
l: usize,
) -> Result<()>
fn mul_at_bt( &self, a: &BackendArray, b: &BackendArray, c: &BackendArray, n: usize, m: usize, l: usize, ) -> Result<()>
Multiplies the transposed
a matrix by the transposed b matrix and then the result is in
the c matrix
().Source§fn mul_a_b_for_elems(
&self,
a: &BackendArray,
b: &BackendArray,
c: &BackendArray,
n: usize,
m: usize,
) -> Result<()>
fn mul_a_b_for_elems( &self, a: &BackendArray, b: &BackendArray, c: &BackendArray, n: usize, m: usize, ) -> Result<()>
Multiplies the
a matrix elements by the b matrix elements and then the result is in the
c matrix
().Source§fn mul_at_b_for_elems(
&self,
a: &BackendArray,
b: &BackendArray,
c: &BackendArray,
n: usize,
m: usize,
) -> Result<()>
fn mul_at_b_for_elems( &self, a: &BackendArray, b: &BackendArray, c: &BackendArray, n: usize, m: usize, ) -> Result<()>
Multiplies the transposed
a matrix elements by the b matrix elements and saves the
result to the c matrix
().Source§fn mul_a_bt_for_elems(
&self,
a: &BackendArray,
b: &BackendArray,
c: &BackendArray,
n: usize,
m: usize,
) -> Result<()>
fn mul_a_bt_for_elems( &self, a: &BackendArray, b: &BackendArray, c: &BackendArray, n: usize, m: usize, ) -> Result<()>
Multiplies the
a matrix elements by the transposed b matrix elements and then the
result is in the c matrix
().Source§fn mul_at_bt_for_elems(
&self,
a: &BackendArray,
b: &BackendArray,
c: &BackendArray,
n: usize,
m: usize,
) -> Result<()>
fn mul_at_bt_for_elems( &self, a: &BackendArray, b: &BackendArray, c: &BackendArray, n: usize, m: usize, ) -> Result<()>
Multiplies the transposed
a matrix elements by the transposed b matrix elements and
then the result is in the c matrix.
().Source§fn div_a_b_for_elems(
&self,
a: &BackendArray,
b: &BackendArray,
c: &BackendArray,
n: usize,
m: usize,
) -> Result<()>
fn div_a_b_for_elems( &self, a: &BackendArray, b: &BackendArray, c: &BackendArray, n: usize, m: usize, ) -> Result<()>
Divides the
a matrix elements by the b matrix elements and then the result is in the
c matrix
().Source§fn div_at_b_for_elems(
&self,
a: &BackendArray,
b: &BackendArray,
c: &BackendArray,
n: usize,
m: usize,
) -> Result<()>
fn div_at_b_for_elems( &self, a: &BackendArray, b: &BackendArray, c: &BackendArray, n: usize, m: usize, ) -> Result<()>
Divides the transposed
a matrix elements by the b matrix elements and then the result
is in the c matrix
().Source§fn div_a_bt_for_elems(
&self,
a: &BackendArray,
b: &BackendArray,
c: &BackendArray,
n: usize,
m: usize,
) -> Result<()>
fn div_a_bt_for_elems( &self, a: &BackendArray, b: &BackendArray, c: &BackendArray, n: usize, m: usize, ) -> Result<()>
Divides the transposed
a matrix elements by the b matrix elements and then the result
is in the c matrix
().Source§fn div_at_bt_for_elems(
&self,
a: &BackendArray,
b: &BackendArray,
c: &BackendArray,
n: usize,
m: usize,
) -> Result<()>
fn div_at_bt_for_elems( &self, a: &BackendArray, b: &BackendArray, c: &BackendArray, n: usize, m: usize, ) -> Result<()>
Divides the transposed
a matrix elements by the transposed b matrix elements and then
the result is in the c matrix
().Source§fn add_a_b_for_scalar(
&self,
a: &BackendArray,
b: f32,
c: &BackendArray,
n: usize,
m: usize,
) -> Result<()>
fn add_a_b_for_scalar( &self, a: &BackendArray, b: f32, c: &BackendArray, n: usize, m: usize, ) -> Result<()>
Adds the
a matrix onto the b scalar and then the result is in the c matrix
().Source§fn add_at_b_for_scalar(
&self,
a: &BackendArray,
b: f32,
c: &BackendArray,
n: usize,
m: usize,
) -> Result<()>
fn add_at_b_for_scalar( &self, a: &BackendArray, b: f32, c: &BackendArray, n: usize, m: usize, ) -> Result<()>
Adds the transposed
a matrix onto the b scalar and then the result is in the c matrix
().Source§fn sub_a_b_for_scalar(
&self,
a: &BackendArray,
b: f32,
c: &BackendArray,
n: usize,
m: usize,
) -> Result<()>
fn sub_a_b_for_scalar( &self, a: &BackendArray, b: f32, c: &BackendArray, n: usize, m: usize, ) -> Result<()>
Subtracts the
b scalar from the a matrix and then the result is in the c matrix.
().Source§fn sub_at_b_for_scalar(
&self,
a: &BackendArray,
b: f32,
c: &BackendArray,
n: usize,
m: usize,
) -> Result<()>
fn sub_at_b_for_scalar( &self, a: &BackendArray, b: f32, c: &BackendArray, n: usize, m: usize, ) -> Result<()>
Subtracts the
b scalar from the transposed a matrix and then the result is in the c
matrix
().Source§fn rsub_a_b_for_scalar(
&self,
a: &BackendArray,
b: f32,
c: &BackendArray,
n: usize,
m: usize,
) -> Result<()>
fn rsub_a_b_for_scalar( &self, a: &BackendArray, b: f32, c: &BackendArray, n: usize, m: usize, ) -> Result<()>
Subtracts the
a matrix from the b scalar and then the result is in the c matrix
().Source§fn rsub_at_b_for_scalar(
&self,
a: &BackendArray,
b: f32,
c: &BackendArray,
n: usize,
m: usize,
) -> Result<()>
fn rsub_at_b_for_scalar( &self, a: &BackendArray, b: f32, c: &BackendArray, n: usize, m: usize, ) -> Result<()>
Subtracts the transposed
a matrix from the b scalar and then the result is in the c
matrix
().Source§fn mul_a_b_for_scalar(
&self,
a: &BackendArray,
b: f32,
c: &BackendArray,
n: usize,
m: usize,
) -> Result<()>
fn mul_a_b_for_scalar( &self, a: &BackendArray, b: f32, c: &BackendArray, n: usize, m: usize, ) -> Result<()>
Multiplies the
a matrix by the b scalar and then the result is in the c matrix
().Source§fn mul_at_b_for_scalar(
&self,
a: &BackendArray,
b: f32,
c: &BackendArray,
n: usize,
m: usize,
) -> Result<()>
fn mul_at_b_for_scalar( &self, a: &BackendArray, b: f32, c: &BackendArray, n: usize, m: usize, ) -> Result<()>
Multiplies the transposed
a matrix by the b scalar and then the result is in the c
matrix
().Source§fn div_a_b_for_scalar(
&self,
a: &BackendArray,
b: f32,
c: &BackendArray,
n: usize,
m: usize,
) -> Result<()>
fn div_a_b_for_scalar( &self, a: &BackendArray, b: f32, c: &BackendArray, n: usize, m: usize, ) -> Result<()>
Divides the
a matrix by the b scalar and then the result is in the c matrix
().Source§fn div_at_b_for_scalar(
&self,
a: &BackendArray,
b: f32,
c: &BackendArray,
n: usize,
m: usize,
) -> Result<()>
fn div_at_b_for_scalar( &self, a: &BackendArray, b: f32, c: &BackendArray, n: usize, m: usize, ) -> Result<()>
Divides the transposed
a matrix by the b scalar and then the result is in the c
matrix
().Source§fn rdiv_a_b_for_scalar(
&self,
a: &BackendArray,
b: f32,
c: &BackendArray,
n: usize,
m: usize,
) -> Result<()>
fn rdiv_a_b_for_scalar( &self, a: &BackendArray, b: f32, c: &BackendArray, n: usize, m: usize, ) -> Result<()>
Divides the
b scalar by the a matrix elements and then the result is in the c matrix
().Source§fn rdiv_at_b_for_scalar(
&self,
a: &BackendArray,
b: f32,
c: &BackendArray,
n: usize,
m: usize,
) -> Result<()>
fn rdiv_at_b_for_scalar( &self, a: &BackendArray, b: f32, c: &BackendArray, n: usize, m: usize, ) -> Result<()>
Divides the
b scalar by the transposed a matrix elements and then the result is in the
c matrix
().Source§fn sigmoid_a(
&self,
a: &BackendArray,
b: &BackendArray,
n: usize,
m: usize,
) -> Result<()>
fn sigmoid_a( &self, a: &BackendArray, b: &BackendArray, n: usize, m: usize, ) -> Result<()>
Calculates sigmoid function for the
a matrix adn the result is the b matrix
().Source§fn sigmoid_at(
&self,
a: &BackendArray,
b: &BackendArray,
n: usize,
m: usize,
) -> Result<()>
fn sigmoid_at( &self, a: &BackendArray, b: &BackendArray, n: usize, m: usize, ) -> Result<()>
Calculates sigmoid function for the transposed
a matrix and then the result is in the b
matrix
().Source§fn tanh_a(
&self,
a: &BackendArray,
b: &BackendArray,
n: usize,
m: usize,
) -> Result<()>
fn tanh_a( &self, a: &BackendArray, b: &BackendArray, n: usize, m: usize, ) -> Result<()>
Calculates hyperbolic tangent function for the
a matrix and then the result is in b
matrix
().Source§fn tanh_at(
&self,
a: &BackendArray,
b: &BackendArray,
n: usize,
m: usize,
) -> Result<()>
fn tanh_at( &self, a: &BackendArray, b: &BackendArray, n: usize, m: usize, ) -> Result<()>
Calculates hyperbolic tangent function for the transposed
a matrix and then the result is
in the b matrix
().Source§fn softmax_a(
&self,
a: &BackendArray,
b: &BackendArray,
n: usize,
m: usize,
) -> Result<()>
fn softmax_a( &self, a: &BackendArray, b: &BackendArray, n: usize, m: usize, ) -> Result<()>
Calculates softmax function for the
a matrix and then the result is in the b matrix
().Source§fn softmax_at(
&self,
a: &BackendArray,
b: &BackendArray,
n: usize,
m: usize,
) -> Result<()>
fn softmax_at( &self, a: &BackendArray, b: &BackendArray, n: usize, m: usize, ) -> Result<()>
Calculates softmax function for the transposed
a matrix and then the result is in the b
matrix
().Source§fn repeat_col_a(
&self,
a: &BackendArray,
b: &BackendArray,
n: usize,
m: usize,
) -> Result<()>
fn repeat_col_a( &self, a: &BackendArray, b: &BackendArray, n: usize, m: usize, ) -> Result<()>
Repeats the
a vector as column
().Source§fn repeat_row_a(
&self,
a: &BackendArray,
b: &BackendArray,
n: usize,
m: usize,
) -> Result<()>
fn repeat_row_a( &self, a: &BackendArray, b: &BackendArray, n: usize, m: usize, ) -> Result<()>
Repeats the
a vector as row
().Auto Trait Implementations§
impl !Freeze for CudaBackend
impl RefUnwindSafe for CudaBackend
impl Send for CudaBackend
impl Sync for CudaBackend
impl Unpin for CudaBackend
impl UnwindSafe for CudaBackend
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more