#NEWLINE# def forward_gpu( self , x ) : #NEWLINE# #INDENT# if ( cuda . cudnn_enabled and self . use_cudnn ) : #NEWLINE# #INDENT# return super ( AveragePooling2D , self ) . forward_gpu ( x ) #NEWLINE# #UNINDENT# ( n , c , h , w ) = x [ 0 ] . shape #NEWLINE# y_h = conv . get_conv_outsize ( h , self . kh , self . sy , self . ph ) #NEWLINE# y_w = conv . get_conv_outsize ( w , self . kw , self . sx , self . pw ) #NEWLINE# y = cuda . cupy . empty ( ( n , c , y_h , y_w ) , dtype = numpy . float32 ) #NEWLINE# coeff = ( 1.0 / ( self . kh * self . kw ) ) #NEWLINE# cuda . elementwise ( 'raw T in, int32 h, int32 w,int32 out_h, int32 out_w, int32 kh, int32 kw,int32 sy, int32 sx, int32 ph, int32 pw, T coeff' , 'T out' , '\n               int c0    = i / (out_h * out_w);\n               int out_y = i / out_w % out_h;\n               int out_x = i % out_w;\n               int in_y_0 = max(0, out_y * sy - ph);\n               int in_y_1 = min(h, out_y * sy + kh - ph);\n               int in_x_0 = max(0, out_x * sx - pw);\n               int in_x_1 = min(w, out_x * sx + kw - pw);\n\n               float val = 0;\n               for (int y = in_y_0; y < in_y_1; ++y) {\n                 int offset_y = w * (y + h * c0);\n                 for (int x = in_x_0; x < in_x_1; ++x) {\n                   val += in[x + offset_y];\n                 }\n               }\n               out = val * coeff;\n            ' , 'avg_pool_fwd' ) ( x [ 0 ] . reduced_view ( ) , h , w , y_h , y_w , self . kh , self . kw , self . sy , self . sx , self . ph , self . pw , coeff , y ) #NEWLINE# return ( y , )