• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /**
2  * Copyright 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_BACKEND_OPTIMIZER_INFERENCE_WEIGHT_PREPROCESS_UTILS_H_
18 #define MINDSPORE_CCSRC_BACKEND_OPTIMIZER_INFERENCE_WEIGHT_PREPROCESS_UTILS_H_
19 
20 #include <vector>
21 #include <functional>
22 #include <string>
23 #include <memory>
24 #include "ir/anf.h"
25 #include "ir/tensor.h"
26 #include "kernel/kernel_build_info.h"
27 #include "include/common/utils/utils.h"
28 #include "include/backend/kernel_graph.h"
29 #include "include/backend/anf_runtime_algorithm.h"
30 #include "include/common/utils/anfalgo.h"
31 #include "include/api/data_type.h"
32 #include "mindspore/core/utils/ms_context.h"
33 #include "mindspore/core/ops/framework_ops.h"
34 
35 namespace mindspore {
36 namespace opt {
37 
38 constexpr auto n_lens_str = "n_lens";
39 constexpr auto is_fixed_weight_str = "is_fixed_weight";
40 
41 tensor::TensorPtr GetParamFromLoad(const CNodePtr &load, const bool unused);
42 
43 bool CheckFusionValid(const CNodePtr &matmul, int64_t *k, const int trans_a_pos, const int trans_b_pos,
44                       const std::vector<TypeId> &valid_dtypes);
45 
46 std::shared_ptr<ValueNode> CreateWeightTensor(TypeId type_id, const std::vector<int64_t> &weight_shape,
47                                               const std::vector<void *> &data_c_list,
48                                               const std::vector<int64_t> &n_len_list, const int64_t &k_len,
49                                               const std::shared_ptr<Type> &w_dtype, const bool &need_rank_offset,
50                                               const uint32_t &global_rank_id);
51 
52 void SortWeightNodeList(AnfNodePtrList *node_list);
53 
54 }  // namespace opt
55 }  // namespace mindspore
56 
57 #endif  // MINDSPORE_CCSRC_BACKEND_OPTIMIZER_INFERENCE_WEIGHT_PREPROCESS_UTILS_H_
58