Replies: 1 comment
-
To support fixed-point math in a language you have a choice between adding fixed-point types, or adding fixed-point operations that apply to integer types. We went with the latter. We found that this was a more intuitive way (for us at least) to target the fixed-point instructions available in current CPUs and DSPs. The fixed-point operations we support are here: https://github.com/halide/Halide/blob/main/src/IROperator.h#L1616 So for fixed-point addition without changing the bit width we have halving_add and rounding_halving_add, for fixed-point multiplication without changing the bit width we have mul_shift_right and rounding_mul_shift_right, and when you want to change precision we have a variety of widening operators there. Narrowing operators (ones that reduce precision) are typically done with a non-narrowing operator wrapped in a saturating_cast, which we peephole recognize in the backend to hit instructions like rshrn on ARM. |
Beta Was this translation helpful? Give feedback.
-
HI there,
Are there any plans to support fixed-point floating values? Something akin to this article: #3115
but more in-line with Halide's cast<> system?
Thanks, Charles.
Beta Was this translation helpful? Give feedback.
All reactions