#ifndef LCF_OPTIMIZER_H_
#define LCF_OPTIMIZER_H_
#include "myXPU.h"
#include "myType.h"
#include "myHead.h"
#include "globalMemPoolFloat.h"

class Optimizer {
    public:
        static void SGDM(int fType, int devID, MyVoid *w, MyVoid *dm, MyVoid *dw, int len, float l2, float alpha, float ln, GlobalMemPoolFloat *cMem);
        static void SGD(int fType, int devID, MyVoid *w, MyVoid *dm, MyVoid *dw, int len, float ln);
        static void AdaGrad(int fType, int devID, MyVoid *w, MyVoid *dm, MyVoid *dw, int len, float ln);
        static void RMSprop(int fType, int devID, MyVoid *w, MyVoid *dm, MyVoid *dw, int len, float ln);
        static void Adam(int fType, int devID, MyVoid *w, MyVoid *dm, MyVoid *dw, int len, float ln);
        static void GradClipByGlobalNormCPU(int fType, MyVoid *numArr, int numLen, float clipNorm);
        static void GradClipByNormCPU(int fType, MyVoid *numArr, int numLen, int tensorLen, float clipNorm);      
        #ifdef _CMEM_USE_GPU_
        static void GradClipByGlobalNormGPU(int fType, int devID, MyVoid *numArr, int numLen, float clipNorm, GlobalMemPoolFloat *cMem);
        static void GradClipByNormGPU(int fType, int devID, MyVoid *numArr, int numLen, int tensorLen, float clipNorm, GlobalMemPoolFloat *cMem);
        #endif       
        static void GradClipByGlobalNorm(int fType, int devID, MyVoid *numArr, int numLen, float clipNorm, GlobalMemPoolFloat *cMem);
        static void GradClipByNorm(int fType, int devID, MyVoid *numArr, int numLen, int tensorLen, float clipNorm, GlobalMemPoolFloat *cMem);
};
#endif
