<s> from dsltools import Node <EOL> from expr import Expr <EOL> class Adverb ( Expr , Node ) : <EOL> _members = [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT:type>' , '<STR_LIT>' ] <EOL> def node_init ( self ) : <EOL> assert self . fn , "<STR_LIT>" % self <EOL> def functions ( self ) : <EOL> yield self . fn <EOL> class Accumulative ( Expr ) : <EOL> """<STR_LIT>""" <EOL> _members = [ '<STR_LIT>' , '<STR_LIT>' ] <EOL> class HasEmit ( Expr ) : <EOL> """<STR_LIT>""" <EOL> _members = [ '<STR_LIT>' ] <EOL> class IndexAdverb ( Adverb ) : <EOL> _members = [ '<STR_LIT>' , '<STR_LIT>' ] <EOL> class IndexMap ( IndexAdverb ) : <EOL> """<STR_LIT>""" <EOL> pass <EOL> class IndexAccumulative ( IndexAdverb , Accumulative ) : <EOL> pass <EOL> class IndexReduce ( IndexAccumulative ) : <EOL> """<STR_LIT>""" <EOL> pass <EOL> class IndexScan ( IndexAccumulative , HasEmit ) : <EOL> pass <EOL> class DataAdverb ( Adverb ) : <EOL> _members = [ '<STR_LIT:args>' , '<STR_LIT>' ] <EOL> def fn_to_str ( self , fn ) : <EOL> if hasattr ( fn , '<STR_LIT:name>' ) : <EOL> return fn . name <EOL> else : <EOL> return str ( fn ) <EOL> def args_to_str ( self ) : <EOL> if isinstance ( self . args , ( list , tuple ) ) : <EOL> return "<STR_LIT:U+002CU+0020>" . join ( [ str ( arg ) + "<STR_LIT::>" + str ( arg . type ) for arg in self . args ] ) <EOL> else : <EOL> return str ( self . args ) <EOL> def __repr__ ( self ) : <EOL> s = "<STR_LIT>" % ( self . node_type ( ) , self . axis , <EOL> self . args_to_str ( ) , <EOL> self . type , <EOL> self . fn_to_str ( self . fn ) , ) <EOL> return s <EOL> def __str__ ( self ) : <EOL> return repr ( self ) <EOL> class Map ( DataAdverb ) : <EOL> pass <EOL> class OuterMap ( DataAdverb ) : <EOL> pass <EOL> class DataAccumulative ( DataAdverb , Accumulative ) : <EOL> pass <EOL> class Reduce ( DataAccumulative ) : <EOL> def __repr__ ( self ) : <EOL> return "<STR_LIT>" % ( self . axis , <EOL> self . args_to_str ( ) , <EOL> self . type , <EOL> self . init , <EOL> self . fn_to_str ( self . fn ) , <EOL> self . fn_to_str ( self . combine ) ) <EOL> class Scan ( DataAccumulative , HasEmit ) : <EOL> def __repr__ ( self ) : <EOL> s = "<STR_LIT>" % ( self . node_type ( ) , self . axis , <EOL> self . args_to_str ( ) , <EOL> self . type <EOL> ) <EOL> s += "<STR_LIT>" % ( self . init , <EOL> self . fn_to_str ( self . fn ) , <EOL> self . fn_to_str ( self . combine ) , <EOL> self . fn_to_str ( self . emit ) ) <EOL> return s <EOL> class Filter ( DataAdverb ) : <EOL> """<STR_LIT>""" <EOL> _members = [ '<STR_LIT>' ] <EOL> class IndexFilter ( IndexAdverb , Filter ) : <EOL> pass <EOL> class FilterReduce ( Reduce , Filter ) : <EOL> """<STR_LIT>""" <EOL> pass <EOL> class IndexFilterReduce ( FilterReduce ) : <EOL> pass <EOL> class Tiled ( object ) : <EOL> _members = [ '<STR_LIT>' , '<STR_LIT>' ] <EOL> def __repr__ ( self ) : <EOL> s = "<STR_LIT>" % ( self . node_type ( ) , self . axes , <EOL> self . args_to_str ( ) , <EOL> self . type , <EOL> self . fn_to_str ( self . fn ) , ) <EOL> return s <EOL> class TiledMap ( Tiled , Map ) : <EOL> pass <EOL> class TiledOuterMap ( Tiled , OuterMap ) : <EOL> pass <EOL> class TiledReduce ( Tiled , Reduce ) : <EOL> def __repr__ ( self ) : <EOL> s = ( "<STR_LIT>" ) % ( self . node_type ( ) , self . axes , <EOL> self . args_to_str ( ) , <EOL> self . type , <EOL> self . init , <EOL> self . fn_to_str ( self . fn ) , <EOL> self . fn_to_str ( self . combine ) , <EOL> ) <EOL> return s <EOL> class TiledScan ( Tiled , Scan ) : <EOL> def __repr__ ( self ) : <EOL> s = "<STR_LIT>" % ( self . node_type ( ) , self . axes , <EOL> self . args_to_str ( ) , <EOL> self . type <EOL> ) <EOL> s += "<STR_LIT>" % ( self . init , <EOL> self . fn_to_str ( self . fn ) , <EOL> self . fn_to_str ( self . combine ) , <EOL> self . fn_to_str ( self . emit ) ) <EOL> return s <EOL> class Conv ( Adverb ) : <EOL> _members = [ '<STR_LIT:x>' , '<STR_LIT>' ] <EOL> def __repr__ ( self ) : <EOL> return "<STR_LIT>" % ( self . fn , self . x , self . window_shape ) <EOL> def __str__ ( self ) : <EOL> return repr ( self ) <EOL> class ConvBorderFn ( Conv ) : <EOL> _members = [ '<STR_LIT>' ] <EOL> class ConvBorderValue ( Conv ) : <EOL> _members = [ '<STR_LIT>' ] <EOL> class ConvPadding ( Conv ) : <EOL> _members = [ '<STR_LIT>' ] </s>
