<s> from __future__ import absolute_import , print_function , division <EOL> import numpy <EOL> import theano <EOL> from theano import tensor <EOL> from theano . tests . breakpoint import PdbBreakpoint <EOL> from theano . tests import unittest_tools as utt , test_ifelse <EOL> from theano . tensor . tests import test_basic <EOL> import theano . sandbox . gpuarray <EOL> from . . import basic_ops <EOL> from . . type import GpuArrayType , gpuarray_shared_constructor , get_context <EOL> from . . basic_ops import ( <EOL> GpuAlloc , GpuAllocEmpty , GpuReshape , GpuFromHost , host_from_gpu ) <EOL> from . . blas import GpuGemm <EOL> from . . elemwise import GpuCAReduceCuda , GpuCAReduceCPY , GpuElemwise <EOL> from . . subtensor import GpuSubtensor <EOL> from . config import mode_with_gpu , test_ctx_name <EOL> def test_local_assert ( ) : <EOL> x = theano . tensor . fmatrix ( ) <EOL> a = theano . tensor . opt . assert_op ( x , theano . tensor . eq ( x , <NUM_LIT:0> ) . any ( ) ) <EOL> f = theano . function ( [ x ] , a , mode = mode_with_gpu ) <EOL> topo = f . maker . fgraph . toposort ( ) <EOL> a_op = [ n for n in topo if isinstance ( n . op , theano . tensor . opt . Assert ) ] <EOL> assert len ( a_op ) == <NUM_LIT:1> <EOL> assert isinstance ( a_op [ <NUM_LIT:0> ] . inputs [ <NUM_LIT:0> ] . type , GpuArrayType ) <EOL> def test_local_remove_all_assert ( ) : <EOL> x = theano . tensor . fmatrix ( ) <EOL> a = theano . tensor . opt . assert_op ( x , theano . tensor . eq ( x , <NUM_LIT:0> ) . any ( ) ) <EOL> f = theano . function ( [ x ] , a , mode = mode_with_gpu . excluding ( '<STR_LIT>' ) ) <EOL> topo = f . maker . fgraph . toposort ( ) <EOL> a_op = [ n for n in topo if isinstance ( n . op , theano . tensor . opt . Assert ) ] <EOL> assert len ( a_op ) == <NUM_LIT:1> <EOL> f = theano . function ( [ x ] , a , mode = mode_with_gpu . including ( '<STR_LIT>' ) ) <EOL> topo = f . maker . fgraph . toposort ( ) <EOL> a_op = [ n for n in topo if isinstance ( n . op , theano . tensor . opt . Assert ) ] <EOL> assert len ( a_op ) == <NUM_LIT:0> <EOL> f = theano . function ( [ x ] , a , mode = mode_with_gpu . excluding ( '<STR_LIT>' ) ) <EOL> topo = f . maker . fgraph . toposort ( ) <EOL> a_op = [ n for n in topo if isinstance ( n . op , theano . tensor . opt . Assert ) ] <EOL> assert len ( a_op ) == <NUM_LIT:1> <EOL> def test_local_gpu_contiguous_gpu_contiguous ( ) : <EOL> a = tensor . fmatrix ( ) <EOL> o1 = basic_ops . gpu_contiguous ( a ) <EOL> o2 = basic_ops . gpu_contiguous ( o1 ) <EOL> f1 = theano . function ( [ a ] , o1 , mode = mode_with_gpu ) <EOL> f2 = theano . function ( [ a ] , o2 , mode = mode_with_gpu ) <EOL> assert <NUM_LIT:1> == len ( [ node for node in f1 . maker . fgraph . toposort ( ) <EOL> if isinstance ( node . op , basic_ops . GpuContiguous ) ] ) <EOL> assert <NUM_LIT:1> == len ( [ node for node in f2 . maker . fgraph . toposort ( ) <EOL> if isinstance ( node . op , basic_ops . GpuContiguous ) ] ) <EOL> def test_local_gpu_contiguous ( ) : <EOL> a = tensor . fmatrix ( ) <EOL> o = tensor . extra_ops . cpu_contiguous ( a ) <EOL> f = theano . function ( [ a ] , o , mode = mode_with_gpu ) <EOL> assert <NUM_LIT:1> == len ( [ node for node in f . maker . fgraph . toposort ( ) <EOL> if isinstance ( node . op , basic_ops . GpuContiguous ) ] ) <EOL> f ( [ [ <NUM_LIT> ] ] ) <EOL> def test_flatten ( ) : <EOL> m = theano . tensor . fmatrix ( ) <EOL> f = theano . function ( [ m ] , m . flatten ( ) , mode = mode_with_gpu ) <EOL> val = numpy . random . rand ( <NUM_LIT:10> , <NUM_LIT:11> ) . astype ( "<STR_LIT>" ) <EOL> res = f ( val ) <EOL> utt . assert_allclose ( res , val . flatten ( ) ) <EOL> assert res . shape == val . flatten ( ) . shape <EOL> assert GpuReshape in [ type ( node . op ) <EOL> for node in f . maker . fgraph . toposort ( ) ] <EOL> val = numpy . random . rand ( <NUM_LIT:10> , <NUM_LIT:11> ) . astype ( "<STR_LIT>" ) <EOL> res = f ( val ) <EOL> utt . assert_allclose ( res , val . flatten ( ) ) <EOL> assert res . shape == val . flatten ( ) . shape <EOL> assert GpuReshape in [ type ( node . op ) <EOL> for node in f . maker . fgraph . toposort ( ) ] <EOL> f = theano . function ( [ m ] , m . flatten ( ndim = <NUM_LIT:2> ) , mode = mode_with_gpu ) <EOL> val = numpy . random . rand ( <NUM_LIT:10> , <NUM_LIT:11> ) . astype ( "<STR_LIT>" ) <EOL> res = f ( val ) <EOL> utt . assert_allclose ( res , val ) <EOL> assert res . shape == val . shape <EOL> assert GpuReshape in [ type ( node . op ) <EOL> for node in f . maker . fgraph . toposort ( ) ] <EOL> m = theano . tensor . tensor3 ( ) <EOL> f = theano . function ( [ m ] , m . flatten ( ndim = <NUM_LIT:2> ) , mode = mode_with_gpu ) <EOL> val = numpy . random . rand ( <NUM_LIT:10> , <NUM_LIT:11> , <NUM_LIT:12> ) . astype ( "<STR_LIT>" ) <EOL> res = f ( val ) <EOL> utt . assert_allclose ( res , val . reshape ( <NUM_LIT:10> , - <NUM_LIT:1> ) ) <EOL> assert res . shape == val . reshape ( <NUM_LIT:10> , - <NUM_LIT:1> ) . shape <EOL> assert GpuReshape in [ type ( node . op ) <EOL> for node in f . maker . fgraph . toposort ( ) ] <EOL> def test_reduce ( ) : <EOL> kind = get_context ( test_ctx_name ) . kind <EOL> for method , param in [ ( '<STR_LIT>' , dict ( acc_dtype = '<STR_LIT>' ) ) , <EOL> ( '<STR_LIT>' , dict ( acc_dtype = '<STR_LIT>' ) ) , <EOL> ( '<STR_LIT>' , { } ) , ( '<STR_LIT>' , { } ) ] : <EOL> m = theano . tensor . fmatrix ( ) <EOL> f = theano . function ( [ m ] , getattr ( m , method ) ( axis = <NUM_LIT:0> , <EOL> ** param ) , <EOL> mode = mode_with_gpu ) <EOL> val = numpy . random . rand ( <NUM_LIT:10> , <NUM_LIT:11> ) . astype ( "<STR_LIT>" ) <EOL> res = f ( val ) <EOL> utt . assert_allclose ( res , getattr ( val , method ) ( axis = <NUM_LIT:0> ) ) <EOL> assert res . shape == ( <NUM_LIT:11> , ) <EOL> topo = f . maker . fgraph . toposort ( ) <EOL> ops = [ type ( node . op ) for node in topo ] <EOL> if kind == '<STR_LIT>' and method in [ "<STR_LIT>" , "<STR_LIT>" ] : <EOL> assert not ( GpuCAReduceCuda in ops or GpuCAReduceCPY in ops ) <EOL> else : <EOL> assert GpuCAReduceCuda in ops or GpuCAReduceCPY in ops <EOL> def test_local_gpualloc_memset_0 ( ) : <EOL> i = theano . tensor . iscalar ( ) <EOL> z = numpy . zeros ( ( <NUM_LIT:1> , ) , dtype = '<STR_LIT>' ) <EOL> o = numpy . ones ( ( <NUM_LIT:1> , ) , dtype = '<STR_LIT>' ) <EOL> ones = numpy . ones ( ( <NUM_LIT:2> , ) , dtype = '<STR_LIT>' ) <EOL> a = tensor . alloc ( z , i ) <EOL> f = theano . function ( [ i ] , a , mode = mode_with_gpu ) <EOL> topo = f . maker . fgraph . toposort ( ) <EOL> assert len ( topo ) == <NUM_LIT:2> <EOL> assert isinstance ( topo [ <NUM_LIT:0> ] . op , GpuAlloc ) and topo [ <NUM_LIT:0> ] . op . memset_0 <EOL> assert ( numpy . asarray ( f ( <NUM_LIT:6> ) ) == <NUM_LIT:0> ) . all ( ) <EOL> a = GpuAlloc ( test_ctx_name ) ( z , i ) <EOL> f = theano . function ( [ i ] , a , mode = mode_with_gpu ) <EOL> topo = f . maker . fgraph . toposort ( ) <EOL> assert len ( topo ) == <NUM_LIT:1> <EOL> assert isinstance ( topo [ <NUM_LIT:0> ] . op , GpuAlloc ) and topo [ <NUM_LIT:0> ] . op . memset_0 <EOL> assert ( numpy . asarray ( f ( <NUM_LIT:6> ) ) == <NUM_LIT:0> ) . all ( ) <EOL> a = GpuAlloc ( test_ctx_name ) ( o , i ) <EOL> f = theano . function ( [ i ] , a , mode = mode_with_gpu ) <EOL> topo = f . maker . fgraph . toposort ( ) <EOL> assert len ( topo ) == <NUM_LIT:1> <EOL> assert isinstance ( topo [ <NUM_LIT:0> ] . op , GpuAlloc ) <EOL> assert not topo [ <NUM_LIT:0> ] . op . memset_0 <EOL> assert ( numpy . asarray ( f ( <NUM_LIT:6> ) ) == <NUM_LIT:1> ) . all ( ) <EOL> a = GpuAlloc ( test_ctx_name ) ( ones , i ) <EOL> f = theano . function ( [ i ] , a , mode = mode_with_gpu ) <EOL> topo = f . maker . fgraph . toposort ( ) <EOL> assert len ( topo ) == <NUM_LIT:1> <EOL> assert isinstance ( topo [ <NUM_LIT:0> ] . op , GpuAlloc ) <EOL> assert not topo [ <NUM_LIT:0> ] . op . memset_0 <EOL> assert ( numpy . asarray ( f ( <NUM_LIT:2> ) ) == <NUM_LIT:1> ) . all ( ) <EOL> def test_local_gpualloc_empty ( ) : <EOL> i = theano . tensor . iscalar ( ) <EOL> ii = theano . tensor . iscalar ( ) <EOL> a = tensor . AllocEmpty ( '<STR_LIT>' ) ( i ) <EOL> f = theano . function ( [ i ] , a , mode = mode_with_gpu ) <EOL> topo = f . maker . fgraph . toposort ( ) <EOL> assert len ( topo ) == <NUM_LIT:2> <EOL> assert isinstance ( topo [ <NUM_LIT:0> ] . op , GpuAllocEmpty ) <EOL> assert f ( <NUM_LIT:3> ) . shape == ( <NUM_LIT:3> , ) <EOL> a = tensor . AllocEmpty ( '<STR_LIT>' ) ( i , ii ) <EOL> f = theano . function ( [ i , ii ] , a , mode = mode_with_gpu ) <EOL> topo = f . maker . fgraph . toposort ( ) <EOL> assert len ( topo ) == <NUM_LIT:2> <EOL> assert isinstance ( topo [ <NUM_LIT:0> ] . op , GpuAllocEmpty ) <EOL> assert f ( <NUM_LIT:3> , <NUM_LIT:4> ) . shape == ( <NUM_LIT:3> , <NUM_LIT:4> ) <EOL> def test_rebroadcast ( ) : <EOL> d = numpy . random . rand ( <NUM_LIT:10> , <NUM_LIT:10> ) . astype ( '<STR_LIT>' ) <EOL> v = theano . tensor . fmatrix ( ) <EOL> up = tensor . unbroadcast ( v . sum ( ) . dimshuffle ( '<STR_LIT:x>' , '<STR_LIT:x>' ) , <NUM_LIT:0> , <NUM_LIT:1> ) <EOL> f = theano . function ( [ v ] , [ up ] , mode = mode_with_gpu ) <EOL> f ( d ) <EOL> topo = f . maker . fgraph . toposort ( ) <EOL> rebrs = [ node for node in topo if isinstance ( node . op , tensor . Rebroadcast ) ] <EOL> assert len ( rebrs ) == <NUM_LIT:1> <EOL> rebr = rebrs [ <NUM_LIT:0> ] <EOL> assert isinstance ( rebr . inputs [ <NUM_LIT:0> ] . type , GpuArrayType ) <EOL> assert isinstance ( rebr . outputs [ <NUM_LIT:0> ] . type , GpuArrayType ) <EOL> class TestSpecifyShape ( test_basic . TestSpecifyShape ) : <EOL> mode = mode_with_gpu <EOL> input_type = GpuArrayType <EOL> class test_gpu_ifelse ( test_ifelse . test_ifelse ) : <EOL> mode = mode_with_gpu <EOL> @ staticmethod <EOL> def cast_output ( v ) : <EOL> return basic_ops . as_gpuarray_variable ( v , test_ctx_name ) <EOL> shared = staticmethod ( gpuarray_shared_constructor ) <EOL> def get_ifelse ( self , n ) : <EOL> return theano . ifelse . IfElse ( n , gpu = True , as_view = True ) <EOL> def test_print_op ( ) : <EOL> """<STR_LIT>""" <EOL> b = tensor . fmatrix ( ) <EOL> f = theano . function ( [ b ] , theano . printing . Print ( ) ( b ) * <NUM_LIT:2> , <EOL> mode = mode_with_gpu ) <EOL> topo = f . maker . fgraph . toposort ( ) <EOL> assert isinstance ( topo [ <NUM_LIT:0> ] . op , GpuFromHost ) <EOL> assert isinstance ( topo [ <NUM_LIT:1> ] . op , theano . printing . Print ) <EOL> assert isinstance ( topo [ <NUM_LIT:2> ] . op , GpuElemwise ) <EOL> assert topo [ <NUM_LIT:3> ] . op == host_from_gpu <EOL> f ( numpy . random . random ( ( <NUM_LIT:5> , <NUM_LIT:5> ) ) . astype ( '<STR_LIT>' ) ) <EOL> def test_pdbbreakpoint_op ( ) : <EOL> """<STR_LIT>""" <EOL> b = tensor . fmatrix ( ) <EOL> condition = tensor . gt ( b . sum ( ) , <NUM_LIT:0> ) <EOL> b_monitored = PdbBreakpoint ( name = '<STR_LIT>' ) ( condition , b ) <EOL> output = b_monitored ** <NUM_LIT:2> <EOL> f = theano . function ( [ b ] , output , mode = mode_with_gpu ) <EOL> topo = f . maker . fgraph . toposort ( ) <EOL> assert isinstance ( topo [ - <NUM_LIT:2> ] . op , GpuElemwise ) <EOL> assert topo [ - <NUM_LIT:1> ] . op == host_from_gpu <EOL> def test_local_gpu_elemwise_careduce ( ) : <EOL> x = theano . tensor . matrix ( ) <EOL> o = ( x * x ) . sum ( ) <EOL> f = theano . function ( [ x ] , o , mode = mode_with_gpu ) <EOL> topo = f . maker . fgraph . toposort ( ) <EOL> assert len ( topo ) == <NUM_LIT:3> <EOL> assert topo [ <NUM_LIT:1> ] . op . pre_scalar_op == theano . scalar . sqr <EOL> data = numpy . random . rand ( <NUM_LIT:3> , <NUM_LIT:4> ) . astype ( theano . config . floatX ) <EOL> utt . assert_allclose ( f ( data ) , ( data * data ) . sum ( ) ) <EOL> o = ( x * x ) . sum ( axis = <NUM_LIT:1> ) <EOL> f = theano . function ( [ x ] , o , mode = mode_with_gpu ) <EOL> topo = f . maker . fgraph . toposort ( ) <EOL> assert len ( topo ) == <NUM_LIT:3> <EOL> assert topo [ <NUM_LIT:1> ] . op . pre_scalar_op == theano . scalar . sqr <EOL> utt . assert_allclose ( f ( data ) , ( data * data ) . sum ( axis = <NUM_LIT:1> ) ) <EOL> def test_local_lift_dot22scalar ( ) : <EOL> x = tensor . matrix ( ) <EOL> y = tensor . matrix ( ) <EOL> a = tensor . scalar ( ) <EOL> o = tensor . blas . Dot22Scalar ( ) ( x , y , a ) <EOL> f_cpu = theano . function ( [ x , y , a ] , o ) <EOL> f_gpu = theano . function ( [ x , y , a ] , o , mode = mode_with_gpu ) <EOL> assert not any ( isinstance ( n . op , tensor . blas . Dot22Scalar ) <EOL> for n in f_gpu . maker . fgraph . apply_nodes ) <EOL> assert any ( isinstance ( n . op , GpuGemm ) <EOL> for n in f_gpu . maker . fgraph . apply_nodes ) <EOL> x_val = numpy . random . random ( ( <NUM_LIT:2> , <NUM_LIT:3> ) ) . astype ( theano . config . floatX ) <EOL> y_val = numpy . random . random ( ( <NUM_LIT:3> , <NUM_LIT:4> ) ) . astype ( theano . config . floatX ) <EOL> a_val = <NUM_LIT:0.5> <EOL> utt . assert_allclose ( f_cpu ( x_val , y_val , a_val ) , f_gpu ( x_val , y_val , a_val ) ) <EOL> def test_local_gpu_subtensor ( ) : <EOL> t = tensor . _shared ( numpy . zeros ( <NUM_LIT:20> , "<STR_LIT>" ) ) <EOL> f = theano . function ( [ ] , t [ <NUM_LIT:3> : <NUM_LIT:4> ] , mode = mode_with_gpu ) <EOL> topo = f . maker . fgraph . toposort ( ) <EOL> assert any ( [ type ( node . op ) is tensor . Subtensor for node in topo ] ) <EOL> assert not any ( [ isinstance ( node . op , GpuSubtensor ) for node in topo ] ) <EOL> t = tensor . fmatrix ( ) <EOL> f = theano . function ( [ t ] , t [ <NUM_LIT:3> : <NUM_LIT:4> ] , mode = mode_with_gpu ) <EOL> topo = f . maker . fgraph . toposort ( ) <EOL> assert any ( [ type ( node . op ) is tensor . Subtensor for node in topo ] ) <EOL> assert not any ( [ isinstance ( node . op , GpuSubtensor ) for node in topo ] ) <EOL> t = tensor . fmatrix ( ) <EOL> f = theano . function ( [ t ] , [ t [ <NUM_LIT:3> : <NUM_LIT:4> ] , t + <NUM_LIT:1> ] , mode = mode_with_gpu ) <EOL> topo = f . maker . fgraph . toposort ( ) <EOL> assert not any ( [ type ( node . op ) is tensor . Subtensor for node in topo ] ) <EOL> assert any ( [ isinstance ( node . op , GpuSubtensor ) for node in topo ] ) <EOL> t = tensor . fmatrix ( ) <EOL> f = theano . function ( [ t ] , [ t [ <NUM_LIT:3> : <NUM_LIT:4> ] , t + <NUM_LIT:1> , t ] , mode = mode_with_gpu ) <EOL> topo = f . maker . fgraph . toposort ( ) <EOL> assert not any ( [ type ( node . op ) is tensor . Subtensor for node in topo ] ) <EOL> assert any ( [ isinstance ( node . op , GpuSubtensor ) for node in topo ] ) <EOL> t = tensor . _shared ( numpy . zeros ( <NUM_LIT:20> , "<STR_LIT>" ) ) <EOL> f = theano . function ( [ ] , t [ <NUM_LIT:3> : <NUM_LIT:4> ] + <NUM_LIT:1> , mode = mode_with_gpu ) <EOL> topo = f . maker . fgraph . toposort ( ) <EOL> assert any ( [ type ( node . op ) is tensor . Subtensor for node in topo ] ) <EOL> assert not any ( [ isinstance ( node . op , GpuSubtensor ) for node in topo ] ) <EOL> assert any ( [ isinstance ( node . op , GpuElemwise ) for node in topo ] ) <EOL> def test_local_gpu_elemwise ( ) : <EOL> """<STR_LIT>""" <EOL> a = tensor . bmatrix ( ) <EOL> b = tensor . fmatrix ( ) <EOL> c = tensor . fmatrix ( ) <EOL> a_v = ( numpy . random . rand ( <NUM_LIT:4> , <NUM_LIT:5> ) * <NUM_LIT:10> ) . astype ( "<STR_LIT>" ) <EOL> b_v = ( numpy . random . rand ( <NUM_LIT:4> , <NUM_LIT:5> ) * <NUM_LIT:10> ) . astype ( "<STR_LIT>" ) <EOL> c_v = ( numpy . random . rand ( <NUM_LIT:4> , <NUM_LIT:5> ) * <NUM_LIT:10> ) . astype ( "<STR_LIT>" ) <EOL> f = theano . function ( [ a , b , c ] , a + b + c , mode = mode_with_gpu ) <EOL> topo = f . maker . fgraph . toposort ( ) <EOL> assert sum ( isinstance ( node . op , GpuElemwise ) for node in topo ) == <NUM_LIT:1> <EOL> assert sum ( type ( node . op ) == tensor . Elemwise for node in topo ) == <NUM_LIT:0> <EOL> utt . assert_allclose ( f ( a_v , b_v , c_v ) , a_v + b_v + c_v ) <EOL> a_s = theano . scalar . int8 ( ) <EOL> b_s = theano . scalar . float32 ( ) <EOL> c_s = theano . scalar . float32 ( ) <EOL> out_s = theano . scalar . Composite ( [ a_s , b_s , c_s ] , [ a_s + b_s + c_s ] ) <EOL> out_op = tensor . Elemwise ( out_s ) <EOL> f = theano . function ( [ a , b , c ] , out_op ( a , b , c ) , mode = mode_with_gpu ) <EOL> topo = f . maker . fgraph . toposort ( ) <EOL> assert sum ( isinstance ( node . op , GpuElemwise ) for node in topo ) == <NUM_LIT:1> <EOL> assert sum ( type ( node . op ) == tensor . Elemwise for node in topo ) == <NUM_LIT:0> <EOL> utt . assert_allclose ( f ( a_v , b_v , c_v ) , a_v + b_v + c_v ) <EOL> return <EOL> a_s = theano . scalar . float32 ( ) <EOL> a = tensor . fmatrix ( ) <EOL> from theano . scalar . basic import identity <EOL> out_s = theano . scalar . Composite ( [ a_s , b_s , c_s ] , <EOL> [ identity ( a_s ) , identity ( c_s ) , identity ( b_s ) ] ) <EOL> outs_op = tensor . Elemwise ( out_s ) <EOL> f = theano . function ( [ a , b , c ] , outs_op ( a , b , c ) , mode = mode_with_gpu ) <EOL> topo = f . maker . fgraph . toposort ( ) <EOL> assert sum ( isinstance ( node . op , GpuElemwise ) for node in topo ) == <NUM_LIT:1> <EOL> assert sum ( type ( node . op ) == tensor . Elemwise for node in topo ) == <NUM_LIT:0> <EOL> out = f ( a_v , b_v , c_v ) <EOL> utt . assert_allclose ( out [ <NUM_LIT:0> ] , a_v ) <EOL> utt . assert_allclose ( out [ <NUM_LIT:1> ] , c_v ) <EOL> utt . assert_allclose ( out [ <NUM_LIT:2> ] , b_v ) <EOL> out_s = theano . scalar . Composite ( [ a_s , b_s , c_s ] , [ a_s + b_s , a_s * b_s ] ) <EOL> outs_op = tensor . Elemwise ( out_s ) <EOL> f = theano . function ( [ a , b , c ] , outs_op ( a , b , c ) , mode = mode_with_gpu ) <EOL> topo = f . maker . fgraph . toposort ( ) <EOL> assert sum ( isinstance ( node . op , GpuElemwise ) for node in topo ) == <NUM_LIT:1> <EOL> assert sum ( type ( node . op ) == tensor . Elemwise for node in topo ) == <NUM_LIT:0> <EOL> out = f ( a_v , b_v , c_v ) <EOL> utt . assert_allclose ( out [ <NUM_LIT:0> ] , a_v + b_v ) <EOL> utt . assert_allclose ( out [ <NUM_LIT:1> ] , a_v * c_v ) <EOL> c = gpuarray_shared_constructor ( numpy . asarray ( c_v , dtype = '<STR_LIT>' ) ) <EOL> f = theano . function ( [ a , b ] , outs_op ( a [ : : <NUM_LIT:2> ] , b [ : : <NUM_LIT:2> ] , c [ : : <NUM_LIT:2> ] ) , <EOL> mode = mode_with_gpu ) <EOL> out = f ( a_v , b_v ) <EOL> utt . assert_allclose ( out [ <NUM_LIT:0> ] , a_v [ : : <NUM_LIT:2> ] + b_v [ : : <NUM_LIT:2> ] ) <EOL> utt . assert_allclose ( out [ <NUM_LIT:1> ] , a_v [ : : <NUM_LIT:2> ] * c_v [ : : <NUM_LIT:2> ] ) <EOL> def test_local_lift_abstractconv_gpu_shape ( ) : <EOL> prev = theano . config . on_opt_error <EOL> try : <EOL> theano . config . on_opt_error = '<STR_LIT>' <EOL> s = tensor . ivector ( ) <EOL> a = tensor . ftensor4 ( ) <EOL> b = tensor . ftensor4 ( ) <EOL> c = tensor . nnet . abstract_conv . AbstractConv2d_gradWeights ( ) ( a , b , s ) <EOL> theano . function ( [ s , a , b ] , c , mode = mode_with_gpu ) <EOL> finally : <EOL> theano . config . on_opt_error = prev </s>
