Fix substitution order in parse_type_str (#316)

* Fix substitution order in parse_type_str

Signed-off-by: Ganesan Ramalingam <grama@microsoft.com>

* add comment

* Remove files added accidentally

Co-authored-by: chentong319 <chentong@us.ibm.com>
Co-authored-by: Tian Jin <tjingrant@gmail.com>
This commit is contained in:
G. Ramalingam 2020-09-30 02:36:06 -07:00 committed by GitHub
parent 46306a8a26
commit 75930ffbcf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 1 deletions

View File

@ -818,7 +818,11 @@ def parse_type_str(allowedType):
'complex128' : 'Complex<F64>', 'complex128' : 'Complex<F64>',
'string' : 'StringType'} 'string' : 'StringType'}
for key, item in onnx_to_mlir_type_dict.items(): # Apply substitutions in decreasing order of key-length, so that float16 is replaced
# before float, and uint16 is replaced before int16, etc.
mapping = list(onnx_to_mlir_type_dict.items())
mapping.sort(key=lambda pair:len(pair[0]), reverse=True)
for key, item in mapping:
allowedType = allowedType.replace(key, item) allowedType = allowedType.replace(key, item)
return allowedType return allowedType