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

// norm on Channels of one pic.
class L2NormLayer : public TensorOperate
{
    public:
        L2NormLayer(int ifType, int iID, int iMaxSeqNum, DevicesBatchDisptach *iDevicesBatchDisptach, float iScale);
        virtual ~L2NormLayer();
        void ComputeAndCreateOutYInDTensorInfo();
        void SaveLayerWeight(int n);
        void LoadLayerWeight();
        void CompuateOutY(int devID, int seqNum);
        void CompuateOutD(int devID, int seqNum);
        void ComputerYMemRealease(int devID);
        void ComputerDMemRealease(int devID);
        void CreateParaAndInstance();
        TensorData *GetXXT(int devID, int seqNum);

    private:
        void SetChildLayerMomeryPointInitStatus();
        void RealeaseChildLayerMemory();
        TensorData *mXXT;                  // mXXT[batchNum][inHeight][inWidth] which value is sqrt(X.X^t)
        float mScale;                      // defualt is 20.0
        int inChannels, inHeight, inWidth;
        int outChannels, outHeight, outWidth;
};
#endif
