Greedily generate 2D n:m sparse pattern mask of the input matrix mat. This function would pad each dimension of mat by zero to be a multiples of m before mask generation.

2D n:m sparse pattern: At least $$n \times n$$ zeros in every $$m \times m$$ block under the constraint of at least n zeros for each row and column. Greedily generating: For each $$m \times m$$ block, selecting values to keep in descent order.

Parameters
• mat (nparray) – The input matrix.

• n (int) – n of n:m sparse pattern.

• m (int) – m of n:m sparse pattern.

Returns

The 2D n:m sparse mask of mat.

Return type

nparray

Examples

import numpy as np