MNN/source/backend/metal/MetalRaster.hpp

39 lines
1.1 KiB
C++
Raw Normal View History

2019-04-17 10:49:11 +08:00
//
2020-11-05 16:41:56 +08:00
// MetalRaster.hpp
2019-04-17 10:49:11 +08:00
// MNN
//
2020-11-05 16:41:56 +08:00
// Created by MNN on 2020/05/09.
2019-04-17 10:49:11 +08:00
// Copyright © 2018, Alibaba Group Holding Limited
//
2020-11-05 16:41:56 +08:00
#ifndef MetalRaster_hpp
#define MetalRaster_hpp
2019-04-17 10:49:11 +08:00
2019-12-27 22:16:57 +08:00
#import "core/Execution.hpp"
2019-04-17 10:49:11 +08:00
#import "MetalDefine.h"
2020-11-05 16:41:56 +08:00
#include <map>
2019-04-17 10:49:11 +08:00
#if MNN_METAL_ENABLED
namespace MNN {
2020-11-05 16:41:56 +08:00
class MetalRaster : public Execution {
2019-04-17 10:49:11 +08:00
public:
2020-11-05 16:41:56 +08:00
MetalRaster(Backend *backend);
virtual ~MetalRaster() = default;
2019-04-17 10:49:11 +08:00
virtual ErrorCode onResize(const std::vector<Tensor *> &inputs, const std::vector<Tensor *> &outputs) override;
2020-11-05 16:41:56 +08:00
virtual ErrorCode onExecute(const std::vector<Tensor *> &inputs, const std::vector<Tensor *> &outputs) override;
2019-04-17 10:49:11 +08:00
private:
2020-11-05 16:41:56 +08:00
std::map<Tensor*, std::shared_ptr<Tensor>> mTempInput;
std::vector<std::tuple<id<MTLBuffer>, id<MTLBuffer>, MTLSize, MTLSize> > mTempInputCopy;
2019-04-17 10:49:11 +08:00
std::shared_ptr<Tensor> mTempOutput;
2020-11-05 16:41:56 +08:00
bool mNeedZero = false;
id<MTLBuffer> mOutputPtr;
bool mFast = false;
id<MTLComputePipelineState> mBlitPipeline;
std::vector<id<MTLBuffer>> mShapeTemp;
2019-04-17 10:49:11 +08:00
};
} // namespace MNN
#endif /* MNN_METAL_ENABLED */
2020-11-05 16:41:56 +08:00
#endif /* MetalRaster_hpp */