33#include "gpuarray/buffer_blas.h"
44#include "gpuarray/types.h"
55#include "gpuarray/util.h"
6- #include "gpuarray/error.h"
6+
7+ #include "private.h"
8+ #include "util/error.h"
79
810int GpuArray_rdot (GpuArray * X , GpuArray * Y ,
911 GpuArray * Z , int nocopy ) {
@@ -13,24 +15,28 @@ int GpuArray_rdot(GpuArray *X, GpuArray *Y,
1315 GpuArray copyY ;
1416 GpuArray * Zp = Z ;
1517 size_t n ;
16- void * ctx ;
18+ gpucontext * ctx = gpudata_context ( Xp -> data ) ;
1719 size_t elsize ;
1820 int err ;
1921
2022 if (X -> typecode != GA_HALF &&
2123 X -> typecode != GA_FLOAT &&
2224 X -> typecode != GA_DOUBLE )
23- return GA_INVALID_ERROR ;
25+ return error_set ( ctx -> err , GA_INVALID_ERROR , "Data type not supported" ) ;
2426
2527 if (X -> nd != 1 || Y -> nd != 1 || Z -> nd != 0 ||
2628 X -> typecode != Y -> typecode || X -> typecode != Z -> typecode )
27- return GA_VALUE_ERROR ;
29+ 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)" ,
31+ X -> nd , Y -> nd , Z -> nd );
2832 n = X -> dimensions [0 ];
2933 if (!(X -> flags & GA_ALIGNED ) || !(Y -> flags & GA_ALIGNED ) ||
3034 !(Z -> flags & GA_ALIGNED ))
3135 return GA_UNALIGNED_ERROR ;
3236 if (X -> dimensions [0 ] != Y -> dimensions [0 ])
33- return GA_VALUE_ERROR ;
37+ return error_fmt (ctx -> err , GA_VALUE_ERROR ,
38+ "Shape mismatch: X->dimensions[0] = %d != Y->dimensions[0] = %d" ,
39+ X -> dimensions [0 ], Y -> dimensions [0 ]);
3440
3541 elsize = gpuarray_get_elsize (X -> typecode );
3642 if (X -> strides [0 ] < 0 ) {
@@ -49,12 +55,11 @@ int GpuArray_rdot(GpuArray *X, GpuArray *Y,
4955 else {
5056 err = GpuArray_copy (& copyY , Y , GA_ANY_ORDER );
5157 if (err != GA_NO_ERROR )
52- goto cleanup ;
58+ goto cleanup ;
5359 Yp = & copyY ;
5460 }
5561 }
5662
57- ctx = gpudata_context (Xp -> data );
5863 err = gpublas_setup (ctx );
5964 if (err != GA_NO_ERROR )
6065 goto cleanup ;
@@ -138,7 +143,7 @@ int GpuArray_rgemv(cb_transpose transA, double alpha, GpuArray *A,
138143 else {
139144 err = GpuArray_copy (& copyA , A , GA_F_ORDER );
140145 if (err != GA_NO_ERROR )
141- goto cleanup ;
146+ goto cleanup ;
142147 Ap = & copyA ;
143148 }
144149 }
@@ -148,7 +153,7 @@ int GpuArray_rgemv(cb_transpose transA, double alpha, GpuArray *A,
148153 else {
149154 err = GpuArray_copy (& copyX , X , GA_ANY_ORDER );
150155 if (err != GA_NO_ERROR )
151- goto cleanup ;
156+ goto cleanup ;
152157 Xp = & copyX ;
153158 }
154159 }
0 commit comments