Operator RND

Operator Library: Arithmetics

RND 算子对输出 Bit Width 执行带舍入和截断的右移操作。舍入的位数通过参数 bits2Round 指定。

实现的舍入方法为“远离零的半舍入”(Round half away from zero)。颜色分量分别进行舍入。

示例

  • 输入 = 4 Bit 无符号,输入值 = 7,bits2Round = 2

    输出 = 2 Bit 无符号,输出值 = 2

  • 输入 = 5 Bit 有符号,输入值 = -13,bits2Round = 2

    输出 = 3 Bit 有符号,输出值 = -3

  • 输入 = 4 Bit 无符号,输入值 = 15,bits2Round = 2

    输出 = 2 Bit 无符号,输出值 = 3 注意:输出已被截断为最大可能值。

I/O Property

Property 值
Operator Type O
Input Link I, data input
Output Link O,数据输出

支持的 Link Format

Link Parameter Input Link I Output Link O
Bit Width [1, 64] unsigned, [2, 64] signed auto1
Arithmetic {unsigned, signed} as I
Parallelism any as I
Kernel Columns any as I
Kernel Rows any as I
Img Protocol {VALT_IMAGE2D, VALT_LINE1D, VALT_PIXEL0D} as I
Color Format any as I
Color Flavor any as I
Max. Img Width any as I
Max. Img Height any as I

1

输出端的 Bit Width 为输入 Bit Width 减去参数 bits2Round 的值。

参数

bits2Round
键入 静态参数
默认 0
范围

无符号数的范围为 [0, BitWidth(I)-1]

有符号数的条件为 (BitWidth(I) - bits2Round > 1)

此参数定义输入向右移位的位数。

使用示例

以下示例展示了 RND 算子的使用方法: