<s> from __future__ import absolute_import , print_function , division <EOL> import os <EOL> import sys <EOL> import time <EOL> from optparse import OptionParser <EOL> import subprocess <EOL> import numpy <EOL> import theano <EOL> import theano . tensor as T <EOL> def execute ( execute = True , verbose = True , M = <NUM_LIT> , N = <NUM_LIT> , K = <NUM_LIT> , <EOL> iters = <NUM_LIT:10> , order = '<STR_LIT:C>' ) : <EOL> """<STR_LIT>""" <EOL> if verbose : <EOL> print ( '<STR_LIT>' ) <EOL> print ( '<STR_LIT>' , theano . config . blas . ldflags ) <EOL> print ( '<STR_LIT>' , theano . config . compiledir ) <EOL> print ( '<STR_LIT>' , theano . config . floatX ) <EOL> print ( '<STR_LIT>' , theano . config . device ) <EOL> print ( '<STR_LIT>' ) <EOL> print ( '<STR_LIT>' , sys . platform ) <EOL> print ( '<STR_LIT>' , sys . version ) <EOL> print ( '<STR_LIT>' , sys . prefix ) <EOL> print ( '<STR_LIT>' ) <EOL> print ( '<STR_LIT>' , os . getenv ( '<STR_LIT>' ) ) <EOL> print ( '<STR_LIT>' , os . getenv ( '<STR_LIT>' ) ) <EOL> print ( '<STR_LIT>' , os . getenv ( '<STR_LIT>' ) ) <EOL> print ( ) <EOL> print ( '<STR_LIT>' <EOL> '<STR_LIT>' ) <EOL> numpy . show_config ( ) <EOL> print ( '<STR_LIT>' , numpy . dot . __module__ ) <EOL> print ( '<STR_LIT>' , numpy . __file__ ) <EOL> print ( '<STR_LIT>' , numpy . __version__ ) <EOL> if ( theano . config . device . startswith ( "<STR_LIT>" ) or <EOL> theano . config . init_gpu_device . startswith ( "<STR_LIT>" ) ) : <EOL> print ( '<STR_LIT>' ) <EOL> subprocess . call ( ( theano . sandbox . cuda . nvcc_compiler . nvcc_path , <EOL> "<STR_LIT>" ) ) <EOL> print ( ) <EOL> a = theano . shared ( numpy . ones ( ( M , N ) , dtype = theano . config . floatX , <EOL> order = order ) ) <EOL> b = theano . shared ( numpy . ones ( ( N , K ) , dtype = theano . config . floatX , <EOL> order = order ) ) <EOL> c = theano . shared ( numpy . ones ( ( M , K ) , dtype = theano . config . floatX , <EOL> order = order ) ) <EOL> f = theano . function ( [ ] , updates = [ ( c , <NUM_LIT> * c + <NUM_LIT> * T . dot ( a , b ) ) ] ) <EOL> if any ( [ x . op . __class__ . __name__ == '<STR_LIT>' for x in <EOL> f . maker . fgraph . toposort ( ) ] ) : <EOL> c_impl = [ hasattr ( thunk , '<STR_LIT>' ) <EOL> for node , thunk in zip ( f . fn . nodes , f . fn . thunks ) <EOL> if node . op . __class__ . __name__ == "<STR_LIT>" ] <EOL> assert len ( c_impl ) == <NUM_LIT:1> <EOL> if c_impl [ <NUM_LIT:0> ] : <EOL> impl = '<STR_LIT>' <EOL> else : <EOL> impl = '<STR_LIT>' <EOL> elif any ( [ x . op . __class__ . __name__ == '<STR_LIT>' for x in <EOL> f . maker . fgraph . toposort ( ) ] ) : <EOL> impl = '<STR_LIT>' <EOL> else : <EOL> impl = '<STR_LIT>' <EOL> impl += str ( f . maker . fgraph . toposort ( ) ) <EOL> t0 = <NUM_LIT:0> <EOL> t1 = - <NUM_LIT:1> <EOL> if execute : <EOL> sync = ( hasattr ( theano , "<STR_LIT>" ) and <EOL> hasattr ( theano . sandbox , "<STR_LIT>" ) and <EOL> theano . sandbox . cuda . cuda_available ) <EOL> t0 = time . time ( ) <EOL> for i in range ( iters ) : <EOL> f ( ) <EOL> if sync : <EOL> theano . sandbox . cuda . synchronize ( ) <EOL> t1 = time . time ( ) <EOL> return t1 - t0 , impl <EOL> def jobman_job ( state , channel ) : <EOL> execute ( ) <EOL> return channel . COMPLETE <EOL> def test ( ) : <EOL> return execute ( ) <EOL> parser = OptionParser ( <EOL> usage = '<STR_LIT>' <EOL> '<STR_LIT>' ) <EOL> parser . add_option ( '<STR_LIT>' , '<STR_LIT>' , action = '<STR_LIT:store_true>' , dest = '<STR_LIT>' , <EOL> default = False , <EOL> help = "<STR_LIT>" <EOL> "<STR_LIT>" ) <EOL> parser . add_option ( '<STR_LIT>' , action = '<STR_LIT:store_true>' , dest = '<STR_LIT>' , <EOL> default = False , <EOL> help = "<STR_LIT>" ) <EOL> parser . add_option ( '<STR_LIT>' , '<STR_LIT>' , action = '<STR_LIT:store>' , dest = '<STR_LIT:M>' , <EOL> default = <NUM_LIT:0> , type = "<STR_LIT:int>" , <EOL> help = "<STR_LIT>" ) <EOL> parser . add_option ( '<STR_LIT>' , '<STR_LIT>' , action = '<STR_LIT:store>' , dest = '<STR_LIT:N>' , <EOL> default = <NUM_LIT:0> , type = "<STR_LIT:int>" , <EOL> help = "<STR_LIT>" ) <EOL> parser . add_option ( '<STR_LIT>' , '<STR_LIT>' , action = '<STR_LIT:store>' , dest = '<STR_LIT>' , <EOL> default = <NUM_LIT:0> , type = "<STR_LIT:int>" , <EOL> help = "<STR_LIT>" ) <EOL> parser . add_option ( '<STR_LIT>' , action = '<STR_LIT:store>' , dest = '<STR_LIT>' , <EOL> default = <NUM_LIT:10> , type = "<STR_LIT:int>" , <EOL> help = "<STR_LIT>" ) <EOL> parser . add_option ( '<STR_LIT>' , action = '<STR_LIT:store>' , dest = '<STR_LIT>' , <EOL> default = "<STR_LIT:C>" , <EOL> help = "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" ) <EOL> parser . add_option ( '<STR_LIT>' , '<STR_LIT>' , action = '<STR_LIT:store>' , dest = '<STR_LIT:B>' , <EOL> default = <NUM_LIT> , type = "<STR_LIT:int>" , <EOL> help = "<STR_LIT>" ) <EOL> if __name__ == "<STR_LIT:__main__>" : <EOL> options , arguments = parser . parse_args ( sys . argv ) <EOL> if hasattr ( options , "<STR_LIT>" ) : <EOL> print ( options . help ) <EOL> sys . exit ( <NUM_LIT:0> ) <EOL> if not options . quiet : <EOL> print ( """<STR_LIT>""" ) <EOL> if options . M == <NUM_LIT:0> : <EOL> M = options . B <EOL> else : <EOL> M = options . M <EOL> if options . N == <NUM_LIT:0> : <EOL> N = options . B <EOL> else : <EOL> N = options . N <EOL> if options . K == <NUM_LIT:0> : <EOL> K = options . B <EOL> else : <EOL> K = options . K <EOL> t , impl = execute ( not options . print_only , not options . quiet , <EOL> M = M , N = N , K = K , iters = options . iter , <EOL> order = options . order ) <EOL> if options . print_only : <EOL> pass <EOL> elif options . quiet : <EOL> print ( t ) <EOL> else : <EOL> print ( ) <EOL> print ( "<STR_LIT>" , options . iter , end = '<STR_LIT:U+0020>' ) <EOL> print ( "<STR_LIT>" , end = '<STR_LIT:U+0020>' ) <EOL> print ( "<STR_LIT>" % ( M , N , N , K ) ) <EOL> print ( ) <EOL> print ( '<STR_LIT>' % ( t , impl ) ) <EOL> print ( ) <EOL> print ( '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' ) </s>
