2020-11-05 16:41:56 +08:00
|
|
|
//
|
|
|
|
// ConvDepthWiseExecution.hpp
|
|
|
|
// MNN
|
|
|
|
//
|
|
|
|
// Created by MNN on 2020/08/18.
|
|
|
|
// Copyright © 2018, Alibaba Group Holding Limited
|
|
|
|
//
|
|
|
|
|
|
|
|
#ifndef ConvDepthWiseExecution_hpp
|
|
|
|
#define ConvDepthWiseExecution_hpp
|
|
|
|
|
|
|
|
#include <vector>
|
|
|
|
#include "backend/cuda/core/CUDABackend.hpp"
|
|
|
|
#include "core/Execution.hpp"
|
|
|
|
namespace MNN {
|
|
|
|
namespace CUDA {
|
2022-02-18 11:30:27 +08:00
|
|
|
|
|
|
|
struct constBuffer {
|
|
|
|
int pad[2];
|
|
|
|
int kernelSize[2];
|
|
|
|
int stride[2];
|
|
|
|
int dilate[2];
|
|
|
|
int inputSize[2];
|
|
|
|
int outputSize[2];
|
|
|
|
int channel;
|
|
|
|
int total;
|
|
|
|
int batch;
|
|
|
|
float minValue = -65504.0f;
|
|
|
|
float maxValue = 65504.0f;
|
|
|
|
} uConstant;
|
|
|
|
|
2020-11-05 16:41:56 +08:00
|
|
|
class ConvDepthWiseExecution : public Execution {
|
|
|
|
public:
|
2022-02-18 11:30:27 +08:00
|
|
|
struct Resource {
|
|
|
|
std::shared_ptr<Tensor> weightTensor;
|
|
|
|
std::shared_ptr<Tensor> biasTensor;
|
|
|
|
void* mFilter;
|
|
|
|
void* mBias;
|
|
|
|
};
|
|
|
|
ConvDepthWiseExecution(const Op *op, Backend *bn, std::shared_ptr<Resource> resource);
|
2020-11-05 16:41:56 +08:00
|
|
|
virtual ~ConvDepthWiseExecution();
|
|
|
|
virtual ErrorCode onResize(const std::vector<Tensor *> &inputs, const std::vector<Tensor *> &outputs) override;
|
|
|
|
virtual ErrorCode onExecute(const std::vector<Tensor *> &inputs, const std::vector<Tensor *> &outputs) override;
|
|
|
|
|
|
|
|
protected:
|
2020-12-15 14:12:35 +08:00
|
|
|
std::pair<void*, int> mConstBuffer;
|
2020-11-05 16:41:56 +08:00
|
|
|
const Op *mOp;
|
|
|
|
int mTotalCount;
|
2022-02-18 11:30:27 +08:00
|
|
|
constBuffer parameters;
|
|
|
|
std::shared_ptr<Resource> mResource;
|
2020-11-05 16:41:56 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
class DeconvDepthWiseExecution : public ConvDepthWiseExecution {
|
|
|
|
public:
|
2022-02-18 11:30:27 +08:00
|
|
|
DeconvDepthWiseExecution(const Op *op, Backend *bn, std::shared_ptr<Resource> resource) : ConvDepthWiseExecution(op, bn, resource) {
|
2020-11-05 16:41:56 +08:00
|
|
|
// Do nothing
|
|
|
|
}
|
|
|
|
virtual ~DeconvDepthWiseExecution() {
|
|
|
|
// Do nothing
|
|
|
|
}
|
|
|
|
virtual ErrorCode onResize(const std::vector<Tensor *> &inputs, const std::vector<Tensor *> &outputs) override;
|
|
|
|
virtual ErrorCode onExecute(const std::vector<Tensor *> &inputs, const std::vector<Tensor *> &outputs) override;
|
|
|
|
};
|
|
|
|
} // namespace CUDA
|
|
|
|
} // namespace MNN
|
|
|
|
#endif
|