SoFunction
Updated on 2024-11-12

pytorch common linear functions in detail

Pytorch's linear functions mainly encapsulate Blas and Lapack, with similar usage and interfaces.

The commonly used linear functions are as follows:

function (math.) functionality
trace Sum of diagonal elements (trace of matrix)
diag diagonal element
triu/tril Upper/lower triangles of the matrix with specified offsets
mm/bmm Matrix multiplication, matrix multiplication of batch
t reprovision
dot/cross Inner product/outer product
inverse Finding the inverse matrix
svd singular value decomposition (math.)

Note: The transpose of the matrix will make the storage space discontinuous, you need to call its .contiguous method to turn it continuous.

Example:

import torch as t
b=()
b.is_contiguous()
 
exports:False
 
b=()
b.is_contiguous()
 
exports:True

Above this pytorch commonly used linear functions in detail is all that I have shared with you, I hope to give you a reference, and I hope you will support me more.