@@ -36,6 +36,11 @@ protected function useMath(Buffer $X)
36
36
return $ this ->forceMath || in_array ($ X ->dtype (),$ this ->floatTypes );
37
37
}
38
38
39
+ public function logging ($ message )
40
+ {
41
+ fwrite (STDERR ,$ message ."\n" );
42
+ }
43
+
39
44
protected function math_copy (
40
45
int $ n ,
41
46
Buffer $ X , int $ offsetX , int $ incX ,
@@ -908,6 +913,8 @@ public function gather(
908
913
throw new RuntimeException ('Matrix A specification too large for buffer. ' );
909
914
if ($ offsetB +$ n *$ k >count ($ B ))
910
915
throw new RuntimeException ('Matrix B specification too large for buffer. ' );
916
+ if ($ numClass <=0 )
917
+ throw new RuntimeException ('numClass must be grator than zero. ' );
911
918
912
919
$ idxX = $ offsetX ;
913
920
$ idxA = $ offsetA ;
@@ -916,8 +923,10 @@ public function gather(
916
923
for ($ j =0 ;$ j <$ n ;$ j ++) {
917
924
$ index = $ X [$ idxX +$ j ];
918
925
if ($ index >=$ numClass ) {
919
- throw new RuntimeException ("index is out of range.: " .$ index );
920
- }
926
+ //throw new RuntimeException("index is out of range.:".$index);
927
+ $ this ->logging ("gather: index is out of range.: " .$ index ." numClass= " .$ numClass );
928
+ $ index = $ numClass -1 ;
929
+ }
921
930
$ iA = $ idxA +$ index *$ ldIndex ;
922
931
$ iB = $ idxB +$ j *$ k ;
923
932
if ($ reverse ) {
@@ -970,6 +979,8 @@ public function reduceGather(
970
979
throw new RuntimeException ('Matrix A specification too large for buffer. ' );
971
980
if ($ offsetB +$ m *$ n >count ($ B ))
972
981
throw new RuntimeException ('Matrix B specification too large for buffer. ' );
982
+ if ($ numClass <=0 )
983
+ throw new RuntimeException ('numClass must be grator than zero. ' );
973
984
974
985
$ idxX = $ offsetX ;
975
986
$ idxA = $ offsetA ;
@@ -982,7 +993,9 @@ public function reduceGather(
982
993
for ($ j =0 ;$ j <$ n ;$ j ++) {
983
994
$ index = $ X [$ idxX +$ j ];
984
995
if ($ index >=$ numClass ) {
985
- throw new RuntimeException ("index is out of range.: " .$ index );
996
+ //throw new RuntimeException("index is out of range.:".$index);
997
+ $ this ->logging ("reduceGather: index is out of range.: " .$ index ." numClass= " .$ numClass );
998
+ $ index = $ numClass -1 ;
986
999
}
987
1000
$ iA = $ idxA +$ j +$ index *$ ldIndex ;
988
1001
$ iB = $ idxB +$ j ;
0 commit comments