// // ConvBufLowMemoryExecution.hpp // MNN // // Created by MNN on 2023/10/12. // Copyright © 2018, Alibaba Group Holding Limited // #ifdef MNN_LOW_MEMORY #ifndef MNN_OPENCL_BUFFER_CLOSED #ifndef ConvBufLowMemoryExecution_hpp #define ConvBufLowMemoryExecution_hpp #include "core/ConvolutionCommon.hpp" #include "ConvBufExecution.hpp" namespace MNN { namespace OpenCL { class ConvBufLowMemoryExecution : public ConvBufCommonExecution, public CommonExecution { public: ConvBufLowMemoryExecution(const std::vector &inputs, const std::vector &outputs, const MNN::Op *op, Backend *backend); ConvBufLowMemoryExecution(std::shared_ptr resource, const MNN::Op* op, Backend* backend); virtual ~ConvBufLowMemoryExecution(); virtual ErrorCode onResize(const std::vector &inputs, const std::vector &outputs) override; virtual ErrorCode onExecute(const std::vector &inputs, const std::vector &outputs) override; virtual bool onClone(Backend* bn, const Op* op, Execution** dst) override; private: int getExecuteTime(); void getInfoFromOpLowMemory(void *weight_ptr); void set1x1WeightLowMemory(); void setGeneralWeightLowMemory(); void tuneGeneralCaseLowMemory(Tensor * input, Tensor * output); void useFPWeightGemmLowMemory(Tensor * input, Tensor * output); void tuneGemvLowMemory(Tensor * input, Tensor * output); void tuneGemmLowMemory(Tensor * input, Tensor * output); bool convertToQuantWeight1x1Buffer(cl::Buffer input); std::vector mPaddings{0, 0}; std::vector mGlobalWorkSize{1, 1, 1}; std::vector mLocalWorkSize{1, 1, 1, 1}; void *mFilterDataPtr = nullptr; bool mUseFPWeight = false; std::shared_ptr mConvGemmInpTensor; std::shared_ptr mConvGemmOutTensor; std::shared_ptr mConvGemmWeightTensor; std::shared_ptr mBufferToConv1x1Kernel = nullptr; uint32_t batchConvMode = 0; // batch > 1 convolution input arrage mode. 0 is need tune; 1 arrage to n/4chw4; 2 arrage to c/4hwn4 std::shared_ptr mStrassenComputor; cl_mem mInputImage1d = nullptr; cl_mem mGemmInputImage1d = nullptr; }; } // namespace OpenCL } // namespace MNN #endif /* ConvBufLowMemoryExecution_hpp */ #endif /* MNN_OPENCL_BUFFER_CLOSED */ #endif /* MNN_LOW_MEMORY */