qonnx.core.datatype (module)
- class qonnx.core.datatype.BaseDataType
Bases:
abc.ABCBase class for QONNX data types.
- abstract allowed(value)
Check whether given value is allowed for this DataType.
value (float32): value to be checked
- abstract bitwidth()
Returns the number of bits required for this DataType.
- abstract get_canonical_name()
Return a canonical string representation of this QONNX DataType.
- abstract get_hls_datatype_str()
Returns the corresponding Vivado HLS datatype name.
- abstract get_num_possible_values()
Returns the number of possible values this DataType can take. Only implemented for integer types for now.
- abstract is_fixed_point()
Returns whether this DataType represent fixed-point values only.
- abstract is_integer()
Returns whether this DataType represents integer values only.
- abstract max()
Returns the largest possible value allowed by this DataType.
- abstract min()
Returns the smallest possible value allowed by this DataType.
- property name
- signed()
Returns whether this DataType can represent negative numbers.
- abstract to_numpy_dt()
Return an appropriate numpy datatype that can represent this QONNX DataType.
- class qonnx.core.datatype.BipolarType
Bases:
qonnx.core.datatype.BaseDataType- allowed(value)
Check whether given value is allowed for this DataType.
value (float32): value to be checked
- bitwidth()
Returns the number of bits required for this DataType.
- get_canonical_name()
Return a canonical string representation of this QONNX DataType.
- get_hls_datatype_str()
Returns the corresponding Vivado HLS datatype name.
- get_num_possible_values()
Returns the number of possible values this DataType can take. Only implemented for integer types for now.
- is_fixed_point()
Returns whether this DataType represent fixed-point values only.
- is_integer()
Returns whether this DataType represents integer values only.
- max()
Returns the largest possible value allowed by this DataType.
- min()
Returns the smallest possible value allowed by this DataType.
- to_numpy_dt()
Return an appropriate numpy datatype that can represent this QONNX DataType.
- class qonnx.core.datatype.DataType(value)
Bases:
enum.EnumEnum class that contains QONNX data types to set the quantization annotation. ONNX does not support data types smaller than 8-bit integers, whereas in QONNX we are interested in smaller integers down to ternary and bipolar.
- static get_accumulator_dt_cands()
- static get_smallest_possible(value)
Returns smallest (fewest bits) possible DataType that can represent value. Prefers unsigned integers where possible.
- class qonnx.core.datatype.DataTypeMeta(cls, bases, classdict)
Bases:
enum.EnumMeta
- class qonnx.core.datatype.FixedPointType(bitwidth, intwidth)
Bases:
qonnx.core.datatype.IntType- allowed(value)
Check whether given value is allowed for this DataType.
value (float32): value to be checked
- frac_bits()
- get_canonical_name()
Return a canonical string representation of this QONNX DataType.
- get_hls_datatype_str()
Returns the corresponding Vivado HLS datatype name.
- int_bits()
- is_fixed_point()
Returns whether this DataType represent fixed-point values only.
- is_integer()
Returns whether this DataType represents integer values only.
- max()
Returns the largest possible value allowed by this DataType.
- min()
Returns the smallest possible value allowed by this DataType.
- scale_factor()
- to_numpy_dt()
Return an appropriate numpy datatype that can represent this QONNX DataType.
- class qonnx.core.datatype.FloatType
Bases:
qonnx.core.datatype.BaseDataType- allowed(value)
Check whether given value is allowed for this DataType.
value (float32): value to be checked
- bitwidth()
Returns the number of bits required for this DataType.
- get_canonical_name()
Return a canonical string representation of this QONNX DataType.
- get_hls_datatype_str()
Returns the corresponding Vivado HLS datatype name.
- get_num_possible_values()
Returns the number of possible values this DataType can take. Only implemented for integer types for now.
- is_fixed_point()
Returns whether this DataType represent fixed-point values only.
- is_integer()
Returns whether this DataType represents integer values only.
- max()
Returns the largest possible value allowed by this DataType.
- min()
Returns the smallest possible value allowed by this DataType.
- to_numpy_dt()
Return an appropriate numpy datatype that can represent this QONNX DataType.
- class qonnx.core.datatype.IntType(bitwidth, signed)
Bases:
qonnx.core.datatype.BaseDataType- allowed(value)
Check whether given value is allowed for this DataType.
value (float32): value to be checked
- bitwidth()
Returns the number of bits required for this DataType.
- get_canonical_name()
Return a canonical string representation of this QONNX DataType.
- get_hls_datatype_str()
Returns the corresponding Vivado HLS datatype name.
- get_num_possible_values()
Returns the number of possible values this DataType can take. Only implemented for integer types for now.
- is_fixed_point()
Returns whether this DataType represent fixed-point values only.
- is_integer()
Returns whether this DataType represents integer values only.
- max()
Returns the largest possible value allowed by this DataType.
- min()
Returns the smallest possible value allowed by this DataType.
- to_numpy_dt()
Return an appropriate numpy datatype that can represent this QONNX DataType.
- class qonnx.core.datatype.TernaryType
Bases:
qonnx.core.datatype.BaseDataType- allowed(value)
Check whether given value is allowed for this DataType.
value (float32): value to be checked
- bitwidth()
Returns the number of bits required for this DataType.
- get_canonical_name()
Return a canonical string representation of this QONNX DataType.
- get_hls_datatype_str()
Returns the corresponding Vivado HLS datatype name.
- get_num_possible_values()
Returns the number of possible values this DataType can take. Only implemented for integer types for now.
- is_fixed_point()
Returns whether this DataType represent fixed-point values only.
- is_integer()
Returns whether this DataType represents integer values only.
- max()
Returns the largest possible value allowed by this DataType.
- min()
Returns the smallest possible value allowed by this DataType.
- to_numpy_dt()
Return an appropriate numpy datatype that can represent this QONNX DataType.
- qonnx.core.datatype.resolve_datatype(name)