1 /** 2 * Copyright 2020 Huawei Technologies Co., Ltd 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 #ifndef PARALLEL_AUTO_PARALLEL_REC_GRAPH_H_ 18 #define PARALLEL_AUTO_PARALLEL_REC_GRAPH_H_ 19 20 #include <iostream> 21 #include <string> 22 #include <vector> 23 24 #include "frontend/parallel/auto_parallel/rec_core/rec_strategy.h" 25 #include "frontend/parallel/auto_parallel/rec_core/rec_tensor.h" 26 27 namespace mindspore { 28 namespace parallel { 29 enum OperatorType { 30 kRecUnkownType, 31 kRecMatMul, 32 kRecConvolution, 33 kRecPooling, 34 kRecElmWiseOp, 35 kRecReLU, 36 kRecBatchNorm, 37 kRecReshape, 38 kRecBiasAdd, 39 kRecSoftmax, 40 kRecSparseSoftmaxCrossEntropyWithLogits, 41 kRecSoftmaxCrossEntropyWithLogits, 42 kRecOneHot, 43 kRecLog, 44 kRecExp, 45 kRecAdd, 46 kRecSub, 47 kRecMul, 48 kRecDiv, 49 kRecSqueeze, 50 kRecCast, 51 kRecReduce, 52 kRecPReLU, 53 kRecGatherV2, 54 kRecArgWithValue, 55 kRecUnsortedSegmentOp 56 }; 57 58 enum InfoType { kApplication, kConstant }; 59 60 struct OperatorRec { 61 OperatorType op_type; 62 TensorParam arguments[MAX_INPUT_NUM]; 63 StrategyRec str; 64 }; 65 66 // Define simplified dataflow Graph for partitioning 67 class Graph { 68 public: 69 struct NodeType { 70 std::string name; 71 // Nodes that point to this node 72 std::vector<size_t> node_in; 73 // Nodes that point from this node 74 std::vector<size_t> node_out; 75 std::vector<size_t> node_in_aux; 76 // Node Type Info: Application or Constant. Defined in enum <InfoType> . 77 InfoType info; 78 // Operator info. Defined in struct <OperatorRec> . 79 OperatorRec apply; 80 // Tensor info. Defined in tensor.h struct <TensorParam> . 81 TensorParam tensor_parm; 82 }; 83 84 std::vector<Graph::NodeType> nodes; // Nodes of the graph. Pubic. 85 }; // Define simplified dataflow Graph for partitioning 86 } // namespace parallel 87 } // namespace mindspore 88 #endif // PARALLEL_AUTO_PARALLEL_REC_GRAPH_H_ 89