MNN/source/backend/opencl/execution/image/LayerNormExecution.hpp

42 lines
1015 B
C++
Raw Normal View History

2023-07-18 09:36:26 +08:00
//
// LayerNormExecution.hpp
// MNN
//
// Created by MNN on 2023/07/05.
// Copyright © 2018, Alibaba Group Holding Limited
//
#ifndef LayerNormExecution_hpp
#define LayerNormExecution_hpp
2024-04-19 11:58:21 +08:00
#include "CommonExecution.hpp"
2023-07-18 09:36:26 +08:00
namespace MNN {
namespace OpenCL {
2024-04-19 11:58:21 +08:00
class LayerNormExecution : public CommonExecution {
2023-07-18 09:36:26 +08:00
public:
LayerNormExecution(const std::vector<Tensor *> &inputs, const MNN::Op *op, Backend *backend);
virtual ~LayerNormExecution() = default;
2024-04-19 11:58:21 +08:00
virtual ErrorCode onEncode(const std::vector<Tensor *> &inputs, const std::vector<Tensor *> &outputs) override;
2023-07-18 09:36:26 +08:00
private:
int getLocalSize(int size, int maxGroupSize);
OpenCLBackend *mOpenCLBackend;
int axis_size = 0;
int group_ = 1;
2024-04-19 11:58:21 +08:00
bool RMSNorm = false;
2023-07-18 09:36:26 +08:00
float epsilon_ = 0.001;
std::shared_ptr<cl::Buffer> mGammaBuffer;
std::shared_ptr<cl::Buffer> mBetaBuffer;
bool has_gamma_beta_ = false;
2023-12-27 17:26:44 +08:00
uint32_t mMaxWorkGroupSize;
2023-07-18 09:36:26 +08:00
};
} // namespace OpenCL
} // namespace MNN
#endif /* LayerNormExecution_hpp */