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

class MaxPoolLayer : public TensorOperate
{
    public:
        MaxPoolLayer(int ifType, int iID, int iMaxSeqNum, DevicesBatchDisptach *iDevicesBatchDisptach, const char* inTypeStr, \
                     MaxPoolLayer* inLayer, int inKSize, int rtPad, int rbPad, int clPad, int crPad);
        virtual ~MaxPoolLayer();
        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 *GetCIndexMat(int devID, int seqNum);
        TensorData *GetRIndexMat(int devID, int seqNum);

    private:
        void SetChildLayerMomeryPointInitStatus();
        void RealeaseChildLayerMemory();
        TensorData *mRIndexMat;                // Row MAX value index matrix [batchNum][outChannels][IF MAXPOOL: outHeight ; IF MAXUS: inHeight][IF MAXPOOL: outWidth; IF MAXUS: inWidth]
        TensorData *mCIndexMat;                // Col MAX value index matrix [batchNum][outChannels][IF MAXPOOL: outHeight ; IF MAXUS: inHeight][IF MAXPOOL: outWidth; IF MAXUS: inWidth]
        int kernelSize;                       // sample kernel
        int pType;                            // sample type: pool or upsample
        MaxPoolLayer *mSaveLayer;             // for MAXPOOL saveLayId not use can set any value
        int mrtPad, mrbPad, mclPad, mcrPad;   // PAD
        
        int inChannels, inHeight, inWidth;
        int outChannels, outHeight, outWidth;
};

#endif
