Skip to content

Commit

Permalink
Use quantize and dequantize from openxla#1496 in dequantize_select_qu…
Browse files Browse the repository at this point in the history
…antize and dequantize_compare
  • Loading branch information
sdasgup3 committed Jun 20, 2023
1 parent 74517e0 commit 216983b
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions docs/spec.md
Original file line number Diff line number Diff line change
Expand Up @@ -6334,15 +6334,14 @@ def dequantize_op_quantize(op, *inputs_and_output_type):
return quantize(float_result, output_type)

def dequantize_select_quantize(pred, on_true, on_false, output_type):
float_on_true = (on_true - zero_point(on_true)) * scale(on_true)
float_on_false = (on_false - zero_point(on_false)) * scale(on_false)
float_on_true = dequantize(on_true)
float_on_false = dequantize(on_false)
float_result = select(pred, float_on_true, float_on_false)
rounded_result = round_nearest_even(float_result / scale(output_type))
return clamp(storage_min(output_type), rounded_result, storage_max(output_type))
return quantize(float_result, output_type)

def dequantize_compare(lhs, rhs, comparison_direction):
float_lhs = (lhs - zero_point(lhs)) * scale(lhs)
float_rhs = (rhs - zero_point(rhs)) * scale(rhs)
float_lhs = dequantize(lhs)
float_rhs = dequantize(rhs)
return compare(float_lhs, float_rhs, comparison_direction, FLOAT)
```

Expand Down

0 comments on commit 216983b

Please sign in to comment.