• 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 #ifndef MINDSPORE_CCSRC_BACKEND_OPTIMIZER_ASCEND_ENHANCER_INSERT_TENSOR_MOVE_FOR_HCCL_OP_H_
17 #define MINDSPORE_CCSRC_BACKEND_OPTIMIZER_ASCEND_ENHANCER_INSERT_TENSOR_MOVE_FOR_HCCL_OP_H_
18 
19 #include <memory>
20 #include "backend/optimizer/common/optimizer.h"
21 #include "backend/optimizer/ascend/ascend_helper.h"
22 
23 namespace mindspore {
24 namespace opt {
25 class InsertTensorMoveForHcclOp : public PatternProcessPass {
26  public:
27   explicit InsertTensorMoveForHcclOp(bool multigraph = true)
28       : PatternProcessPass("insert_tensor_move_for_hccl_op", multigraph),
29         kernel_query_(std::make_shared<KernelQuery>()) {}
30   ~InsertTensorMoveForHcclOp() override = default;
31   const AnfNodePtr Process(const FuncGraphPtr &, const AnfNodePtr &, const EquivPtr &) const override;
32 
33  private:
34   void InsertTensorMove(const FuncGraphPtr &graph, const CNodePtr &hccl_node) const;
35   bool NeedInsertTensorMove(const FuncGraphPtr &graph, const AnfNodePtr &input, const CNodePtr &cur_node) const;
36   KernelQueryPtr kernel_query_;
37 };
38 }  // namespace opt
39 }  // namespace mindspore
40 #endif  // MINDSPORE_CCSRC_BACKEND_OPTIMIZER_ASCEND_ENHANCER_INSERT_TENSOR_MOVE_FOR_HCCL_OP_H_
41