Skip to content

Commit 322681b

Browse files
committed
Use "right" ld* with 1D matrices
1 parent 83d1868 commit 322681b

1 file changed

Lines changed: 12 additions & 4 deletions

File tree

src/gpuarray_array_blas.c

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -550,10 +550,14 @@ int GpuArray_rgemmBatch_3d(cb_transpose transA, cb_transpose transB, double alph
550550

551551
if (cC == 2) {
552552
o = cb_fortran;
553-
ldc = Cp->strides[2] / elsize;
553+
ldc = Cp->dimensions[2] > 1
554+
? Cp->strides[2] / elsize
555+
: Cp->dimensions[1];
554556
} else if (cC == 1) {
555557
o = cb_c;
556-
ldc = Cp->strides[1] / elsize;
558+
ldc = Cp->dimensions[1] > 1
559+
? Cp->strides[1] / elsize
560+
: Cp->dimensions[2];
557561
} else {
558562
err = GA_VALUE_ERROR;
559563
goto cleanup;
@@ -579,15 +583,19 @@ int GpuArray_rgemmBatch_3d(cb_transpose transA, cb_transpose transB, double alph
579583
goto cleanup;
580584
}
581585
if (cB == 2) {
582-
ldb = Bp->strides[2] / elsize;
586+
ldb = Bp->dimensions[2] > 1
587+
? Bp->strides[2] / elsize
588+
: Bp->dimensions[1];
583589
if (o == cb_c) {
584590
if (transB == cb_no_trans)
585591
transB = cb_trans;
586592
else
587593
transB = cb_no_trans;
588594
}
589595
} else if (cB == 1) {
590-
ldb = Bp->strides[1] / elsize;
596+
ldb = Bp->dimensions[1] > 1
597+
? Bp->strides[1] / elsize
598+
: Bp->dimensions[2];
591599
if (o == cb_fortran) {
592600
if (transB == cb_no_trans)
593601
transB = cb_trans;

0 commit comments

Comments
 (0)