1 /** 2 * Copyright 2019 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_TMP_IDENTITY_INFO_H_ 18 #define MINDSPORE_CCSRC_FRONTEND_PARALLEL_OPS_INFO_TMP_IDENTITY_INFO_H_ 19 20 #include <memory> 21 #include <string> 22 #include <vector> 23 24 #include "frontend/parallel/auto_parallel/operator_costmodel.h" 25 #include "frontend/parallel/ops_info/operator_info.h" 26 #include "frontend/parallel/strategy.h" 27 28 namespace mindspore { 29 namespace parallel { 30 class TmpIdentityInfo : public OperatorInfo { 31 // This operator is only used for the case of a parameter tensor being used by multiple operators, where we 32 // consider this parameter tensor as TmpIdentityInfo operator. TmpIdentityInfo operator tasks as input a tensor, 33 // and outputs the same tensor. After the transformation, subsequent operators can share the output tensor. 34 public: 35 TmpIdentityInfo(const Shapes &inputs_shape, const Shapes &outputs_shape, const PrimitiveAttrs &attrs, 36 const std::string &name = IDENTITY_INFO) OperatorInfo(name,inputs_shape,outputs_shape,attrs,std::make_shared<TmpIdentityCost> ())37 : OperatorInfo(name, inputs_shape, outputs_shape, attrs, std::make_shared<TmpIdentityCost>()) {} 38 ~TmpIdentityInfo() override = default; 39 40 Status Init(const StrategyPtr &strategy) override; 41 Status InitForCostModel(const StrategyPtr &strategy) override; 42 43 std::vector<StrategyPtr> GenerateOpStrategies(int64_t stage_id) override; 44 Status SetCostUnderStrategy(const StrategyPtr &strategy) override; 45 46 protected: 47 Status CheckStrategy(const StrategyPtr &strategy) override; GetAttrs()48 Status GetAttrs() override { return SUCCESS; } InferMirrorOps()49 Status InferMirrorOps() override { return SUCCESS; } InferForwardCommunication()50 Status InferForwardCommunication() override { return SUCCESS; } 51 Status InferDevMatrixShape() override; 52 Status InferTensorMap() override; 53 }; 54 } // namespace parallel 55 } // namespace mindspore 56 57 #endif // MINDSPORE_CCSRC_FRONTEND_PARALLEL_OPS_INFO_TMP_IDENTITY_INFO_H_ 58