vec_cpadd
Description
Adds elements (odd and even) between adjacent pairs: 
Prototype
vec_cpadd(mask, dst, src, repeat_times, dst_rep_stride, src_rep_stride)
Parameters
For details, see Parameters. dst has the same data type as src.
Returns
None
Applicability
Restrictions
For details, see Restrictions.
Example
This example describes only basic functions. For more details, see Example.
from tbe import tik
tik_instance = tik.Tik()
src_gm = tik_instance.Tensor("float16", (128,), name="src_gm", scope=tik.scope_gm)
dst_gm = tik_instance.Tensor("float16", (64,), name="dst_gm", scope=tik.scope_gm)
src_ub = tik_instance.Tensor("float16", (128,), name="src_ub", scope=tik.scope_ubuf)
dst_ub = tik_instance.Tensor("float16", (64,), name="dst_ub", scope=tik.scope_ubuf)
# Move the user input from the Global Memory to the Unified Buffer.
tik_instance.data_move(src_ub, src_gm, 0, 1, 8, 0, 0)
tik_instance.vec_cpadd(128, dst_ub, src_ub, 1, 4, 8)
# Move the compute result from the Unified Buffer to the Global Memory.
tik_instance.data_move(dst_gm, dst_ub, 0, 1, 4, 0, 0)
tik_instance.BuildCCE(kernel_name="vec_cpadd", inputs=[src_gm], outputs=[dst_gm])
Result example:
Input (src_gm): [-1.899 3.43 6.39 2.61 -1.996 9.68 0.699 4.395 -0.2384 5.39 -5.58 -0.592 -8.52 -1.713 -0.977 8.53 -7.043 4.348 -2.475 4.16 -7.48 -3.48 0.7246 9.266 7.566 2.225 0.07605 -8.59 -3.506 0.1312 -7.598 -7.668 -8.76 -8.9 0.3625 7.906 9.26 2.357 6.71 0.5034 -9.484 -2.215 -5.188 4.316 -9.96 7.254 5.855 3.146 -4.613 -4.715 -4.637 7.99 -9.11 7.59 -2.705 -8.26 -7.84 7.047 3.244 7.31 1.431 -1.55 6.465 1.723 2.998 4.51 -7.445 -3.293 3.705 -4.11 3.783 0.5117 1.835 6.62 0.6226 7.043 1.572 -8.58 -3.37 -5.836 9.72 -6.047 -2.977 9.86 -9.55 -2.402 -4.71 3.793 8.625 -0.3523 7.88 -1.134 7.465 -4.598 -7.055 -9.04 -0.979 -0.6177 -6.355 -1.605 -8.92 1.049 -0.723 7.066 8.984 9.74 9.49 6.133 -6.87 -7.582 -4.863 2.217 8.46 9.84 5.785 4.992 8.68 -1.767 2.395 8.414 9.375 2.877 -3.016 -4.137 -1.899 6.22 -7.426 4.99 ] Output (dst_gm): [ 1.53 9. 7.684 5.094 5.152 -6.17 -10.234 7.555 -2.695 1.686 -10.96 9.99 9.79 -8.516 -3.375 -15.266 -17.66 8.266 11.62 7.215 -11.7 -0.871 -2.707 9. -9.33 3.352 -1.52 -10.96 -0.793 10.555 -0.11914 8.19 7.508 -10.734 -0.4043 4.297 8.45 7.664 -7.008 -9.2 3.672 6.883 -11.95 -0.918 8.27 6.746 2.867 -16.1 -1.597 -7.96 -7.875 6.344 18.72 15.625 -14.45 -2.646 18.31 10.78 6.914 10.81 12.25 -7.152 4.32 -2.438 ]
Parent topic: Pair Reduce