This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

MSP430FR5994: LEA matrix dimension constraints for matrix multiplication

Part Number: MSP430FR5994

Hi,

Sorry, this question has probably been asked before, but I've run some tests (on small matrices) and i'm confused regarding the matrix dimension constraints, when performing matrix multiply using LEA (dsplib - msp_matrix_mpy_q15). There appears to be some discrepancies with the API documentation.

1) What are the matrix dimension constraints ?

E.g.

When HxW of A and B are : (1x4) * (4x2) and using the following values :

_q15 matA[1][4] = {
                         {_Q15(+0.01), _Q15(+0.02), _Q15(+0.03), _Q15(+0.04)}
                        };
    _q15 matB[4][2] = {
                         {_Q15(+0.005), _Q15(+0.01)},
                         {_Q15(+0.01), _Q15(+0.005)},
                         {_Q15(+0.005), _Q15(+0.01)},
                         {_Q15(+0.01), _Q15(+0.005)}
                        };

I get the correct results : 26, 22

But in the dsplib API , the matrix dimensions are supposed to be multiples of 2. If so, how come the above 2 input matrices result is correct ?

Is this an edge case where a 1xW matrix A works fine ? I have tested A(5x4) x B(4x2), this also works fine.

2) Can you confirm if the API documentation is accurate regarding the matrix dimensions needing to be multiples of 2 ?

http://software-dl.ti.com/msp430/msp430_public_sw/mcu/msp430/DSPLib/latest/exports/html/structmsp__matrix__mpy__q15__params.html

3) Does ONLY the ColA = RowB = must be multiple of 2 ? Does ColB also need to be multiple of 2 ?

As msp_matrix_mpy_q15 works like a vector-matrix multiplication (iteratively A_row x MatB), then does the rows of matrix A also need to be a multiple of 2 ?

thanks

  • Hi Rosh,

    As the API guide mentions, we recommend that the rows and columns of the matrices must be multiples of 2 for the functions to work properly in all scenarios. As Brent mentioned in the following thread, you can zero-pad your matrices if their dimensions are not multiples of 2.

    MSP430FR5992: MSP-DSPLib & msp_matrix_mpy_q15

    As Walter mentioned in the Original question link at the top of this thread, there is not a significant execution time benefit to using LEA for small matrices due to the overhead of setting up LEA. LEA brings a lot of benefit when the matrices sizes are large. Otherwise, the CPU and/or the MPY32 module may be adequate and even faster.

    I hope this helps.

    Regards,

    James

**Attention** This is a public forum