add type check for input name of resolve_datatype() #121
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I found some potential issue in the
resolve_datatype()
function of thedatatype.py
file:Looking at this function I first thought one has to pass a string for the name input. However, if the input
name
is of type for exampleqonnx.core.datatype.BipolarType
with a name attribute which is covered in the_spacial_types
dictonary (in this case Bipolar) the checkif name in _special_types.keys():
will be true. But when you pass for example anqonnx.core.datatype.IntType
class the checkif name in _special_types.keys():
will be false and the program will crash at the next checkelif name.startswith("UINT"):
since here the assumption is that the inputname
is of typestr
. So long story short the firstif
can accept astr
or a class which is named in the_spacial_types
dictonary while the other cases only work withstr
.I propose to introduce a type check for the input
name
for a better error handling. I also added a test case to check if the error is raised and another one to test theresolve_datatype
function.