#ifndef _TENSOR_DATA_H_
#define _TENSOR_DATA_H_
#include "myXPU.h"
#include "myHead.h"
#include "myType.h"
#include "globalMemPoolFloat.h"
#include "memoryHandle.h"

class TensorInfo {
    public:
        TensorInfo();
        TensorInfo(int dim, int *dimSize);
        virtual ~TensorInfo();
        void SetTensorInfo(int iDims, int *iDimSize);
        void CopyInfo(TensorInfo *p);
        int GetDataSize();
        void UpdateOneDimSize(int idx, int newSize);
        void PrintTensorInfo();
        int mDims;
        int *mDimInfo;
        int mDataSize;
};

class TensorData {
    public:
        TensorData();
        TensorData(TensorInfo *info, int ifType, int devID, GlobalMemPoolFloat *iGMemMain, GlobalMemPoolFloat *iGMemBack);
        TensorData(int needLen, int ifType, int devID, GlobalMemPoolFloat *iGMemMain, GlobalMemPoolFloat *iGMemBack);
        TensorData(int iDims, int *iDimInfo, int ifType, int devID, GlobalMemPoolFloat *iGMemMain, GlobalMemPoolFloat *iGMemBack);
        TensorData(int iDims, int *iDimInfo, int ifType, int devID, GlobalMemPoolFloat *iGMemMain, GlobalMemPoolFloat *iGMemBack, int iHD);
        TensorData(TensorInfo *info, int ifType, int devID, GlobalMemPoolFloat *iGMemMain, GlobalMemPoolFloat *iGMemBack, int iHD);
        void SetTensorInfo(int iDims, int *iDimInfo, int ifType, int devID, GlobalMemPoolFloat *iGMemMain, GlobalMemPoolFloat *iGMemBack);
        void SetTensorInfo(int iDims, int *iDimInfo, int ifType, int devID, GlobalMemPoolFloat *iGMemMain, GlobalMemPoolFloat *iGMemBack, int iHD);
        virtual ~TensorData();
        int GetDimSize(int dimIndex);
        int GetDataSize();
        TensorInfo *GetTensorInfo();
        MemoryHandle *GetTensorMemHandle();
        void UpdateTensorData(MemoryHandle *pMHandle);
        void UpdateTensorData(int sfType, int srcDevID, int dOffset, MyVoid* dataBuff, MemType iMemType, int sOffser, int len);
        int fType;

    private:
        TensorInfo *mTensorInfo;
        MemoryHandle *mMemoryHandle;
        int mHID;
};

#endif
