gemx_rt.py

class gemx_rt.GemxRT(xclbin_opts, wgt, bias, wgt_scale, bias_scale, post_scale)

base class for using the GEMX library 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

  • bias (list) – bias read from the model

  • wgt_scale (list) – Quantization parameters multiple with weight matrices

  • bias_scale (list) – Quantization parameters multiple with bias matrices

  • post_scale (list) – Quantization parameters multiple with output matrices

get_padded_shape(shape, min_row, min_col)

return padded sizes for row and col

Parameters
  • shape (shape) – a tuple of (actual row, actual col)

  • min_row (int) – minimal row size supported

  • min_col (int) – minimal col size supported

Returns

padded row size, padded col size

Return type

tuple

format_for_fpga(nparr, min_row, min_col)

pad the numpy array with given minimal row size and col size

Parameters
  • nparr (ndarray) – array need to be padded

  • min_row (int) – minimal row size supported

  • min_col (int) – minimal col size supported

Returns

padded numpy array

Return type

ndarray

predict(inp, in_scale)

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