diff options
author | Justin Lebar <jlebar@google.com> | 2018-06-01 15:32:16 -0700 |
---|---|---|
committer | TensorFlower Gardener <gardener@tensorflow.org> | 2018-06-01 15:34:52 -0700 |
commit | 5e0b2f2b0d0d938152334ae1ef1c9b25d229e280 (patch) | |
tree | 2774166e3d5f04577d39fc2227d6d0e364bd249a /tensorflow/compiler/xla/service/g3doc | |
parent | af1d59aff9bf3b43dfff4d99e50d22f527201e76 (diff) |
[XLA] Move xla/tools/parser/* into xla/service.
Now that we're using the parser inside of xla/service, it's awkward for
it to live inside of xla/tools, because everything else in there is a
standalone tool. We've already had one person be confused by this.
PiperOrigin-RevId: 198935921
Diffstat (limited to 'tensorflow/compiler/xla/service/g3doc')
-rw-r--r-- | tensorflow/compiler/xla/service/g3doc/hlo_parser.md | 144 |
1 files changed, 144 insertions, 0 deletions
diff --git a/tensorflow/compiler/xla/service/g3doc/hlo_parser.md b/tensorflow/compiler/xla/service/g3doc/hlo_parser.md new file mode 100644 index 0000000000..f0f3dd7785 --- /dev/null +++ b/tensorflow/compiler/xla/service/g3doc/hlo_parser.md @@ -0,0 +1,144 @@ +# HLO Text Syntax + +```yacc +hlo_module + : 'HloModule' name computations + ; + +/* If no computation is marked as ENTRY, the last computation will be the entry +computation of the module.*/ +computations + : computation + | computation computations + ; + +computation + : 'ENTRY' name param_list_to_shape instruction_list + | name param_list_to_shape instruction_list + | 'ENTRY' name instruction_list + | name instruction_list + ; + +/* If no instruction is marked as ROOT, the last instruction will be the root of +its computation. */ +instruction_list + : '{' instruction_list1 '}' + ; +instruction_list1 + : instruction + | instruction_list1 instruction + ; +instruction + : 'ROOT' name '=' shape opcode operands extra_attributes + | name '=' shape opcode operands extra_attributes + ; + +operands + : '(' operands1 ')' + ; +operands1 + : /*empty*/ + | operand + | operands1 ',' operand + ; +operand + : shape name + | name + ; + +attributes + : /*empty*/ + | ',' attribute + | ',' attribute attributes + ; +attribute + : attribute_name attribute_value + ; +attribute_value + : kInt + | kName + | [0-9bf]{2,}_[0-9io]{2,}->[0-9bf]{2,} /*dim_labels_pattern*/ + | [0-9]+(x[0-9]+)+ /*dxd_pattern*/ + | [0-9]+_[0-9]+(_[0-9]+)?(x[0-9]+_[0-9]+(_[0-9]+)?)* /*pad_pattern*/ + | '{' sub_attributes '}' + ; + +param_list_to_shape + : param_list '->' shape + ; + +param_list + : '(' param_list1 ')' + ; +param_list1 + : /*empty*/ + | param + | param_list1 ',' param + ; +param + : name shape + ; + +shape + : shape_val_ + | '(' tuple_elements ')' + ; +tuple_elements + : /*empty*/ + | shape (',' shape)* + ; + +name + : identifier ':' + | '%' identifier + | identifier + ; + +identifier + : [a-zA-Z_][a-zA-Z0-9_.-]* + ; + +/* literal is in the right hand side of a constant instruction. */ +literal + : tuple + | non_tuple + ; +tuple + : shape '(' literal_list ')' + ; +literal_list + : /*empty*/ + : literal + | literal_list ',' literal + ; +non_tuple + : rank01 + | rank2345 + ; +rank2345 + : shape sparse_or_nested_array + ; +sparse_or_nested_array + : sparse_array + | nested_array + ; +sparse_array + : '{' sparse_array1 '}' + ; +sparse_array1 + : sparse_array_item + | sparse_array1 ',' sparse_array_item + ; +sparse_array_item + : multi_index ':' scalar + ; +multi_index + : kInt + | '[' multi_index1 ']' + ; +multi_index1 + : kInt + | multi_index1 ',' kInt + ; + +``` |