• 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 #ifndef MINDSPORE_CCSRC_RUNTIME_HARDWARE_ASCEND_GE_UTILS_H_
17 #define MINDSPORE_CCSRC_RUNTIME_HARDWARE_ASCEND_GE_UTILS_H_
18 
19 #include <string>
20 #include <vector>
21 #include <unordered_set>
22 #include "include/transform/graph_ir/types.h"
23 #include "utils/phase.h"
24 #include "acl/acl_rt.h"
25 
26 namespace mindspore {
27 namespace device {
28 namespace ascend {
29 using mindspore::transform::OptionMap;
30 
31 std::string ShapesToString(const ShapeArray &shapes);
32 std::string GetGraphName(const FuncGraphPtr &graph);
33 OptionMap GetComputeGraphOptions(const ShapeArray &input_shapes, bool is_dynamic_shape);
34 void GetComputeGraphReuseOptions(const FuncGraphPtr &graph, OptionMap *option);
35 void SetPassthroughGeOptions(bool is_global, OptionMap *options);
36 bool AddDFGraph(const FuncGraphPtr &anf_graph, const transform::TensorOrderMap &init_inputs_map, bool export_air);
37 bool AddFakeGraph(const FuncGraphPtr &anf_graph);
38 bool IsGeTrain();
39 void SyncCopyStream(aclrtStream stream);
40 void SavePrevStepWeight(const std::vector<AnfNodePtr> &weights, aclrtStream stream);
41 
GetPhasePrefix()42 inline std::string GetPhasePrefix() {
43   const std::string &phase = PhaseManager::GetInstance().phase();
44   auto pos = phase.find('.');
45   if (pos != std::string::npos) {
46     return phase.substr(0, pos);
47   }
48 
49   return "";
50 }
51 
52 class InferNeedUpdateParaNames {
53  public:
GetInferParameterNames()54   std::unordered_set<std::string> &GetInferParameterNames() { return infer_need_update_para_names; }
55 
56  private:
57   std::unordered_set<std::string> infer_need_update_para_names;
58 };
59 }  // namespace ascend
60 }  // namespace device
61 }  // namespace mindspore
62 #endif  // MINDSPORE_CCSRC_RUNTIME_HARDWARE_ASCEND_GE_UTILS_H_
63