spcl/gemm_hls

Transpose of the input matrix B

Closed this issue · 1 comments

Hi,
I'm implementing my work based on the GEMM project, it involves matrix computation of A×B, transpose(A)×B, and A×transpose(B).

  1. Since Transpose(A) has been implemented in the project, I plan to use if...else..statement as follows, will there be any problem if I write like this?

bool Trans_A;
if (Trans_A){ //the code below is same as Line 72-86 in Top.cpp
ReadA();
#ifdef MM_CONVERT_A
TransposeA();
ConvertWidthA();
#else
TransposeA();
#endif
}else{
ReadATransposed();
ConvertWidthATransposed(); }

  1. For Transpose(B), can I use the same code as Transpose(A)? It seems that the condition and implementation of ConvertA and ConvertB are different.

It is not trivial to do both transpose and non-transpose in the same compilation of the kernel, because the streams that connect the memory modules and the kernels are fixed at compile-time, and cannot have more than one producer.

You can compile two separate kernels, where one is transposed, and the other is not. You can even link them together to exist on the FPGA at the same time.

There is no support for transposing B, but it would be quite nasty if you want to read both A and B transposed. Is there maybe an algebraic identity that can help you there, like (A B^T)^T = B A^T?