gemx_uspmv_rt.py

class gemx_uspmv_rt.GemxUspmvRT(wgt, relu_list, xclbin_opts)

base class for using the GEMX library with USPMV engine in the machine learning examples

Parameters
  • xclbin_opts (dictionary) – information read from config_info.dat used to build the xclbin

  • wgt (list) – weight read from the model

  • relu_list (list) – list to show that for each layer, if relu or not

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 uspmv 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

  • in_scale (float) – input scale

Returns

result prediction matrix

Return type

array