def test_advinc_subtensor1():
 for shp in [(3, 3), (3, 3, 3)]:
  shared = cuda.shared_constructor
  xval = (numpy.arange(numpy.prod(shp), dtype='float32').reshape(shp) + 1)
  yval = numpy.empty(((2,) + shp[1:]), dtype='float32')
  yval[:] = 10
  x = shared(xval, name='x')
  y = T.tensor(dtype='float32', broadcastable=((False,) * len(shp)), name='y')
  expr = T.advanced_inc_subtensor1(x, y, [0, 2])
  f = theano.function([y], expr, mode=mode_with_gpu)
  assert (sum([isinstance(node.op, cuda.GpuAdvancedIncSubtensor1) for node in f.maker.fgraph.toposort()]) == 1)
  rval = f(yval)
  rep = xval.copy()
  rep[[0, 2]] += yval
  utt.assert_allclose(rval, rep)

def test_advinc_subtensor1 ( ) : for shp in [ ( 3 , 3 ) , ( 3 , 3 , 3 ) ] : shared = cuda . shared_constructor xval = ( numpy . arange ( numpy . prod ( shp ) , dtype = 'float32' ) . reshape ( shp ) + 1 ) yval = numpy . empty ( ( ( 2 , ) + shp [ 1 : ] ) , dtype = 'float32' ) yval [ : ] = 10 x = shared ( xval , name = 'x' ) y = T . tensor ( dtype = 'float32' , broadcastable = ( ( False , ) * len ( shp ) ) , name = 'y' ) expr = T . advanced_inc_subtensor1 ( x , y , [ 0 , 2 ] ) f = theano . function ( [ y ] , expr , mode = mode_with_gpu ) assert ( sum ( [ isinstance ( node . op , cuda . GpuAdvancedIncSubtensor1 ) for node in f . maker . fgraph . toposort ( ) ] ) == 1 ) rval = f ( yval ) rep = xval . copy ( ) rep [ [ 0 , 2 ] ] += yval utt . assert_allclose ( rval , rep )
test the second case in the opt local_gpu_advanced_incsubtensor1 .