keras_spmv_rt.py¶
-
class
keras_spmv_rt.
KerasSpmvRT
(keras_model, batch_sz, xclbin_opts)¶ runtime class to use SPMV in the keras example
It will send all the weights matrices loaded from the model to kernel for future usage
- Parameters
keras_model (model) – pre-trained model
xclbin_opts (dictionary) – information read from config_info.dat used to build the xclbin
batch_sz (shape) – output prediction matrix size
-
format_for_sparse_fpga
(weight_mat, shape)¶ return padded sizes, row index, col index and non-zero elements array of given sparse matrix to fit the format of spmv engine
- Parameters
weight_mat (ndarray) – transpose of the weight sparse matrix
shape (shape) – shape of the sparse matrix
- Returns
int – padded row size
int – padded col size
int – padded number of non-zero elements
array – row indices
array – col indices
array – non-zero elements
-
predict
(inp)¶ prepare input matrix for the engine, send all the matrices and instructions to kernel and get the result prediction matrix
- Parameters
inp (array) – input matrix
- Returns
result prediction matrix
- Return type
array