Trait Backend

Source
pub trait Backend {
Show 53 methods // Required methods fn name(&self) -> &'static str; fn has_cublas(&self) -> bool; unsafe fn alloc(&self, n: usize) -> Result<BackendArray>; fn alloc_and_store_zeros(&self, n: usize) -> Result<BackendArray>; fn alloc_and_store(&self, elems: &[f32]) -> Result<BackendArray>; fn load(&self, a: &BackendArray, elems: &mut [f32]) -> Result<()>; fn store(&self, a: &BackendArray, elems: &[f32]) -> Result<()>; fn copy(&self, a: &BackendArray, b: &BackendArray) -> Result<()>; fn transpose_a( &self, a: &BackendArray, b: &BackendArray, n: usize, m: usize, ) -> Result<()>; fn add_a_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<()>; fn add_a_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<()>; fn sub_a_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<()>; fn sub_a_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<()>; fn mul_a_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<()>; fn mul_a_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<()>; fn mul_a_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<()>; fn mul_a_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<()>; fn div_a_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<()>; fn div_a_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<()>; fn add_a_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<()>; fn sub_a_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<()>; fn rsub_a_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<()>; fn mul_a_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<()>; fn div_a_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<()>; fn rdiv_a_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<()>; fn sigmoid_a( &self, a: &BackendArray, b: &BackendArray, n: usize, m: usize, ) -> Result<()>; fn sigmoid_at( &self, a: &BackendArray, b: &BackendArray, n: usize, m: usize, ) -> Result<()>; fn tanh_a( &self, a: &BackendArray, b: &BackendArray, n: usize, m: usize, ) -> Result<()>; fn tanh_at( &self, a: &BackendArray, b: &BackendArray, n: usize, m: usize, ) -> Result<()>; fn swish_a( &self, a: &BackendArray, b: &BackendArray, n: usize, m: usize, ) -> Result<()>; fn swish_at( &self, a: &BackendArray, b: &BackendArray, n: usize, m: usize, ) -> Result<()>; fn softmax_a( &self, a: &BackendArray, b: &BackendArray, n: usize, m: usize, ) -> Result<()>; fn softmax_at( &self, a: &BackendArray, b: &BackendArray, n: usize, m: usize, ) -> Result<()>; fn sqrt_a( &self, a: &BackendArray, b: &BackendArray, n: usize, m: usize, ) -> Result<()>; fn sqrt_at( &self, a: &BackendArray, b: &BackendArray, n: usize, m: usize, ) -> Result<()>; fn repeat_col_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<()>;
}
Expand description

A backend trait.

The backend provides a low-level interface to computing platform (OpenCL or CUDA) for basic operations and functions on matrices. The backend methods operate on backend arrays which refers to areas of the device memory. The backend is low-level layer between a frontend and computing platform.

Required Methods§

Source

fn name(&self) -> &'static str

Returns the backend name.

Source

fn has_cublas(&self) -> bool

Returns true if the backend uses cuBLAS, otherwise false.

Source

unsafe fn alloc(&self, n: usize) -> Result<BackendArray>

Allocates a backend array.

Source

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>

Allocates a backend array and stores the elements in the backend array.

Source

fn load(&self, a: &BackendArray, elems: &mut [f32]) -> Result<()>

Loads elements from the backenc array.

Source

fn store(&self, a: &BackendArray, elems: &[f32]) -> Result<()>

Stores elements in the backend array.

Source

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<()>

Transposes the a matrix and then the result is in the b matrix (C=AT).

Source

fn add_a_b( &self, a: &BackendArray, b: &BackendArray, c: &BackendArray, n: usize, m: usize, ) -> Result<()>

Adds the b matrix to the a matrix and then the result is in the c matrix (C=A+B).

Source

fn add_at_b( &self, a: &BackendArray, b: &BackendArray, c: &BackendArray, n: usize, m: usize, ) -> Result<()>

Adds the b matrix to the transposed a matrix and then the result is in the c matrix (C=AT+B).

Source

fn add_a_bt( &self, a: &BackendArray, b: &BackendArray, c: &BackendArray, n: usize, m: usize, ) -> Result<()>

Adds the transposed b matrix to the a matrix and then the result is in the c matrix (C=A+BT).

Source

fn add_at_bt( &self, a: &BackendArray, b: &BackendArray, c: &BackendArray, n: usize, m: usize, ) -> Result<()>

Adds the transposed b matrix to the transposed a matrix and then the result is in the c matrix (C=AT+BT).

Source

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 (C=A-B).

Source

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 (C=AT-B).

Source

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 (C=A-BT).

Source

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 (C=AT-BT).

Source

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 (C=A·B).

Source

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 (C=AT·B).

Source

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 (C=A·BT).

Source

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 (C=AT·BT).

Source

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 (cij=aij·bij).

Source

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 (cij=aji·bij).

Source

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 (cij=aij·bji).

Source

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. (cij=aji·bji).

Source

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 (cij=aijbij).

Source

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 (cij=ajibij).

Source

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 (cij=aijbji).

Source

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 (cij=ajibji).

Source

fn add_a_b_for_scalar( &self, a: &BackendArray, b: f32, c: &BackendArray, n: usize, m: usize, ) -> Result<()>

Adds the b scalar to the a matrix and then the result is in the c matrix (C=A+b).

Source

fn add_at_b_for_scalar( &self, a: &BackendArray, b: f32, c: &BackendArray, n: usize, m: usize, ) -> Result<()>

Adds the b scalar to the transposed a matrix and then the result is in the c matrix (C=AT+b).

Source

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. (C=A-b).

Source

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 (C=AT-b).

Source

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 (C=b-A).

Source

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 (C=b-AT).

Source

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 (C=A·b).

Source

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 (C=AT·b).

Source

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 (C=Ab).

Source

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 (C=ATb).

Source

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 (cij=baij).

Source

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 (cij=baji).

Source

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 (B=sigmoid(A)).

Source

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 (B=sigmoid(AT)).

Source

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 (B=tanh(A)).

Source

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 (B=tanh(AT)).

Source

fn swish_a( &self, a: &BackendArray, b: &BackendArray, n: usize, m: usize, ) -> Result<()>

Calculates swish function for the a matrix adn the result is the b matrix (B=swish(A)).

Source

fn swish_at( &self, a: &BackendArray, b: &BackendArray, n: usize, m: usize, ) -> Result<()>

Calculates swish function for the transposed a matrix and then the result is in the b matrix (B=swish(AT)).

Source

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 (B=softmax(A)).

Source

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 (B=softmax(AT)).

Source

fn sqrt_a( &self, a: &BackendArray, b: &BackendArray, n: usize, m: usize, ) -> Result<()>

Calculates square root of the a matrix adn the result is the b matrix (B=A).

Source

fn sqrt_at( &self, a: &BackendArray, b: &BackendArray, n: usize, m: usize, ) -> Result<()>

Calculates square root of the transposed a matrix and then the result is in the b matrix (B=AT).

Source

fn repeat_col_a( &self, a: &BackendArray, b: &BackendArray, n: usize, m: usize, ) -> Result<()>

Repeats the a vector as column (bij=ai).

Source

fn repeat_row_a( &self, a: &BackendArray, b: &BackendArray, n: usize, m: usize, ) -> Result<()>

Repeats the a vector as row (bij=aj).

Implementors§