#ifndef _FUSIIN_LAYER_H_
#define _FUSIIN_LAYER_H_
#include "tensorOperate.h"
#include "tensor.h"

class FusionLayer : public TensorOperate 
{
    public:
        FusionLayer();
        FusionLayer(int ifType, int iID, int iMaxSeqNum, DevicesBatchDisptach *iDevicesBatchDisptach, const char *fusionStr);
        virtual ~FusionLayer();
        void SetLayerConfig(int ifType, int iID, int iMaxSeqNum, DevicesBatchDisptach *iDevicesBatchDisptach, const char *fusionStr);
        void ComputeAndCreateOutYInDTensorInfo();
        void CreateParaAndInstance();
        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);
        int GetBatchCATFusionInYDataOffset(int devID, int seqNum, int index);
        DATA_FUSION_TYPE GetInputDataFusionMethod();
                
    private:
        void SetChildLayerMomeryPointInitStatus();
        DATA_FUSION_TYPE GetFusionTypeByStr(const char *str);
        void CompuateOutYADD_DOTMethod(int devID, int seqNum);
        void ResultYInActionCATMethod(int devID, int seqNum);
        void ComputerOutD_DATA_CAT_N_HW_C(int devID, MemoryHandle *resultDCMem, MemoryHandle *tmpInDCMem, int seqNum, int index);
        void ComputerOutD_DATA_CAT_N_C_HW(int devID, MemoryHandle *resultDCMem, MemoryHandle *tmpInDCMem, int seqNum, int index);
        void ComputerOutDDotD(int devID, MemoryHandle *resultDCMem, int seqNum, int index);

        void RealeaseChildLayerMemory();
                
        DATA_FUSION_TYPE mFusionType;
        int *inChannels, *inHeight, *inWidth;
        int outChannels, outHeight, outWidth;
};

#endif
