2019-04-17 10:49:11 +08:00
|
|
|
//
|
|
|
|
// WrapExecution.hpp
|
|
|
|
// MNN
|
|
|
|
//
|
|
|
|
// Created by MNN on 2018/09/03.
|
|
|
|
// Copyright © 2018, Alibaba Group Holding Limited
|
|
|
|
//
|
|
|
|
|
|
|
|
#ifndef WrapExecution_hpp
|
|
|
|
#define WrapExecution_hpp
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <memory>
|
2019-12-27 22:16:57 +08:00
|
|
|
#include "core/Backend.hpp"
|
|
|
|
#include "core/Execution.hpp"
|
|
|
|
#include "core/Macro.h"
|
2019-04-17 10:49:11 +08:00
|
|
|
|
|
|
|
namespace MNN {
|
|
|
|
|
|
|
|
/** execution wrapper. hiding cross-backend tensor converting. */
|
2020-02-26 23:08:52 +08:00
|
|
|
class MNN_PUBLIC WrapExecution : public Execution {
|
2019-04-17 10:49:11 +08:00
|
|
|
public:
|
|
|
|
/**
|
|
|
|
* @brief initializer.
|
|
|
|
* @param CPUBackend CPU backend.
|
|
|
|
* @param execution execution to be wrapped.
|
|
|
|
*/
|
2020-11-05 16:41:56 +08:00
|
|
|
WrapExecution(Backend *CPUBackend, std::shared_ptr<Execution> execution, bool isStatic = true);
|
2019-04-17 10:49:11 +08:00
|
|
|
/**
|
|
|
|
* @brief deinitializer.
|
|
|
|
*/
|
|
|
|
virtual ~WrapExecution() = default;
|
|
|
|
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;
|
|
|
|
|
|
|
|
private:
|
2020-11-05 16:41:56 +08:00
|
|
|
Tensor *_getCopyTensor(Tensor *input);
|
2019-04-17 10:49:11 +08:00
|
|
|
Backend *mCPUBackend;
|
|
|
|
std::shared_ptr<Execution> mExecution;
|
|
|
|
std::vector<Tensor *> mWrapInputTensors;
|
2020-11-05 16:41:56 +08:00
|
|
|
std::shared_ptr<Tensor> mWrapForRaster;
|
|
|
|
std::map<Tensor *, std::tuple<Backend *, Backend *, std::shared_ptr<Tensor>>> mInputMaps;
|
|
|
|
bool mStatic;
|
2019-04-17 10:49:11 +08:00
|
|
|
};
|
|
|
|
} // namespace MNN
|
|
|
|
|
|
|
|
#endif /* WrapExecution_hpp */
|