#ifndef LCF_BIAS_H_
#define LCF_BIAS_H_
#include "tensorOperate.h"

class BiasLayer : public TensorOperate
{
    public:
        BiasLayer(int ifType, int iID, int iMaxSeqNum, DevicesBatchDisptach *iDevicesBatchDisptach, \
                  float iLambda, float iAlpha, float lb, float ld, int ls);
        virtual ~BiasLayer();
        void ComputeAndCreateOutYInDTensorInfo();
        void SaveLayerWeight(int n);
        void LoadLayerWeight();
        void ComputerTmpAllocMemSize(int devID, int *tmpCNHWDCMemSize, int *dpCMemSize, int *tmpBiasCMemSize, int seqNum);
        void ComputerWeightUpdateGrad(int devID, MyVoid *iResultBiasGradCMem, MyVoid *inD, int seqNum);
        void CompuateOutY(int devID, int seqNum);
        void CompuateOutD(int devID, int seqNum);
        void UpdateWeightEnter(int devID, MyVoid *inWGrad);
        void UpdateWeightMain();
        void ComputerYMemRealease(int devID);
        void ComputerDMemRealease(int devID);
        void CreateParaAndInstance();
        void CompGrad(int devID, int seqNum);

    private:
        void SetChildLayerMomeryPointInitStatus();
        void RealeaseChildLayerMemory();

        TensorData *mBias;                   // Handle for bias
        TensorData *mMomentumDb;             // Handle for momentumDb
        TensorData *mBGrad;                  // bias update grad      
        int inChannels, inHeight, inWidth;
        int outChannels, outHeight, outWidth;
};

#endif
