Vitis-Tutorials icon indicating copy to clipboard operation
Vitis-Tutorials copied to clipboard

Can elaborate more on matrix mul breakdown in //DFT Designs on AI Engine//

Open eerobert opened this issue 1 year ago • 1 comments

Maybe my algebra is not good enough. Would like to know more on how to breakdown (1 * 16) * (16* 16) matrix into multiple of (1 * 2) * (2 * 4)

Thanks

eerobert avatar Sep 26 '24 13:09 eerobert

Hi @eerobert For this type of generic question, the forums would be better (https://adaptivesupport.amd.com/s/?language=en_US). Github issue would be more for issues with the tutorials.

Anyway let me give a quick answer. Let just think about 2 (12) * (22) and 1 (14) * (42) matrix multiplication (i.e. splitting the operation in 2 matrices)

mat1 = [a b] mat2 = [c d] mat3 = [a b c d] mat4 = [e f] ................[g h] mat5= [i j] ................[k l] mat6 = [e f] ................[g h] ................[i j] ................[k l]

mat1 * mat4 = [(ae+bg) (af+bh)] mat2 * mat4 = [(ci + dk) (cj+dl)]

mat3 * mat6 = [(ae+bg+ci + dk) (af+bh+cj+dl)] = mat1 * mat4 + mat2 * mat4

So you can see that this would be a sum of matrices in that side. This is done in the AIE using the accumulator in the columns.

Now if you add more columns to the second matrices what happens? Do the expression on paper you will see that the columns are independent, so you can just store the matrix multiplication result side by side. Or do the testing in matlab or python

xflorentw avatar Oct 03 '24 08:10 xflorentw