Skip to content

Commit

Permalink
Add RND bit to bias and scale vector to match existing TVM behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
supersat committed Feb 16, 2023
1 parent 2c0fa6b commit 8738657
Showing 1 changed file with 2 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,8 @@ def bias_and_filter_constexpr(
shift = T.int32(T.trunc(T.log2(hmx_output_scale)))
frac_scale = (hmx_output_scale / (T.int32(1) << shift)) - 1
ifrac_scale = T.round(1024 * frac_scale)
packed_scale = T.int32(ifrac_scale + shift * 1024)
# Bit 22 of the packed scale applies rounding
packed_scale = T.int32((ifrac_scale + shift * 1024)) | (T.int32(1) << T.int32(22))

# Compute final biases based on activation zero point and weights
requant_bias = T.int32((rqozp * rqos / rqis) - rqizp)
Expand Down

0 comments on commit 8738657

Please sign in to comment.