- This function flips all values of the input Array's last component, which correspond to MSB bit (after `pull_out_bits`), to enable the signed comparisons. - Why bit flip is sufficient for obtaining signed comparisons given unsigned comparison functionality? Please see below example: |sign bit MSB| b1| b0| unsigned value| signed value| |------------|----|----|---------------|--------------
(ip: Node)
| 329 | /// Here we xor the MSB bit with 1 to flip it. It is more efficient than do slice + concat. |
| 330 | /// We rely on broadcasting to avoid the huge constants in graph. |
| 331 | pub(super) fn flip_msb(ip: Node) -> Result<Node> { |
| 332 | ip.add(get_msb_flip_constant( |
| 333 | ip.get_type()?.get_shape(), |
| 334 | &ip.get_graph(), |
| 335 | )?) |
| 336 | } |
| 337 | |
| 338 | fn get_msb_flip_constant(shape: ArrayShape, g: &Graph) -> Result<Node> { |
| 339 | let n = shape[shape.len() - 1] as usize; |
no test coverage detected