Specifications - 2023.2 English

Vitis Libraries

Release Date
2023-12-20
Version
2023.2 English

The DATAFLOW directive is applied to the top function. User could specify the individual sub-function implementiontations using a configuration class derived from the following basic class by redefining the appropriate class member:

template <int RowsColsA, typename InputType, typename OutputType>
struct choleskyInverseTraits {
    typedef InputType CHOLESKY_OUT;
    typedef choleskyTraits<false, RowsColsA, InputType, InputType> CHOLESKY_TRAITS;
    typedef InputType BACK_SUBSTITUTE_OUT;
    typedef backSubstituteTraits<RowsColsA, InputType, InputType> BACK_SUBSTITUTE_TRAITS;
    typedef matrixMultiplyTraits<NoTranspose,
                                 ConjugateTranspose,
                                 RowsColsA,
                                 RowsColsA,
                                 RowsColsA,
                                 RowsColsA,
                                 InputType,
                                 OutputType>
        MATRIX_MULTIPLY_TRAITS;
};

The configuration class is supplied to the xf::solver::choleskyInverse function as a template paramter as follows. The sub-functions are executed sequentially: Cholesky, back substitution, and matrix multiply. The implementation selected for these sub-functions determines the resource utilization and function throughput/latency of the Inverse function.

template <int RowsColsA,
          typename InputType,
          typename OutputType,
          typename CholeskyInverseTraits = choleskyInverseTraits<RowsColsA, InputType, OutputType> >
void choleskyInverse(hls::stream<InputType>& matrixAStrm,
                      hls::stream<OutputType>& matrixInverseAStrm,
                      int& cholesky_success) {
#pragma HLS DATAFLOW
    hls::stream<typename CholeskyInverseTraits::CHOLESKY_OUT> matrixUStrm;
#pragma HLS STREAM variable = matrixUStrm depth = 16
    hls::stream<typename CholeskyInverseTraits::BACK_SUBSTITUTE_OUT> matrixInverseUStrm;
#pragma HLS STREAM variable = matrixInverseUStrm depth = 16
    int U_singular;

    // Run Cholesky, get upper-triangular result
    const bool LOWER_TRIANGULAR = false;
    cholesky_success = cholesky<LOWER_TRIANGULAR, RowsColsA, InputType, typename CholeskyInverseTraits::CHOLESKY_OUT, typename CholeskyInverseTraits::CHOLESKY_TRAITS>(matrixAStrm, matrixUStrm);

    // Run back-substitution to compute U^-1
    backSubstitute<RowsColsA, typename CholeskyInverseTraits::CHOLESKY_OUT, typename CholeskyInverseTraits::BACK_SUBSTITUTE_OUT, typename CholeskyInverseTraits::BACK_SUBSTITUTE_TRAITS>(matrixUStrm, matrixInverseUStrm, U_singular);

    // A^-1 = U^-1*U^-t (equivalent to L-t*L-1)
    matrixMultiply<NoTranspose, ConjugateTranspose, RowsColsA, RowsColsA, RowsColsA, RowsColsA, typename CholeskyInverseTraits::BACK_SUBSTITUTE_OUT, OutputType, typename CholeskyInverseTraits::MATRIX_MULTIPLY_TRAITS>(matrixInverseUStrm, matrixInverseAStrm);
}