vec_or

Description

Performs bitwise OR element-wise:

Prototype

vec_or(mask, dst, src0, src1, repeat_times, dst_rep_stride, src0_rep_stride, src1_rep_stride)

Parameters

For details, see Parameters.

dst, src0, and src1 must have the same data type. Tensors of type uint16 or int16.

Returns

None

Applicability

Atlas training product

Atlas inference product AI Core

Atlas inference product Vector Core

Atlas A2 training product / Atlas A2 inference product

Atlas 200I/500 A2 inference product

Restrictions

For details, see Restrictions.

Example

This example applies to a small amount of data that can be moved at a time, helping you understand the API functions. For more complex samples with a large amount of data, see Example.

from tbe import tik
tik_instance = tik.Tik()
src0_gm = tik_instance.Tensor("int16", (128,), name="src0_gm", scope=tik.scope_gm)
src1_gm = tik_instance.Tensor("int16", (128,), name="src1_gm", scope=tik.scope_gm)
dst_gm = tik_instance.Tensor("int16", (128,), name="dst_gm", scope=tik.scope_gm)
src0_ub = tik_instance.Tensor("int16", (128,), name="src0_ub", scope=tik.scope_ubuf)
src1_ub = tik_instance.Tensor("int16", (128,), name="src1_ub", scope=tik.scope_ubuf)
dst_ub = tik_instance.Tensor("int16", (128,), name="dst_ub", scope=tik.scope_ubuf)
# Move the user input from the Global Memory to the Unified Buffer.
tik_instance.data_move(src0_ub, src0_gm, 0, 1, 8, 0, 0)
tik_instance.data_move(src1_ub, src1_gm, 0, 1, 8, 0, 0)
tik_instance.vec_or(128, dst_ub, src0_ub, src1_ub, 1, 8, 8, 8)
# Move the compute result from the Unified Buffer to the destination Global Memory.
tik_instance.data_move(dst_gm, dst_ub, 0, 1, 8, 0, 0)

tik_instance.BuildCCE(kernel_name="vec_or", inputs=[src0_gm, src1_gm], outputs=[dst_gm])

Result example:

Input (src0_gm):
[-6  5 -8  9  5  7  0  0  5  9 -8 -7  4  3 -7  1  4 -8 -9  8  2  8  0  0
  0  6  8  4  2  7 -9 -1  8 -1  7 -2  1 -1  8  0  1 -7  8  8 -8 -5  8  5
 -4  1 -3  6  6  7 -9 -8  6 -2  9 -2 -6 -1  1 -9 -3 -2  3 -7 -1  5 -9  6
  5  0  0  8  5 -9 -6 -8  5  5  5 -3 -8  9  5  5 -1  0 -6  6  1 -5  0  7
  3  4 -4  8  9  0 -7 -5  5 -1  5 -6 -2  1  8  7 -5 -9  0  3  4 -4 -7  2
 -6  0  3  5  1 -6 -2 -5]

Input (src1_gm):
[-8  9 -4  3  3  2  3 -6  9  9 -5  1  3  0 -5  2  8  9 -9  1  5  2  4  1
  7 -5 -3  8 -3  8 -5 -6 -9  7  4 -7 -1 -5  9  2 -3 -3  0  9  1  7 -6 -1
  8 -2  6 -5  5  9  5 -4  9  5  9  4  7  9 -2  9  0 -3 -2  8  4  3 -7 -4
  8  9  5 -4  5 -1  0  1 -2 -3 -1 -7 -1  3  4  8 -9 -3 -6  0  0 -8  2 -7
  7  1 -3 -9 -6  2 -6  7  8 -2 -8  2  4 -2  2 -6  0  0  2  1  3 -9 -8  0
  9 -1  5  2 -8 -5  0  2]

Output (dst_gm):
[-6 13 -4 11  7  7  3 -6 13  9 -5 -7  7  3 -5  3 12 -7 -9  9  7 10  4  1
  7 -1 -3 12 -1 15 -1 -1 -1 -1  7 -1 -1 -1  9  2 -3 -3  8  9 -7 -1 -6 -1
 -4 -1 -1 -1  7 15 -9 -4 15 -1  9 -2 -1 -1 -1 -1 -3 -1 -1 -7 -1  7 -1 -2
 13  9  5 -4  5 -1 -6 -7 -1 -3 -1 -3 -1 11  5 13 -1 -3 -6  6  1 -5  2 -1
  7  5 -3 -1 -5  2 -5 -1 13 -1 -3 -6 -2 -1 10 -1 -5 -9  2  3  7 -1 -7  2
 -5 -1  7  7 -7 -5 -2 -5]