• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 MINDSPORE_CCSRC_FRONTEND_PARALLEL_OPS_INFO_SPLIT_INFO_H_
18 #define MINDSPORE_CCSRC_FRONTEND_PARALLEL_OPS_INFO_SPLIT_INFO_H_
19 
20 #include <string>
21 #include <memory>
22 #include <vector>
23 
24 #include "ir/value.h"
25 #include "frontend/parallel/auto_parallel/operator_costmodel.h"
26 #include "frontend/parallel/ops_info/operator_info.h"
27 #include "frontend/parallel/strategy.h"
28 
29 namespace mindspore {
30 namespace parallel {
31 class SplitInfo : public OperatorInfo {
32  public:
SplitInfo(const std::string & operator_name,const Shapes & inputs_shape,const Shapes & outputs_shape,const PrimitiveAttrs & attrs)33   SplitInfo(const std::string &operator_name, const Shapes &inputs_shape, const Shapes &outputs_shape,
34             const PrimitiveAttrs &attrs)
35       : OperatorInfo(operator_name, inputs_shape, outputs_shape, attrs, std::make_shared<SplitCost>()) {}
36   ~SplitInfo() override = default;
37 
38   Status Init(const StrategyPtr &strategy) override;
39   Status InitForCostModel(const StrategyPtr &strategy) override;
40   std::vector<StrategyPtr> GenerateOpStrategies(int64_t) override;
41   std::shared_ptr<Strategys> GenerateBatchStrategies() override;
42   Status SetCostUnderStrategy(const StrategyPtr &) override;
43 
44  protected:
45   Status GetAttrs() override;
46   Status CheckStrategy(const StrategyPtr &strategy) override;
InferForwardCommunication()47   Status InferForwardCommunication() override { return SUCCESS; }
48   Status InferDevMatrixShape() override;
49   Status InferTensorMap() override;
50   Status InferAsLossDivisor() override;
51 
52  private:
53   size_t axis_ = 0;
54   size_t output_num_ = 0;
55 };
56 }  // namespace parallel
57 }  // namespace mindspore
58 
59 #endif  // MINDSPORE_CCSRC_FRONTEND_PARALLEL_OPS_INFO_SPLIT_INFO_H_
60