fix name of operator output in onnxop.inc and Operator.md (#62)
* fix name of operator output in onnxop.inc and Operator.md * Update directive.py Co-authored-by: Gheorghe-Teodor Bercea <gt.bercea@gmail.com> Co-authored-by: Tian Jin <tjingrant@gmail.com>
This commit is contained in:
parent
477227a0ec
commit
c45655413d
|
@ -13,6 +13,9 @@ ONNF modified this script to import ONNX specifications into ONNF. There are two
|
|||
5. copy the two file into your ONNF: cp onnxop.inc your_ONNF/src/dialect/onnx/onnxop.inc; cp op_build_table.inc your_ONNF/src/builder
|
||||
6. go to your ONNF and build
|
||||
|
||||
## Consistency
|
||||
The Operators.md generated by gen_doc.py is copied into doc. Please refer to this specification, not the one in onnx github, to make sure operators are consistent in version with onnxop.inc.
|
||||
|
||||
## Customization
|
||||
In addition to following the ONNF specification, the modified gen_doc.py provides some mechanism for you to customize the output.
|
||||
Several tables are defined at the beginning of the script:
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -44,7 +44,15 @@ class Directive(object):
|
|||
:param directive_config: a list used to output parsed directive configuration.
|
||||
:return: parse result.
|
||||
"""
|
||||
try:
|
||||
line = ctx.doc_file.next_non_empty_line()
|
||||
except RuntimeError as e:
|
||||
# Do not raise exception when next non-empty line
|
||||
# does not exist. Instead, return failure.
|
||||
if str(e) != "Enf of file.":
|
||||
raise
|
||||
return failure()
|
||||
|
||||
matches = self.ext_to_patterns[ctx.doc_file_ext()].findall(line)
|
||||
if len(matches) > 1:
|
||||
raise ValueError("more than one directives in a line")
|
||||
|
|
|
@ -120,6 +120,11 @@ def display_version_link(name, version): # type: (Text, int) -> Text
|
|||
name_with_ver = '{}-{}'.format(name, version)
|
||||
return '<a href="{}#{}">{}</a>'.format(changelog_md, name_with_ver, name_with_ver)
|
||||
|
||||
def get_unique_output_name(schema, name):
|
||||
for input in schema.inputs :
|
||||
if input.name == name :
|
||||
return 'out_'+name
|
||||
return name
|
||||
|
||||
def display_schema(schema, versions): # type: (OpSchema, Sequence[OpSchema]) -> Text
|
||||
s = ''
|
||||
|
@ -223,7 +228,7 @@ def display_schema(schema, versions): # type: (OpSchema, Sequence[OpSchema]) ->
|
|||
option_str = " (variadic)"
|
||||
else:
|
||||
option_str = " (variadic, heterogeneous)"
|
||||
s += '<dt><tt>{}</tt>{} : {}</dt>\n'.format(output.name, option_str, output.typeStr)
|
||||
s += '<dt><tt>{}</tt>{} : {}</dt>\n'.format(get_unique_output_name(schema, output.name), option_str, output.typeStr)
|
||||
s += '<dd>{}</dd>\n'.format(output.description)
|
||||
s += '</dl>\n'
|
||||
|
||||
|
@ -302,7 +307,6 @@ def collect_types(schema, input) :
|
|||
return allowedTypeStr
|
||||
|
||||
def gen_schema(schema) :
|
||||
skip_attr_gen = []
|
||||
line_indent = ' '
|
||||
|
||||
#s = 'def ONNX'+schema.name+str(schema.since_version)+'Op:ONNX_Op<"'+schema.name+'", \n'
|
||||
|
@ -368,7 +372,6 @@ def gen_schema(schema) :
|
|||
#TODO handle (variadic, heterogeneous)"
|
||||
t=''
|
||||
s+=':$'+input.name
|
||||
if not schema.name in skip_attr_gen :
|
||||
s += gen_attr_ins(schema, isfirst)
|
||||
s+= ');'
|
||||
|
||||
|
@ -377,14 +380,14 @@ def gen_schema(schema) :
|
|||
if schema.outputs:
|
||||
for output in schema.outputs:
|
||||
if output != schema.outputs[0] :
|
||||
s+= ', '
|
||||
s+= ',\n '
|
||||
#need to interpret output.typeStr
|
||||
etypes=collect_types(schema, output)
|
||||
if etypes == '':
|
||||
s+= 'AnyTypeOf<[AnyMemRef, AnyTensor]>'
|
||||
else:
|
||||
s+= 'TensorOf<['+etypes+']>'
|
||||
s += ':$o_'+output.name
|
||||
s += ':$'+get_unique_output_name(schema, output.name)
|
||||
s+= ');\n'
|
||||
|
||||
#s+= 'let hasCanonicalizer = 1;'
|
||||
|
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue