CNugteren / CLBlast

Tuned OpenCL BLAS
Apache License 2.0
1.06k stars 202 forks source link

About the arguments meaning of the matrix operation functions #552

Closed diverger closed 4 months ago

diverger commented 4 months ago

Hi,

In the API doc, the arguments such as "m, n, k" all are simply described as:

Integer size argument. This value must be positive.

This is not so clear. Such as, is 'm' the row of OP(A), or row of A? Are these function arguments aligned with cuBlast or netlib versions? Where can I get the detailed descriptions?

Thanks.

CNugteren commented 4 months ago

The arguments are made such that they are closest to clBLAS, which CLBlast was a replacement for at the time. And indeed, those arguments are in convention with what is done in other BLAS libraries and the Netlib versions.

You are right that in the docs the arguments m, n, and k themselves are described without too much detail, but the remainder of the docs should give enough context, e.g.:

Performs the matrix product C = alpha A B + beta * C, in which A (m by k) and B (k by n) are two general rectangular input matrices, C (m by n) is the matrix to be updated, and alpha and beta are scalar values. The matrices A and/or B can optionally be transposed before performing the operation.

const size_t a_ld: Leading dimension of the input A matrix. This value must be greater than 0.

When (transpose_a == Transpose::kNo && layout == Layout::kColMajor) || (transpose_a == Transpose::kYes && layout == Layout::kRowMajor), then a_ld must be at least m, otherwise a_ld must be at least k.

If you disagree, please feel free to make a PR to improve things.

diverger commented 4 months ago

Hi,

The matrices A and/or B can optionally be transposed before performing the operation.

So, does it means the m,n,k are the dimension sizes after the optional transportations, right?

CNugteren commented 4 months ago

So, does it means the m,n,k are the dimension sizes after the optional transportations, right?

What you'll need is that the k is the dimension shared by the two matrices, m is the other dimension for A, and n is the other dimension for B.