Standard functions
Matrix multiply
For two 2D arrays, * performs matrix multiplication. Use .* for an elementwise product.
using LinearAlgebra
using cuNumeric
A = cuNumeric.rand(Float32, 128, 128)
B = cuNumeric.rand(Float32, 128, 128)
C = A * B # allocates a new result
mul!(similar(C), A, B) # in-place GEMM into an existing arrayLinearAlgebra.mul! Method
LinearAlgebra.mul!(out::NDArray, arr1::NDArray, arr2::NDArray)Compute the matrix multiplication of arr1 and arr2, storing the result in out.
This function performs the operation in-place, modifying out.
Examples
a = cuNumeric.ones(2, 3)
b = cuNumeric.ones(3, 2)
out = cuNumeric.zeros(2, 2)
LinearAlgebra.mul!(out, a, b)Vector operations
Supported LinearAlgebra operations include:
mul!(y, A, x)andmul!(y, A, x, α, β)for matrix-vector products.A * xis also supported.mul!(C, A, B, α, β)for matrix-matrix products.dot(x, y)and entrywisenorm(A, p)(dense-array norms currently require a GPU).axpy!,axpby!,lmul!, andrmul!.ldiv!(y, D, x)andldiv!(D, x)for an NDArray-backedDiagonal.
dot and dense-array norm return device scalars.
Solve
cuNumeric.solve(A, b) solves a linear system and returns an array with the same shape as b. A is a square m × m matrix and b has shape (m,) or (m, n). A \ b is equivalent.
A = cuNumeric.rand(Float32, 64, 64)
b = cuNumeric.rand(Float32, 64)
x = cuNumeric.solve(A, b) # or: A \ b
B = cuNumeric.rand(Float32, 64, 4)
X = A \ BHelpers
These helpers live on NDArray and are also listed in the Public API:
cuNumeric.transposecuNumeric.diag(2D to 1D)cuNumeric.trace
Iterative solvers
See the Krylov.jl example for conjugate gradient, workspace reuse, and the scalar-handling macros.