#NEWLINE# def softmax_with_bias_unittest_template( dtypeInput , dtypeBias ) : #NEWLINE# #INDENT# '\n    This is a basic test for GpuSoftmaxWithBias.\n\n    We check that we loop when there are too many blocks.\n\n    TODO: check that we loop when there are too many threads. (THIS IS\n    NOT IMPLEMENTED)\n\n    ' #NEWLINE# x = T . matrix ( 'x' , dtype = dtypeInput ) #NEWLINE# b = T . vector ( 'b' , dtype = x ) #NEWLINE# z = T . nnet . softmax_with_bias ( x , b ) #NEWLINE# f = theano . function ( [ x , b ] , z , mode = mode_without_gpu ) #NEWLINE# f_gpu = theano . function ( [ x , b ] , z , mode = mode_with_gpu ) #NEWLINE# assert ( f . maker . fgraph . toposort ( ) [ ( - 1 ) ] . op == T . nnet . softmax_with_bias ) #NEWLINE# assert isinstance ( f_gpu . maker . fgraph . toposort ( ) [ ( - 2 ) ] . op , GpuSoftmaxWithBias ) #NEWLINE# def cmp( n , m ) : #NEWLINE# #INDENT# data = numpy . random . uniform ( 1e-07 , 1 , ( n , m ) ) . astype ( dtype = dtypeInput ) #NEWLINE# b_data = numpy . random . uniform ( 1e-07 , 1 , ( m , ) ) . astype ( dtype = dtypeBias ) #NEWLINE# out = f ( data , b_data ) #NEWLINE# gout = f_gpu ( data , b_data ) #NEWLINE# utt . assert_allclose ( out , gout ) #NEWLINE# #UNINDENT# cmp ( 2 , 5 ) #NEWLINE# cmp ( ( 2 << 15 ) , 5 ) #NEWLINE# cmp ( 4074 , 400 ) #NEWLINE# cmp ( 784 , 784 ) #NEWLINE# cmp ( 4 , 1000 ) #NEWLINE# cmp ( 4 , 1024 ) #NEWLINE# cmp ( 4 , 2000 ) #NEWLINE# cmp ( 4 , 2024 ) #NEWLINE# cmp ( 4 , 4074 ) #NEWLINE# cmp ( 2 , 10000 ) #NEWLINE# cmp ( 128 , ( 16 * 1024 ) ) #NEWLINE# cmp ( 128 , ( 64 * 1024 ) )