#NEWLINE# def test_dnn_tag( ) : #NEWLINE# #INDENT# "\n    Test that if cudnn isn't avail we crash and that if it is avail, we use it.\n    " #NEWLINE# x = T . ftensor4 ( ) #NEWLINE# old = theano . config . on_opt_error #NEWLINE# theano . config . on_opt_error = 'raise' #NEWLINE# sio = StringIO ( ) #NEWLINE# handler = logging . StreamHandler ( sio ) #NEWLINE# logging . getLogger ( 'theano.compile.tests.test_dnn' ) . addHandler ( handler ) #NEWLINE# logging . getLogger ( 'theano' ) . removeHandler ( theano . logging_default_handler ) #NEWLINE# raised = False #NEWLINE# try : #NEWLINE# #INDENT# f = theano . function ( [ x ] , pool_2d ( f , ds = ( 2 , 2 ) , ignore_border = True ) , mode = mode_with_gpu . including ( 'cudnn' ) ) #NEWLINE# #UNINDENT# except ( AssertionError , RuntimeError ) : #NEWLINE# #INDENT# assert ( not dnn . dnn_available ( test_ctx_name ) ) #NEWLINE# raised = True #NEWLINE# #UNINDENT# finally : #NEWLINE# #INDENT# theano . config . on_opt_error = old #NEWLINE# logging . getLogger ( 'theano.compile.tests.test_dnn' ) . removeHandler ( handler ) #NEWLINE# logging . getLogger ( 'theano' ) . addHandler ( theano . logging_default_handler ) #NEWLINE# #UNINDENT# if ( not raised ) : #NEWLINE# #INDENT# assert dnn . dnn_available ( test_ctx_name ) #NEWLINE# assert any ( [ isinstance ( n . op , dnn . GpuDnnPool ) for n in f . maker . fgraph . toposort ( ) ] )