// // ConvExecution.hpp // MNN // // Created by MNN on 2019/01/31. // Copyright © 2018, Alibaba Group Holding Limited // #ifndef ConvExecution_hpp #define ConvExecution_hpp #include "core/Execution.hpp" #include #include #include #include #include "backend/opencl/core/OpenCLBackend.hpp" #include "backend/opencl/core/OpenCLRunningUtils.hpp" #include "CommonExecution.hpp" namespace MNN { namespace OpenCL { struct ConvResource { const Convolution2D *mConv2dParams; const Convolution2DCommon *mConv2dCommonParams; std::shared_ptr mFilter; std::shared_ptr mBias; std::shared_ptr mSlope; std::shared_ptr mKernelBuffer; std::shared_ptr dequantScaleOffset; std::vector mStrides{1, 1}; std::vector mDilations{1, 1}; std::set mBuildOptions; bool mIsTurn = false; bool mConv1x1Opt = false; bool mWeightUseBuffer = false; bool gemmOpt = false; int mBlockSize; int mKernelWidth; int mKernelHeight; int mOutputChannel; int mInputChannel; bool mRelu = false; bool mRelu6 = false; bool mPrelu = false; uint32_t mMaxWorkGroupSize; }; class ConvCommonExecution { public: ConvCommonExecution(const Convolution2D *op, Backend *backend); ConvCommonExecution(const Op *op, Backend *backend, bool isExtra); ConvCommonExecution(Backend *backend) { mOpenCLBackend = static_cast(backend); } virtual ~ConvCommonExecution(); protected: std::shared_ptr mResource; OpenCLBackend *mOpenCLBackend; bool mConvComValid = true; }; class ConvExecution : public ConvCommonExecution, public CommonExecution { public: ConvExecution(const std::vector &inputs, const std::vector &outputs, const MNN::Op *op, Backend *backend, bool isExtra = false); ConvExecution(std::shared_ptr resource, const Op* op, Backend* backend); virtual ~ConvExecution(); virtual ErrorCode onEncode(const std::vector &inputs, const std::vector &outputs) override; virtual bool onClone(Backend* bn, const Op* op, Execution** dst) override; static std::shared_ptr getBias(OpenCLBackend *backend, const Convolution2D *conv); private: std::vector mPaddings{0, 0}; std::vector mGlobalWorkSize{1, 1, 1}; std::vector mLocalWorkSize{1, 1, 1, 1}; }; } // namespace OpenCL } // namespace MNN #endif /* ConvExecution_hpp */