| 
									
										
										
										
											2021-02-01 21:31:45 +09:00
										 |  |  | /* ******************************************************************************
 | 
					
						
							|  |  |  |  * | 
					
						
							| 
									
										
										
										
											2019-06-06 15:21:15 +03:00
										 |  |  |  * | 
					
						
							|  |  |  |  * This program and the accompanying materials are made available under the | 
					
						
							|  |  |  |  * terms of the Apache License, Version 2.0 which is available at | 
					
						
							|  |  |  |  * https://www.apache.org/licenses/LICENSE-2.0.
 | 
					
						
							|  |  |  |  * | 
					
						
							| 
									
										
										
										
											2021-02-01 21:31:45 +09:00
										 |  |  |  *  See the NOTICE file distributed with this work for additional | 
					
						
							|  |  |  |  *  information regarding copyright ownership. | 
					
						
							| 
									
										
										
										
											2019-06-06 15:21:15 +03:00
										 |  |  |  * Unless required by applicable law or agreed to in writing, software | 
					
						
							|  |  |  |  * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | 
					
						
							|  |  |  |  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | 
					
						
							|  |  |  |  * License for the specific language governing permissions and limitations | 
					
						
							|  |  |  |  * under the License. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * SPDX-License-Identifier: Apache-2.0 | 
					
						
							|  |  |  |  ******************************************************************************/ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | //
 | 
					
						
							|  |  |  | // Created by raver119 on 20.10.2017.
 | 
					
						
							|  |  |  | //
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include <graph/execution/LogicExecutor.h>
 | 
					
						
							|  |  |  | #include <graph/execution/LogicScope.h>
 | 
					
						
							|  |  |  | #include <graph/execution/LogicWhile.h>
 | 
					
						
							|  |  |  | #include <graph/execution/LogicSwitch.h>
 | 
					
						
							|  |  |  | #include <graph/execution/LogicConditional.h>
 | 
					
						
							|  |  |  | #include <graph/execution/LogicReturn.h>
 | 
					
						
							|  |  |  | #include <graph/execution/LogicExpose.h>
 | 
					
						
							|  |  |  | #include <graph/execution/LogicMerge.h>
 | 
					
						
							|  |  |  | #include <graph/execution/LogicEnter.h>
 | 
					
						
							|  |  |  | #include <graph/execution/LogicExit.h>
 | 
					
						
							|  |  |  | #include <graph/execution/LogicLoopCond.h>
 | 
					
						
							|  |  |  | #include <graph/execution/LogicNextIteration.h>
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-03-02 12:49:41 +03:00
										 |  |  | namespace sd { | 
					
						
							| 
									
										
										
										
											2019-06-06 15:21:15 +03:00
										 |  |  |     namespace graph { | 
					
						
							|  |  |  |         Nd4jStatus LogicExecutor::processNode(Graph *graph, Node *node) { | 
					
						
							|  |  |  |             switch (node->opNum()) { | 
					
						
							| 
									
										
										
										
											2020-03-02 12:49:41 +03:00
										 |  |  |                 case sd::logic::While: | 
					
						
							| 
									
										
										
										
											2019-06-06 15:21:15 +03:00
										 |  |  |                     return LogicWhile::processNode(graph, node); | 
					
						
							| 
									
										
										
										
											2020-03-02 12:49:41 +03:00
										 |  |  |                 case sd::logic::Scope: | 
					
						
							| 
									
										
										
										
											2019-06-06 15:21:15 +03:00
										 |  |  |                     return LogicScope::processNode(graph, node); | 
					
						
							| 
									
										
										
										
											2020-03-02 12:49:41 +03:00
										 |  |  |                 case sd::logic::Conditional: | 
					
						
							| 
									
										
										
										
											2019-06-06 15:21:15 +03:00
										 |  |  |                     return LogicConditional::processNode(graph, node); | 
					
						
							| 
									
										
										
										
											2020-03-02 12:49:41 +03:00
										 |  |  |                 case sd::logic::Switch: | 
					
						
							| 
									
										
										
										
											2019-06-06 15:21:15 +03:00
										 |  |  |                     return LogicSwitch::processNode(graph, node); | 
					
						
							| 
									
										
										
										
											2020-03-02 12:49:41 +03:00
										 |  |  |                 case sd::logic::Return: | 
					
						
							| 
									
										
										
										
											2019-06-06 15:21:15 +03:00
										 |  |  |                     return LogicReturn::processNode(graph, node); | 
					
						
							| 
									
										
										
										
											2020-03-02 12:49:41 +03:00
										 |  |  |                 case sd::logic::Expose: | 
					
						
							| 
									
										
										
										
											2019-06-06 15:21:15 +03:00
										 |  |  |                     return LogicExpose::processNode(graph, node); | 
					
						
							| 
									
										
										
										
											2020-03-02 12:49:41 +03:00
										 |  |  |                 case sd::logic::Merge: | 
					
						
							| 
									
										
										
										
											2019-06-06 15:21:15 +03:00
										 |  |  |                     return LogicMerge::processNode(graph, node); | 
					
						
							| 
									
										
										
										
											2020-03-02 12:49:41 +03:00
										 |  |  |                 case sd::logic::LoopCond: | 
					
						
							| 
									
										
										
										
											2019-06-06 15:21:15 +03:00
										 |  |  |                     return LogicLoopCond::processNode(graph, node); | 
					
						
							| 
									
										
										
										
											2020-03-02 12:49:41 +03:00
										 |  |  |                 case sd::logic::NextIteration: | 
					
						
							| 
									
										
										
										
											2019-06-06 15:21:15 +03:00
										 |  |  |                     return LogicNextIeration::processNode(graph, node); | 
					
						
							| 
									
										
										
										
											2020-03-02 12:49:41 +03:00
										 |  |  |                 case sd::logic::Exit: | 
					
						
							| 
									
										
										
										
											2019-06-06 15:21:15 +03:00
										 |  |  |                     return LogicExit::processNode(graph, node); | 
					
						
							| 
									
										
										
										
											2020-03-02 12:49:41 +03:00
										 |  |  |                 case sd::logic::Enter: | 
					
						
							| 
									
										
										
										
											2019-06-06 15:21:15 +03:00
										 |  |  |                     return LogicEnter::processNode(graph, node); | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             if (node->getName() == nullptr) { | 
					
						
							|  |  |  |                 nd4j_printf("Unknown LogicOp used at node [%i]: [%i]\n", node->id(), node->opNum()); | 
					
						
							|  |  |  |             } else { | 
					
						
							|  |  |  |                 nd4j_printf("Unknown LogicOp used at node [%i:<%s>]: [%i]\n", node->id(), node->getName()->c_str(), node->opNum()); | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |             return ND4J_STATUS_BAD_INPUT; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | } |