arrayfire.blas module

BLAS functions (matmul, dot, etc)

arrayfire.blas.dot(lhs,rhs,lhs_opts=<MATPROP.NONE:0>,rhs_opts=<MATPROP.NONE:0>,return_scalar=False)[source]

Dot product of two input vectors.

Parameters
lhsaf.Array

A 1 dimensional, real or complex arrayfire array.

rhsaf.Array

A 1 dimensional, real or complex arrayfire array.

lhs_opts: optional: af.MATPROP. default: af.MATPROP.NONE.
Can be one of
  • af.MATPROP.NONE - If no op should be done onlhs.

  • No other options are currently supported.

rhs_opts: optional: af.MATPROP. default: af.MATPROP.NONE.
Can be one of
  • af.MATPROP.NONE - If no op should be done onrhs.

  • No other options are currently supported.

return_scalar: optional: bool. default: False.
  • When set to true, the input arrays are flattened and the output is a scalar

Returns
outaf.Array or scalar

Output of dot product oflhs andrhs.

arrayfire.blas.gemm(lhs,rhs,alpha=1.0,beta=0.0,lhs_opts=<MATPROP.NONE:0>,rhs_opts=<MATPROP.NONE:0>,C=None)[source]

BLAS general matrix multiply (GEMM) of two af_array objects.

This provides a general interface to the BLAS level 3 general matrix multiply (GEMM), which is generally defined as:

C = alpha * opA(A) opB(B) + beta * C

where alpha and beta are both scalars; A and B are the matrix multiply operands;and opA and opB are noop (if AF_MAT_NONE) or transpose (if AF_MAT_TRANS) operationson A or B before the actual GEMM operation.Batched GEMM is supported if at least either A or B have more than two dimensions(see af::matmul for more details on broadcasting).However, only one alpha and one beta can be used for all of the batched matrix operands.

Parameters
lhsaf.Array

A 2 dimensional, real or complex arrayfire array.

rhsaf.Array

A 2 dimensional, real or complex arrayfire array.

alphascalar
betascalar
lhs_opts: optional: af.MATPROP. default: af.MATPROP.NONE.
Can be one of
  • af.MATPROP.NONE - If no op should be done onlhs.

  • af.MATPROP.TRANS - Iflhs has to be transposed before multiplying.

  • af.MATPROP.CTRANS - Iflhs has to be hermitian transposed before multiplying.

rhs_opts: optional: af.MATPROP. default: af.MATPROP.NONE.
Can be one of
  • af.MATPROP.NONE - If no op should be done onrhs.

  • af.MATPROP.TRANS - Ifrhs has to be transposed before multiplying.

  • af.MATPROP.CTRANS - Ifrhs has to be hermitian transposed before multiplying.

Returns
outaf.Array

Output of the matrix multiplication onlhs andrhs.

arrayfire.blas.matmul(lhs,rhs,lhs_opts=<MATPROP.NONE:0>,rhs_opts=<MATPROP.NONE:0>)[source]

Generalized matrix multiplication for two matrices.

Parameters
lhsaf.Array

A 2 dimensional, real or complex arrayfire array.

rhsaf.Array

A 2 dimensional, real or complex arrayfire array.

lhs_opts: optional: af.MATPROP. default: af.MATPROP.NONE.
Can be one of
  • af.MATPROP.NONE - If no op should be done onlhs.

  • af.MATPROP.TRANS - Iflhs has to be transposed before multiplying.

  • af.MATPROP.CTRANS - Iflhs has to be hermitian transposed before multiplying.

rhs_opts: optional: af.MATPROP. default: af.MATPROP.NONE.
Can be one of
  • af.MATPROP.NONE - If no op should be done onrhs.

  • af.MATPROP.TRANS - Ifrhs has to be transposed before multiplying.

  • af.MATPROP.CTRANS - Ifrhs has to be hermitian transposed before multiplying.

Returns
outaf.Array

Output of the matrix multiplication onlhs andrhs.

arrayfire.blas.matmulNT(lhs,rhs)[source]

Matrix multiplication after transposing the second matrix.

Parameters
lhsaf.Array

A 2 dimensional, real or complex arrayfire array.

rhsaf.Array

A 2 dimensional, real or complex arrayfire array.

Returns
outaf.Array

Output of the matrix multiplication onlhs andtranspose(rhs).

arrayfire.blas.matmulTN(lhs,rhs)[source]

Matrix multiplication after transposing the first matrix.

Parameters
lhsaf.Array

A 2 dimensional, real or complex arrayfire array.

rhsaf.Array

A 2 dimensional, real or complex arrayfire array.

Returns
outaf.Array

Output of the matrix multiplication ontranspose(lhs) andrhs.

arrayfire.blas.matmulTT(lhs,rhs)[source]

Matrix multiplication after transposing both inputs.

Parameters
lhsaf.Array

A 2 dimensional, real or complex arrayfire array.

rhsaf.Array

A 2 dimensional, real or complex arrayfire array.

Returns
outaf.Array

Output of the matrix multiplication ontranspose(lhs) andtranspose(rhs).