Python test functions¶
test.py
-
class
test.
Test
¶ class provide helper functions to create test cases
-
cmp
(A, B)¶ compare if two arrays are totally the same
- Parameters
A (ndarray) – dense matrix in the host memory
B (ndarray) – dense matrix in the host memory
-
cmpWithinTolerance
(A, B)¶ compare if two arrays are equal within tolerance
- Parameters
A (ndarray) – dense matrix in the host memory
B (ndarray) – dense matrix in the host memory
-
multiply_and_cmp
(C, A, B, X, m, n, post_scale, pRelu_val=[1, 0])¶ calculate matrix multiply golden result matrix C ( C = relu ((A * B + bias) * postScale >> postShift) ) on CPU and compare result to FPGA result.
will save the results to text files if not equal
- Parameters
C (ndarray) – output dense matrix in the host memory
A (ndarray) – dense matrix in the host memory
B (ndarray) – dense matrix in the host memory
X (ndarray) – dense matrix in the host memory
post_scale ((int,int)) – (postScale, postShift)
pRelu_val ((int,int)) – (PReLUScale, PReLUAlpha)
-
test_basic_randint
(PE, xclbin_opts, post_scale, max_dim)¶ generate random input matrices with random sizes and run the test
- Parameters
PE (int) – number of kernels - 1
post_scale ((int,int)) – (postScale, postShift)
max_dim (int) – control the max size generated by the test
-
test_basic_size
(m, k, n, xclbin_opts, PE=0, post_scale=[1, 0])¶ generate random input matrices with given sizes and run the test
- Parameters
m (int) – number of rows of first dense matrix
k (int) – number of cols of first dense matrix
n (int) – number of cols of second dense matrix
xclbin_opts (dictionary) – information read from config_info.dat used to build the xclbin
PE (int) – number of kernels - 1
post_scale ((int,int)) – (postScale, postShift)
-
get_freq
(command)¶ return frequency of the xclbin
- Parameters
command (string) – path to the xbutil in the machine
-
-
class
test.
FcnTest
¶ class provide helper functions to create FCN test cases
-
test_basic_randint
(PE, xclbin_opts, post_scale, RELU_scale, max_dim)¶ generate random input matrices with random sizes and run the test
- Parameters
PE (int) – number of kernels - 1
post_scale ((int,int)) – (postScale, postShift)
RELU_scale ((int,int)) – (PReLUScale, PReLUAlpha)
max_dim (int) – control the max size generated by the test
-
-
class
test.
SpmvTest
¶ class provide helper functions to create spmv test cases
-
multiply_and_cmp_spmv
(row, col, data, m, k, nnz, B, C)¶ calculate sparse matrix multiply golden result matrix C on CPU and compare result to FPGA result.
- Parameters
row (ndarray) – sparse matrix’s row indices
col (ndarray) – sparse matrix’s col indices
data (ndarray) – sparse matrix’s non-zero elements
m (int) – number of rows for this sparse matrix
k (int) – number of cols for this sparse matrix
nnz (int) – number of non-zero elements of this sparse matrix
C (ndarray) – output dense matrix in the host memory
B (ndarray) – dense matrix in the host memory
-
fillMod
(B, size, Max=32764)¶ fill array with values (not random)
- Parameters
B (ndarray) – dense matrix in the host memory
size (int) – size of the array
Max (int) – control the max value filled to the array
-