| 
									
										
										
										
											2020-11-05 16:41:56 +08:00
										 |  |  | //
 | 
					
						
							|  |  |  | //  WhileModule.hpp
 | 
					
						
							|  |  |  | //  MNN
 | 
					
						
							|  |  |  | //
 | 
					
						
							|  |  |  | //  Created by MNN on b'2020/09/10'.
 | 
					
						
							|  |  |  | //  Copyright © 2018, Alibaba Group Holding Limited
 | 
					
						
							|  |  |  | //
 | 
					
						
							|  |  |  | #ifndef WhileModule_hpp
 | 
					
						
							|  |  |  | #define WhileModule_hpp
 | 
					
						
							|  |  |  | #include <MNN/expr/Module.hpp>
 | 
					
						
							|  |  |  | 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; | 
					
						
							| 
									
										
										
										
											2021-04-14 17:21:30 +08:00
										 |  |  |     MNN_PUBLIC 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 { | 
					
						
							| 
									
										
										
										
											2021-11-30 10:10:53 +08:00
										 |  |  |         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
 |