Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes for fp16 tensors and datatypes in ONNX #156

Merged
merged 9 commits into from
Dec 9, 2024
Merged

Conversation

maltanar
Copy link
Collaborator

@maltanar maltanar commented Dec 4, 2024

QONNX traditionally made a number of assumptions about how quantization is represented: using float32 carrier datatypes, with quantization introduced through explicit Quant nodes and optionally with datatype annotations on tensors (InferDataTypes). Some of these baked-in assumptions cause inflexibility around other datatypes. This PR relaxes a few of these restrictions around float16 by introducing the following changes:

  • ModelWrapper.get_tensordatatype previously always returned FLOAT32 for any tensor without a datatype annotation. Now an additional check is performed: if there is no datatype annotation, we look at the underlying container datatype to have the option of returning FLOAT16 instead.
  • InferDataTypes supports preserving FLOAT16 either from annotations or from the container datatype.
  • gen_finn_dt_tensor now returns np.float16 if the desired data type is specified to be FLOAT16.
  • Quant nodes will preserve float16 tensors if those were originally provided as input/outputs.

@maltanar maltanar marked this pull request as ready for review December 9, 2024 10:39
@maltanar maltanar merged commit f3690c8 into main Dec 9, 2024
5 checks passed
@maltanar maltanar deleted the feature/fp16_fixes branch December 9, 2024 12:10
@maltanar maltanar added this to the v0.4.0 milestone Dec 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant