template class xf::hpc::mlp::Fcn

#include "fcn.hpp"

Overview

Fcn class, implement C = f(A*B+X)

Parameters:

t_FloatType matrix A B entry data type
t_XDataType matrix X entry data type
t_DdrWidth number of matrix elements in one memory word
t_XDdrWidth number of matrix elements in one memory word
t_aColMemWords the number of memory words in one row of the matrix A buffer
t_aRowMemWords the number of memory words in one column of the matrix A buffer
t_bColMemWords the number of memory words in one row of the matrix B buffer
t_maxWSize the maximun Weight matrix size 0 for unlimited size
t_maxBSize the maximun Bias vector size 0 for unlimited size
template <
    typename t_FloatType,
    typename t_XDataType,
    unsigned int t_DdrWidth,
    unsigned int t_XDdrWidth,
    unsigned int t_aColMemWords = 1,
    unsigned int t_aRowMemWords = 1,
    unsigned int t_bColMemWords = 1,
    unsigned int t_maxWSize = 0,
    unsigned int t_maxBSize = 0
    >
class Fcn

// typedefs

typedef GemmKernel <t_FloatType, t_XDataType, t_DdrWidth, t_XDdrWidth, t_aColMemWords, t_aRowMemWords, t_bColMemWords>::DdrWideType DdrWideType
typedef GemmKernel <t_FloatType, t_XDataType, t_DdrWidth, t_XDdrWidth, t_aColMemWords, t_aRowMemWords, t_bColMemWords>::DdrStream DdrStream
typedef FcnArgs FcnArgsType
typedef DdrWideType::t_TypeInt DdrIntType

Methods

FcnActivation

void FcnActivation (
    DdrStream& p_inS,
    DdrStream& p_outS,
    unsigned int p_blocks,
    t_FloatType (*) (t_FloatType) f_act,
    int16_t p_args
    )

FcnActivation applies activation function to the FCN output.

Parameters:

p_inS is the input stream from FCN
p_outS is the output stream after applying activation
p_blocks is the number of blocks to be processed
f_act is the activation function
p_args is the arguments passed to the activation function

FcnBlocks

void FcnBlocks (
    DdrIntType* p_aAddr,
    DdrIntType* p_bAddr,
    DdrIntType* p_cAddr,
    DdrIntType* p_xAddr,
    unsigned int p_aColBlocks,
    unsigned int p_aRowBlocks,
    unsigned int p_bColBlocks,
    unsigned int p_aLd,
    unsigned int p_bLd,
    unsigned int p_cLd,
    unsigned int p_xLd,
    unsigned int p_transpBlocks,
    t_FloatType (*) (t_FloatType) f_act,
    FcnArgsType& p_Args
    )

FcnBlocks runs the FCN for input matrices.

Parameters:

p_aAddr the base address of matrix A in external memory
p_bAddr the base address of matrix B in external memory
p_cAddr the base address of matrix C in external memory
p_xAddr the base address of matrix X in external memory
p_aColBlocks the No. blocks along matrix X cols
p_aRowBlocks the No. blocks along matrix X rows
p_bColBlocks the No. blocks along matrix X cols
p_aLd the matrix A word leading dimention
p_bLd the matrix B word leading dimention
p_cLd the matrix C word leading dimention
p_xLd the matrix X word leading dimention
f_act the activation function
p_Args the arguments for fcn operation
p_transpBlocks the number of blocks for compute

runFcn

void runFcn (
    DdrIntType* p_DdrRd,
    DdrIntType* p_DdrWr,
    FcnArgsType& p_Args
    )

runFcn launch fcn operation with given arguments

Parameters:

p_DdrRd the DDR/HBM address for input data
p_DdrWr the DDR/HBM address for output data
p_Args the arguments for fcn