vreduce

Function

vreduce instruction abstraction.

The vreduce instruction determines which elements of the x vector are to be stored in the z vector based on the mask data of the input y vector. Because the tensor in msKPP lacks actual elements, the reserve_num parameter is added to determine the shape of the z output.

Prototype

1
class vreduce(x, y, z, reserve_num)

Parameters

Parameter

Input/Output

Data Type

Description

x

Input

Tensor variable

Input x-vector tensor. UINT16 and UINT32 are supported.

y

Input

Tensor variable

Input y-vector tensor. UINT16 and UINT32 are supported.

z

Output

Tensor variable

Output z-vector tensor. UINT16 and UINT32 are supported.

reserve_num

Input

int

Number of output elements.

Example

1
2
3
4
5
6
7
8
from mskpp import vreduce, Tensor
ub_x, ub_y, ub_z = Tensor("UB"), Tensor("UB"), Tensor("UB")
gm_x, gm_y, gm_z = Tensor("GM"), Tensor("GM"), Tensor("GM")
reserve_num = 16
ub_x.load(gm_x)
ub_y.load(gm_y)
out = vreduce(ub_x, ub_y, ub_z, reserve_num)()
gm_z.load(out[0])