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 example qonnx.core.datatype.BipolarType with a name attribute which is covered in the _spacial_types dictonary (in this case Bipolar) the check if name in _special_types.keys(): will be true. But when you pass for example an qonnx.core.datatype.IntType class the check if name in _special_types.keys(): will be false and the program will crash at the next check elif name.startswith("UINT"): since here the assumption is that the input name is of type str. So long story short the first if can accept a str or a class which is named in the _spacial_types dictonary while the other cases only work with str.
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 the resolve_datatype function.
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.