MNN/express/module/WhileModule.hpp

55 lines
1.5 KiB
C++
Raw Normal View History

2020-11-05 16:41:56 +08:00
//
// WhileModule.hpp
// MNN
//
2025-01-22 14:47:50 +08:00
// Created by MNN on 2020/09/10.
2020-11-05 16:41:56 +08:00
// Copyright © 2018, Alibaba Group Holding Limited
//
2025-01-22 14:47:50 +08:00
2020-11-05 16:41:56 +08:00
#ifndef WhileModule_hpp
#define WhileModule_hpp
#include <MNN/expr/Module.hpp>
2022-05-06 19:51:20 +08:00
#include "core/Schedule.hpp"
2020-11-05 16:41:56 +08:00
namespace MNN {
namespace Express {
class WhileModule : public Module {
public:
virtual ~ WhileModule() {
// Do nothing
}
virtual std::vector<Express::VARP> onForward(const std::vector<Express::VARP>& inputs) override;
2022-12-30 15:18:58 +08:00
static WhileModule* create(const Op* op, const std::map<std::string, SubGraph>& subGraph);
2020-11-05 16:41:56 +08:00
2021-02-07 10:45:07 +08:00
struct Info {
int mCondInputNumber = 0;
int mBodyInputNumber = 0;
2021-02-07 10:45:07 +08:00
int mOutputNumber;
2020-11-05 16:41:56 +08:00
2021-02-07 10:45:07 +08:00
// First mCondInputs' index, Second: inputs's index
std::vector<std::pair<int, int>> mInputForCond;
2020-11-05 16:41:56 +08:00
2021-02-07 10:45:07 +08:00
// First mBodyInputs' index, Second: inputs's index
std::vector<std::pair<int, int>> mInputForBody;
std::vector<std::pair<int, int>> mOutputFromBody;
std::vector<std::pair<int, int>> mOutputFromBodyInput;
std::vector<int> mOutputFromInput;
std::vector<std::pair<int, int>> mUpdateForCond;
std::vector<std::pair<int, int>> mUpdateForBody;
2020-11-05 16:41:56 +08:00
2021-02-07 10:45:07 +08:00
std::vector<std::pair<int, int>> mCondUpdateForCond;
std::vector<std::pair<int, int>> mCondUpdateForBody;
};
private:
WhileModule(){}
2020-11-05 16:41:56 +08:00
2021-02-07 10:45:07 +08:00
Module* clone(CloneContext* ctx) const override;
std::shared_ptr<Info> mInfo;
2020-11-05 16:41:56 +08:00
std::shared_ptr<Module> mCond;
std::shared_ptr<Module> mBody;
};
}
}
#endif