vcadd
Function
vcadd instruction abstraction.
Reduces the tensor dimensions based on the input parameters of the instruction. In the msKPP instruction system, reduce_num controls the shape reduction multiple and ensures that the shapes of the input and output tensors are the same. When the last dimension of the shape is reduced to 1, the dimension is eliminated. Ensure that the last dimension of the shape can be exactly divided by reduce_num and is not 0.
Prototype
1 | class vcadd(x, y, reduce_num) |
Parameters
Parameter |
Input/Output |
Data Type |
Description |
|---|---|---|---|
x |
Input |
Tensor variable |
Input x-vector tensor. FP16 and FP32 are supported. |
reduce_num |
Input |
int |
Number of times that the last dimension is reduced. The value of this parameter does not affect the instruction performance. |
y |
Output |
Tensor variable |
Output y-vector tensor. FP16 and FP32 are supported. |
Example
1 2 3 4 5 6 | from mskpp import vcadd, Tensor ub_x, ub_y = Tensor("UB"), Tensor("UB") gm_x = Tensor("GM") reduce_num = 16 ub_x.load(gm_x) out = vcadd(ub_x, ub_y, reduce_num)() |
Constraints
The value of reduce_num cannot be 0.