Skip to content

Commit 60b1222

Browse files
authored
Merge pull request #88 from SwayamInSync/matmul-nd
[BUG] Fixing matmul to support leading dimensions > 1
2 parents a6885f7 + 44cbf16 commit 60b1222

4 files changed

Lines changed: 558 additions & 171 deletions

File tree

src/csrc/quadblas_interface.cpp

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,14 @@ int
2525
qblas_dot(size_t n, Sleef_quad *x, size_t incx,
2626
Sleef_quad *y, size_t incy, Sleef_quad *result)
2727
{
28-
if (!x || !y || !result || n == 0) {
28+
if (!result) {
29+
return -1;
30+
}
31+
if (n == 0) {
32+
*result = Sleef_cast_from_doubleq1(0.0);
33+
return 0;
34+
}
35+
if (!x || !y) {
2936
return -1;
3037
}
3138
*result = cblas_qdot((int)n, x, (int)incx, y, (int)incy);
@@ -38,7 +45,10 @@ qblas_gemv(char layout, char trans, size_t m, size_t n,
3845
Sleef_quad *x, size_t incx,
3946
Sleef_quad *beta, Sleef_quad *y, size_t incy)
4047
{
41-
if (!alpha || !A || !x || !beta || !y || m == 0 || n == 0) {
48+
if (m == 0 || n == 0) {
49+
return 0;
50+
}
51+
if (!alpha || !A || !x || !beta || !y) {
4252
return -1;
4353
}
4454
cblas_qgemv(to_layout(layout), to_trans(trans),
@@ -56,7 +66,10 @@ qblas_gemm(char layout, char transa, char transb,
5666
Sleef_quad *B, size_t ldb,
5767
Sleef_quad *beta, Sleef_quad *C, size_t ldc)
5868
{
59-
if (!alpha || !A || !B || !beta || !C || m == 0 || n == 0 || k == 0) {
69+
if (m == 0 || n == 0 || k == 0) {
70+
return 0;
71+
}
72+
if (!alpha || !A || !B || !beta || !C) {
6073
return -1;
6174
}
6275
cblas_qgemm(to_layout(layout), to_trans(transa), to_trans(transb),

0 commit comments

Comments
 (0)