MNN/source/backend/opencl/execution/buffer/ConvSubgroupBufExecution.hpp

65 lines
2.1 KiB
C++
Raw Normal View History

2023-07-31 14:24:48 +08:00
//
// ConvSubgroupBufExecution.hpp
// MNN
//
// Created by MNN on 2023/07/01.
// Copyright © 2018, Alibaba Group Holding Limited
//
#ifndef MNN_OPENCL_BUFFER_CLOSED
#ifdef MNN_SUPPORT_INTEL_SUBGROUP
#ifndef ConvSubgroupBufExecution_hpp
#define ConvSubgroupBufExecution_hpp
2024-04-19 11:58:21 +08:00
#include "backend/opencl/execution/image/CommonExecution.hpp"
2023-07-31 14:24:48 +08:00
namespace MNN {
namespace OpenCL {
2024-04-19 11:58:21 +08:00
struct ConvSubgroupBufResource {
const Convolution2DCommon* mConv2dCommonParams;
const Convolution2D* mConv2dParams;
std::vector<int> mStrides{1, 1};
std::vector<int> mDilations{1, 1};
std::shared_ptr<Tensor> mFilter;
std::shared_ptr<Tensor> mBias;
int mKernelWidth;
int mKernelHeight;
int mOutputChannel;
int mInputChannel;
std::set<std::string> mBuildOptions;
};
2023-07-31 14:24:48 +08:00
2024-04-19 11:58:21 +08:00
class ConvSubgroupBuf : public CommonExecution {
2023-07-31 14:24:48 +08:00
public:
virtual ~ConvSubgroupBuf();
ConvSubgroupBuf(const std::vector<Tensor*>& inputs, const std::vector<Tensor*>& outputs, const MNN::Op* op,
Backend* backend);
2024-04-19 11:58:21 +08:00
ConvSubgroupBuf(std::shared_ptr<ConvSubgroupBufResource> resource, const MNN::Op* op, Backend* backend);
2023-07-31 14:24:48 +08:00
2024-04-19 11:58:21 +08:00
virtual ErrorCode onEncode(const std::vector<Tensor*>& inputs, const std::vector<Tensor*>& outputs) override;
virtual bool onClone(Backend* bn, const Op* op, Execution** dst) override;
2023-07-31 14:24:48 +08:00
static bool valid(const Convolution2DCommon* common, const Tensor* input, const Tensor* output, int maxWidth,
int maxHeight, int limit = 8192);
private:
void transformWeight(const Tensor* weightDest, const Tensor* source);
OpenCLBackend* mOpenCLBackend;
2024-04-19 11:58:21 +08:00
std::shared_ptr<ConvSubgroupBufResource> mResource;
2023-07-31 14:24:48 +08:00
std::vector<int> mPaddings{0, 0};
std::vector<uint32_t> mGlobalWorkSize{1, 1, 1};
std::vector<uint32_t> mLocalWorkSize{1, 1, 1, 1};
std::vector<uint32_t> mTranseGlobalWorkSize{1, 1, 1};
std::vector<uint32_t> mTranseLocalWorkSize{1, 1, 1, 1};
std::shared_ptr<Tensor> mSource;
bool mNeedTranse = false;
2024-04-19 11:58:21 +08:00
2023-07-31 14:24:48 +08:00
};
} // namespace OpenCL
} // namespace MNN
#endif /* ConvSubgroupBufExecution_hpp */
#endif /* MNN_SUPPORT_INTEL_SUBGROUP */
#endif /* MNN_OPENCL_BUFFER_CLOSED */