@@ -492,13 +492,15 @@ THCTensor_(baddbmm)(THCState *state, THCTensor *result, real beta, THCTensor *t,
492492 ldc = result_->stride [2 ];
493493 }
494494
495- if (batch1->stride [transpose_result ? 2 : 1 ] == 1 )
495+ if (batch1->stride [transpose_result ? 2 : 1 ] == 1 &&
496+ batch1->stride [transpose_result ? 1 : 2 ] != 0 )
496497 {
497498 transpose_batch1 = ' n' ;
498499 batch1_ = batch1;
499500 lda = batch1_->stride [transpose_result ? 1 : 2 ];
500501 }
501- else if (batch1->stride [transpose_result ? 1 : 2 ] == 1 )
502+ else if (batch1->stride [transpose_result ? 1 : 2 ] == 1 &&
503+ batch1->stride [transpose_result ? 2 : 1 ] != 0 )
502504 {
503505 transpose_batch1 = ' t' ;
504506 batch1_ = batch1;
@@ -511,13 +513,15 @@ THCTensor_(baddbmm)(THCState *state, THCTensor *result, real beta, THCTensor *t,
511513 lda = batch1_->stride [1 ];
512514 }
513515
514- if (batch2->stride [transpose_result ? 2 : 1 ] == 1 )
516+ if (batch2->stride [transpose_result ? 2 : 1 ] == 1 &&
517+ batch2->stride [transpose_result ? 1 : 2 ] != 0 )
515518 {
516519 transpose_batch2 = ' n' ;
517520 batch2_ = batch2;
518521 ldb = batch2_->stride [transpose_result ? 1 : 2 ];
519522 }
520- else if (batch2->stride [transpose_result ? 1 : 2 ] == 1 )
523+ else if (batch2->stride [transpose_result ? 1 : 2 ] == 1 &&
524+ batch2->stride [transpose_result ? 2 : 1 ] != 0 )
521525 {
522526 transpose_batch2 = ' t' ;
523527 batch2_ = batch2;
@@ -529,7 +533,6 @@ THCTensor_(baddbmm)(THCState *state, THCTensor *result, real beta, THCTensor *t,
529533 batch2_ = THCTensor_ (newContiguous)(state, batch2);
530534 ldb = batch2_->stride [1 ];
531535 }
532-
533536 long num_batches = result_->size [0 ];
534537
535538#if defined(THC_REAL_IS_FLOAT) || defined(THC_REAL_IS_DOUBLE)
0 commit comments