#ifndef LCF_ATTENTION_H_
#define LCF_ATTENTION_H_
#include "tensorOperate.h"
#include "formatToLayer.h"
#include "fusionLayer.h"
#include "sumLayer.h"
#include "softMaxLayer.h"
#include "channelScaleLayer.h"
#include "filterLayer.h"
#include "linearLayer.h"

class AttentionLayer : public TensorOperate
{
    public:
        AttentionLayer();
        virtual ~AttentionLayer();
        void SetLayerConfig(int ifType, int iID, int iMaxSeqNum, DevicesBatchDisptach *iDevicesBatchDisptach, int iHVec, int QVNum);
        void ComputeAndCreateOutYInDTensorInfo();
        void CreateParaAndInstance();

        void ComputerYMemRealease(int devID);
        void ComputerDMemRealease(int devID);
        
        void CompuateOutY(int devID, int seqNum);
        void CompuateOutD(int devID, int seqNum);
        
        void UpdateWeightMain();
        int GetKVNum();
        
        void SetFilterMat(int devID, int seqNum, float *mat);
        void UpdateDSTD(float dStd);

    private:
        void SetChildLayerMomeryPointInitStatus();
        void RealeaseSubLayesInstance();
        void SetInOutPoint();
        FormatToLayer *mDataK;
        FormatToLayer *mDataV;
        FusionLayer *mFusionLayerOne;
        FormatToLayer *mDataQ;
                
        FusionLayer *mFusionLayerDot;
        SumLayer *mSumLayer;
        
        FusionLayer *mFusionLayerCat;
        LinearLayer *mLinearLayer;
        FilterLayer *mFilterLayer;
                
        SoftMaxLayer *mSoftMaxLayer;
        ChanneleSacle *mChanneleSacle;
        
        SumLayer *mSumLayerOut;
            
        int mHidVecDim;                   // hidden layer dim equal out dim
        int mKVNum;
};

#endif
