Skip to content

Commit

Permalink
Make reference code zero points float instead of int.
Browse files Browse the repository at this point in the history
These get converted to float anyways, and this is more flexible.

PiperOrigin-RevId: 705259824
  • Loading branch information
dsharletg authored and xnnpack-bot committed Dec 11, 2024
1 parent e3d6f1c commit b8362d1
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/xnnpack/microparams.h
Original file line number Diff line number Diff line change
Expand Up @@ -589,9 +589,9 @@ struct xnn_x32_packb_params {

struct xnn_unary_reference_params {
float x_scale;
int32_t x_zero_point;
float x_zero_point;
float inv_y_scale;
int32_t y_zero_point;
float y_zero_point;
union xnn_unary_params params;
};

Expand Down
6 changes: 3 additions & 3 deletions src/xnnpack/reference-utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,12 @@ Result round_float_to_int(float x) {
}

template <typename T>
float dequantize(T x, float scale, int32_t zero_point) {
return (static_cast<float>(x) - static_cast<float>(zero_point)) * scale;
float dequantize(T x, float scale, float zero_point) {
return (static_cast<float>(x) - zero_point) * scale;
}

template <typename T>
T quantize(float x, float inv_scale, int32_t zero_point) {
T quantize(float x, float inv_scale, float zero_point) {
return round_float_to_int<T>(x * inv_scale + zero_point);
}

Expand Down

0 comments on commit b8362d1

Please sign in to comment.