Home | History | Annotate | only in /external/tensorflow/tensorflow/compiler/xla/tools/parser
Up to higher level directory
NameDateSize
BUILD21-Aug-20181.9K
hlo_lexer.cc21-Aug-201813.3K
hlo_lexer.h21-Aug-20183.9K
hlo_parser.cc21-Aug-201890.3K
hlo_parser.h21-Aug-20181.8K
hlo_parser_test.cc21-Aug-201836.9K
hlo_token.h21-Aug-20181.9K
README.md21-Aug-20182.3K

README.md

      1 # HLO Text Syntax
      2 
      3 ```yacc
      4 hlo_module
      5   : 'HloModule' name computations
      6   ;
      7 
      8 /* If no computation is marked as ENTRY, the last computation will be the entry
      9 computation of the module.*/
     10 computations
     11   : computation
     12   | computation computations
     13   ;
     14 
     15 computation
     16   : 'ENTRY' name param_list_to_shape instruction_list
     17   | name param_list_to_shape instruction_list
     18   | 'ENTRY' name instruction_list
     19   | name instruction_list
     20   ;
     21 
     22 /* If no instruction is marked as ROOT, the last instruction will be the root of
     23 its computation. */
     24 instruction_list
     25   : '{' instruction_list1 '}'
     26   ;
     27 instruction_list1
     28   : instruction
     29   | instruction_list1 instruction
     30   ;
     31 instruction
     32   : 'ROOT' name '=' shape opcode operands extra_attributes
     33   | name '=' shape opcode operands extra_attributes
     34   ;
     35 
     36 operands
     37   : '(' operands1 ')'
     38   ;
     39 operands1
     40   : /*empty*/
     41   | operand
     42   | operands1 ',' operand
     43   ;
     44 operand
     45   : shape name
     46   | name
     47   ;
     48 
     49 attributes
     50   : /*empty*/
     51   | ',' attribute
     52   | ',' attribute attributes
     53   ;
     54 attribute
     55   : attribute_name attribute_value
     56   ;
     57 attribute_value
     58   : kInt
     59   | kName
     60   | [0-9bf]{2,}_[0-9io]{2,}->[0-9bf]{2,}                /*dim_labels_pattern*/
     61   | [0-9]+(x[0-9]+)+                                    /*dxd_pattern*/
     62   | [0-9]+_[0-9]+(_[0-9]+)?(x[0-9]+_[0-9]+(_[0-9]+)?)*  /*pad_pattern*/
     63   | '{' sub_attributes '}'
     64   ;
     65 
     66 param_list_to_shape
     67   : param_list '->' shape
     68   ;
     69 
     70 param_list
     71   : '(' param_list1 ')'
     72   ;
     73 param_list1
     74   : /*empty*/
     75   | param
     76   | param_list1 ',' param
     77   ;
     78 param
     79   : name shape
     80   ;
     81 
     82 shape
     83   : shape_val_
     84   | '(' tuple_elements ')'
     85   ;
     86 tuple_elements
     87   : /*empty*/
     88   | shape (',' shape)*
     89   ;
     90 
     91 name
     92   : identifier ':'
     93   | '%' identifier
     94   | identifier
     95   ;
     96 
     97 identifier
     98   : [a-zA-Z_][a-zA-Z0-9_.-]*
     99   ;
    100 
    101 /* literal is in the right hand side of a constant instruction. */
    102 literal
    103   : tuple
    104   | non_tuple
    105   ;
    106 tuple
    107   : shape '(' literal_list ')'
    108   ;
    109 literal_list
    110   : /*empty*/
    111   : literal
    112   | literal_list ',' literal
    113   ;
    114 non_tuple
    115   : rank01
    116   | rank2345
    117   ;
    118 rank2345
    119   : shape sparse_or_nested_array
    120   ;
    121 sparse_or_nested_array
    122   : sparse_array
    123   | nested_array
    124   ;
    125 sparse_array
    126   : '{' sparse_array1 '}'
    127   ;
    128 sparse_array1
    129   : sparse_array_item
    130   | sparse_array1 ',' sparse_array_item
    131   ;
    132 sparse_array_item
    133   : multi_index ':' scalar
    134   ;
    135 multi_index
    136   : kInt
    137   | '[' multi_index1 ']'
    138   ;
    139 multi_index1
    140   : kInt
    141   | multi_index1 ',' kInt
    142   ;
    143 
    144 ```
    145