• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /**
2  * Copyright 2023 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_LITE_SRC_TRAIN_OPTIMIZER_FUSION_GRU_FUSION_PASS_H_
18 #define MINDSPORE_LITE_SRC_TRAIN_OPTIMIZER_FUSION_GRU_FUSION_PASS_H_
19 
20 #include <memory>
21 #include <vector>
22 #include "tools/converter/optimizer.h"
23 
24 namespace mindspore {
25 namespace lite {
26 class LinkInfoManager;
27 class GruFusionPass : public GraphPass {
28  public:
29   GruFusionPass() = default;
30   ~GruFusionPass() override = default;
31   STATUS Run(schema::MetaGraphT *graph) override;
32 
33  private:
34   STATUS FuseToGruCell(schema::MetaGraphT *graph);
35   STATUS FuseGruCell(schema::MetaGraphT *graph);
36   bool MatchPatten(schema::MetaGraphT *graph, uint32_t stack_index, std::vector<uint32_t> *strided_slices,
37                    std::vector<uint32_t> *squeezes, std::vector<uint32_t> *gru_cells);
38   bool CheckGruCellConnection(schema::MetaGraphT *graph, const std::vector<uint32_t> &gru_cells);
39   STATUS CreateGru(schema::MetaGraphT *graph, uint32_t stack_index, const std::vector<uint32_t> &strided_slices,
40                    const std::vector<uint32_t> &squeezes, const std::vector<uint32_t> &gru_cells);
41   std::shared_ptr<LinkInfoManager> link_info_manager_{nullptr};
42 };
43 }  // namespace lite
44 }  // namespace mindspore
45 #endif  // MINDSPORE_LITE_SRC_TRAIN_OPTIMIZER_FUSION_GRU_FUSION_PASS_H_
46