@@ -24,11 +24,12 @@ int GpuArray_rdot(GpuArray *X, GpuArray *Y,
2424 X -> typecode != GA_DOUBLE )
2525 return error_set (ctx -> err , GA_INVALID_ERROR , "Data type not supported" );
2626
27- if (X -> nd != 1 || Y -> nd != 1 || Z -> nd != 0 ||
28- X -> typecode != Y -> typecode || X -> typecode != Z -> typecode )
27+ if (X -> nd != 1 || Y -> nd != 1 || Z -> nd != 0 )
2928 return error_fmt (ctx -> err , GA_VALUE_ERROR ,
30- "Wrong number of dimensions: X->nd = %d (expected 1), Y->nd = %d (expected 1), Z->nd = %d (expected 0)" ,
29+ "Wrong number of dimensions: X->nd = %u (expected 1), Y->nd = %u (expected 1), Z->nd = %u (expected 0)" ,
3130 X -> nd , Y -> nd , Z -> nd );
31+ if (X -> typecode != Y -> typecode || X -> typecode != Z -> typecode )
32+ error_set (ctx -> err , GA_VALUE_ERROR , "Inconsistent dtypes" );
3233 n = X -> dimensions [0 ];
3334 if (!(X -> flags & GA_ALIGNED ) || !(Y -> flags & GA_ALIGNED ) ||
3435 !(Z -> flags & GA_ALIGNED ))
@@ -111,11 +112,14 @@ int GpuArray_rgemv(cb_transpose transA, double alpha, GpuArray *A,
111112 if (A -> typecode != GA_HALF &&
112113 A -> typecode != GA_FLOAT &&
113114 A -> typecode != GA_DOUBLE )
114- return error_set (ctx -> err , GA_INVALID_ERROR , "Unsupported data type " );
115+ return error_set (ctx -> err , GA_INVALID_ERROR , "Unsupported dtype " );
115116
116- if (A -> nd != 2 || X -> nd != 1 || Y -> nd != 1 ||
117- X -> typecode != A -> typecode || Y -> typecode != A -> typecode )
118- return error_set (ctx -> err , GA_VALUE_ERROR , "Bad shape or inconsistent types" );
117+ if (A -> nd != 2 || X -> nd != 1 || Y -> nd != 1 )
118+ return error_fmt (ctx -> err , GA_VALUE_ERROR ,
119+ "Wrong number of dimensions: A->nd = %u (expected 2), X->nd = %u (expected 1), Y->nd = %u (expected 1)" ,
120+ A -> nd , X -> nd , Y -> nd );
121+ if (X -> typecode != A -> typecode || Y -> typecode != A -> typecode )
122+ return error_set (ctx -> err , GA_VALUE_ERROR , "Inconsistent dtypes" );
119123
120124 if (!(A -> flags & GA_ALIGNED ) || !(X -> flags & GA_ALIGNED ) ||
121125 !(Y -> flags & GA_ALIGNED ))
@@ -213,12 +217,14 @@ int GpuArray_rgemm(cb_transpose transA, cb_transpose transB, double alpha,
213217
214218 if (A -> typecode != GA_HALF && A -> typecode != GA_FLOAT &&
215219 A -> typecode != GA_DOUBLE )
216- return error_set (ctx -> err , GA_INVALID_ERROR , "Unsupported type " );
220+ return error_set (ctx -> err , GA_INVALID_ERROR , "Unsupported dtype " );
217221
218- if (A -> nd != 2 || B -> nd != 2 || C -> nd != 2 ||
219- B -> typecode != A -> typecode ||
220- C -> typecode != A -> typecode )
221- return error_set (ctx -> err , GA_VALUE_ERROR , "Inconsistent nd or types" );
222+ if (A -> nd != 2 || B -> nd != 2 || C -> nd != 2 )
223+ return error_fmt (ctx -> err , GA_VALUE_ERROR ,
224+ "Wrong number of dimensions: A->nd = %u (expected 2), B->nd = %u (expected 2), C->nd = %u (expected 2)" ,
225+ A -> nd , B -> nd , C -> nd );
226+ if (B -> typecode != A -> typecode || C -> typecode != A -> typecode )
227+ return error_set (ctx -> err , GA_VALUE_ERROR , "Inconsistent dtypes" );
222228
223229 if (!(A -> flags & GA_ALIGNED ) || !(B -> flags & GA_ALIGNED ) ||
224230 !(C -> flags & GA_ALIGNED ))
@@ -363,12 +369,14 @@ int GpuArray_rger(double alpha, GpuArray *X, GpuArray *Y, GpuArray *A,
363369
364370 if (X -> typecode != GA_HALF && X -> typecode != GA_FLOAT &&
365371 X -> typecode != GA_DOUBLE )
366- return error_set (ctx -> err , GA_INVALID_ERROR , "Unsupported type " );
372+ return error_set (ctx -> err , GA_INVALID_ERROR , "Unsupported dtype " );
367373
368- if (X -> nd != 1 || Y -> nd != 1 || A -> nd != 2 ||
369- Y -> typecode != X -> typecode ||
370- A -> typecode != X -> typecode )
371- return error_set (ctx -> err , GA_VALUE_ERROR , "Invalid dims or inconsistent types" );
374+ if (X -> nd != 1 || Y -> nd != 1 || A -> nd != 2 )
375+ return error_fmt (ctx -> err , GA_VALUE_ERROR ,
376+ "Wrong number of dimensions: X->nd = %u (expected 1), Y->nd = %u (expected 1), A->nd = %u (expected 2)" ,
377+ X -> nd , Y -> nd , A -> nd );
378+ if (Y -> typecode != X -> typecode || A -> typecode != X -> typecode )
379+ return error_set (ctx -> err , GA_VALUE_ERROR , "Inconsistent dtypes" );
372380
373381 if (!(X -> flags & GA_ALIGNED ) || !(Y -> flags & GA_ALIGNED ) ||
374382 !(A -> flags & GA_ALIGNED ))
@@ -479,12 +487,14 @@ int GpuArray_rgemmBatch_3d(cb_transpose transA, cb_transpose transB, double alph
479487 size_t i ;
480488
481489 if (A -> typecode != GA_FLOAT && A -> typecode != GA_DOUBLE )
482- return error_set (ctx -> err , GA_INVALID_ERROR , "Unsupported type " );
490+ return error_set (ctx -> err , GA_INVALID_ERROR , "Unsupported dtype " );
483491
484- if (A -> nd != 3 || B -> nd != 3 || C -> nd != 3 ||
485- B -> typecode != A -> typecode ||
486- C -> typecode != A -> typecode )
487- return error_set (ctx -> err , GA_VALUE_ERROR , "Invalid dims or inconsistent types" );
492+ if (A -> nd != 3 || B -> nd != 3 || C -> nd != 3 )
493+ return error_fmt (ctx -> err , GA_VALUE_ERROR ,
494+ "Wrong number of dimensions: A->nd = %u (expected 3), B->nd = %u (expected 3), C->nd = %u (expected 3)" ,
495+ A -> nd , B -> nd , C -> nd );
496+ if (B -> typecode != A -> typecode || C -> typecode != A -> typecode )
497+ return error_set (ctx -> err , GA_VALUE_ERROR , "Inconsistent dtypes" );
488498
489499 if (!(A -> flags & GA_ALIGNED ) || !(B -> flags & GA_ALIGNED ) ||
490500 !(C -> flags & GA_ALIGNED ))
@@ -558,7 +568,7 @@ int GpuArray_rgemmBatch_3d(cb_transpose transA, cb_transpose transB, double alph
558568 ? Cp -> strides [1 ] / elsize
559569 : Cp -> dimensions [2 ];
560570 } else {
561- err = error_set (ctx -> err , GA_VALUE_ERROR , "Invalid internal result for C" );
571+ err = error_set (ctx -> err , GA_MISC_ERROR , "Invalid internal result for C" );
562572 goto cleanup ;
563573 }
564574 if (cA == 2 ) {
@@ -582,7 +592,7 @@ int GpuArray_rgemmBatch_3d(cb_transpose transA, cb_transpose transB, double alph
582592 transA = cb_no_trans ;
583593 }
584594 } else {
585- err = error_set (ctx -> err , GA_VALUE_ERROR , "Invalid internal result for A" );
595+ err = error_set (ctx -> err , GA_MISC_ERROR , "Invalid internal result for A" );
586596 goto cleanup ;
587597 }
588598 if (cB == 2 ) {
@@ -606,7 +616,7 @@ int GpuArray_rgemmBatch_3d(cb_transpose transA, cb_transpose transB, double alph
606616 transB = cb_no_trans ;
607617 }
608618 } else {
609- err = error_set (ctx -> err , GA_VALUE_ERROR , "Invalid internal result for B" );
619+ err = error_set (ctx -> err , GA_MISC_ERROR , "Invalid internal result for B" );
610620 goto cleanup ;
611621 }
612622
0 commit comments