• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /**
2  * Copyright 2019-2024 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_PIPELINE_JIT_PASS_H_
18 #define MINDSPORE_CCSRC_PIPELINE_JIT_PASS_H_
19 
20 #include <vector>
21 #include <functional>
22 #include <utility>
23 #include <string>
24 #include "pipeline/jit/ps/resource.h"
25 #include "include/common/visible.h"
26 
27 namespace mindspore {
28 namespace opt {
29 namespace irpass {
30 class OptimizeIRPassLib;
31 }  // namespace irpass
32 }  // namespace opt
33 
34 namespace pipeline {
35 using PassItem = std::pair<std::string, std::function<bool(ResourcePtr)>>;
36 
37 extern std::vector<PassItem> kVmPasses;
38 extern std::vector<PassItem> kInlinePasses;
39 extern std::vector<PassItem> kPynativePasses;
40 
41 bool OptPassAGroup(const ResourcePtr &resource);
42 bool CconvPass(const ResourcePtr &resource);
43 bool PipelineSplitPass(const ResourcePtr &resource);
44 bool PipelineParallelScheduler(const ResourcePtr &resource);
45 bool AutoParallelPass(const ResourcePtr &resource);
46 bool AutoParallelSymbolPassWithReNormalize(const ResourcePtr &resource);
47 bool ParallelVirtualDatasetPass(const ResourcePtr &resource);
48 bool ValidatePass(const ResourcePtr &resource);
49 bool ConvertPrepareAdapt(const ResourcePtr &resource);
50 bool AddCacheEmbeddingPass(const ResourcePtr &resource);
51 bool GradPartialTransformPass(const ResourcePtr &resource);
52 void ReclaimOptimizer();
53 bool PynativeOptPass(const ResourcePtr &resource);
54 bool EliminateSpecialOpOptPass(const ResourcePtr &resource);
55 bool ME_EXPORT AutoMonadElimOptPass(const FuncGraphPtr &func_graph);
56 FuncGraphPtr PrimBpOptPassStep1(const opt::irpass::OptimizeIRPassLib &irpass, const ResourcePtr &resource);
57 FuncGraphPtr PrimBpOptPassStep2(const opt::irpass::OptimizeIRPassLib &irpass, const ResourcePtr &resource,
58                                 const std::vector<bool> &need_grad_flags);
59 FuncGraphPtr JitBpropGraphPass(const ResourcePtr &resource, bool need_renormalize);
60 FuncGraphPtr FinalBpropGraphPass(const ResourcePtr &resource, bool has_control_flow);
61 void UpdateArgsSpec(const FuncGraphPtr &func_graph, const ResourcePtr &resource);
62 }  // namespace pipeline
63 }  // namespace mindspore
64 
65 #endif  // MINDSPORE_CCSRC_PIPELINE_JIT_PASS_H_
66