• 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_CCSRC_TRANSFORM_ACL_IR_OP_API_UTIL_H_
18 #define MINDSPORE_CCSRC_TRANSFORM_ACL_IR_OP_API_UTIL_H_
19 
20 #include <vector>
21 #include <string>
22 #include "utils/ms_context.h"
23 #include "ir/anf.h"
24 #include "acl/acl_base.h"
25 #include "acl/acl_rt.h"
26 #include "hccl/hccl.h"
27 #include "acl/acl_op_compiler.h"
28 #include "plugin/device/ascend/hal/common/ascend_utils.h"
29 
30 namespace mindspore::transform {
31 typedef enum : int8_t {
32   KEEP_DTYPE = 0,
33   ALLOW_FP32_DOWN_PRECISION = 1,
34   FORCE_FP16 = 2,
35   FORCE_HF32 = 3,
36 } aclCubeMathType;
37 
38 class OpApiUtil {
39  public:
40   static aclCubeMathType GetCubeMathType(bool use_hf32 = false);
41 
42   static void GetValidKernelBuildInfo(const AnfNodePtr &node, std::vector<std::string> *input_formats,
43                                       std::vector<std::string> *output_formats,
44                                       std::vector<std::string> *input_reshape_types,
45                                       std::vector<std::string> *output_reshape_types);
46 };
47 
48 class AclUtil {
49  public:
50   static uint8_t KeepOriginDType();
51 
52   static void SetDeterministic();
53 
54   static aclError SetCompileMode(const int64_t is_dyncmic);
55 
56   static aclError SetPrecisionMode(const std::string &mode);
57 
58   static void SetOpPrecisionMode();
59 };
60 }  // namespace mindspore::transform
61 #endif  // MINDSPORE_CCSRC_TRANSFORM_ACL_IR_OP_API_UTIL_H_
62