• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /**
2  * Copyright 2022 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_BACKEND_OPTIMIZER_ASCEND_GE_OPTIMIZER_IRPASS_GE_TENSOR_ARRAY_H_
18 #define MINDSPORE_CCSRC_BACKEND_OPTIMIZER_ASCEND_GE_OPTIMIZER_IRPASS_GE_TENSOR_ARRAY_H_
19 
20 #include <memory>
21 #include <string>
22 #include <vector>
23 #include "include/backend/optimizer/optimizer.h"
24 namespace mindspore {
25 namespace opt {
26 class TensorArrayAddFlow : public PatternProcessPass {
27  public:
28   explicit TensorArrayAddFlow(const std::string &name = "", bool multigraph = true)
PatternProcessPass(name,multigraph)29       : PatternProcessPass(name, multigraph) {}
30   ~TensorArrayAddFlow() override = default;
31 
32   const BaseRef DefinePattern() const override = 0;
33   const AnfNodePtr Process(const FuncGraphPtr &, const AnfNodePtr &, const EquivPtr &) const override;
34 };
35 
36 class TensorArrayAddFlowCond1 : public TensorArrayAddFlow {
37  public:
38   explicit TensorArrayAddFlowCond1(bool multigraph = true)
39       : TensorArrayAddFlow("tensor_arry_add_flow_cond1", multigraph) {}
40   ~TensorArrayAddFlowCond1() override = default;
41 
42   const BaseRef DefinePattern() const override;
43 
44  private:
45   std::vector<std::string> MustExistPrimitiveName() const override;
46 };
47 
48 class TensorArrayAddFlowCond2 : public TensorArrayAddFlow {
49  public:
50   explicit TensorArrayAddFlowCond2(bool multigraph = true)
51       : TensorArrayAddFlow("tensor_arry_add_flow_cond2", multigraph) {}
52   ~TensorArrayAddFlowCond2() override = default;
53 
54   const BaseRef DefinePattern() const override;
55 
56  private:
57   std::vector<std::string> MustExistPrimitiveName() const override;
58 };
59 
60 class GeTensorArrayCastIndex : public PatternProcessPass {
61  public:
62   explicit GeTensorArrayCastIndex(const std::string &name = "ge_tensor_arry_cast_index", bool multigraph = true)
PatternProcessPass(name,multigraph)63       : PatternProcessPass(name, multigraph) {}
64   ~GeTensorArrayCastIndex() override = default;
65 
66   const BaseRef DefinePattern() const override;
67   const AnfNodePtr Process(const FuncGraphPtr &, const AnfNodePtr &, const EquivPtr &) const override;
68 
69  private:
70   std::vector<std::string> MustExistPrimitiveName() const override;
71 };
72 }  // namespace opt
73 }  // namespace mindspore
74 #endif  // MINDSPORE_CCSRC_BACKEND_OPTIMIZER_ASCEND_GE_OPTIMIZER_IRPASS_GE_TENSOR_ARRAY_H_
75