• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /**
2  * Copyright 2020 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 #include "backend/kernel_compiler/akg/akg_kernel_metadata.h"
18 #include "backend/session/anf_runtime_algorithm.h"
19 #include "backend/kernel_compiler/oplib/oplib.h"
20 #include "backend/kernel_compiler/common_utils.h"
21 
22 namespace mindspore {
23 namespace kernel {
AkgMetadataInfo(const CNodePtr & kernel_node,std::vector<std::shared_ptr<KernelBuildInfo>> * const kernel_info_list)24 void AkgMetadataInfo(const CNodePtr &kernel_node,
25                      std::vector<std::shared_ptr<KernelBuildInfo>> *const kernel_info_list) {
26   MS_EXCEPTION_IF_NULL(kernel_node);
27   MS_EXCEPTION_IF_NULL(kernel_info_list);
28 
29   std::string op_name = AnfAlgo::GetCNodeName(kernel_node);
30   for (size_t i = 0; i < support_devices.size(); i++) {
31     auto op_info_ptr = mindspore::kernel::OpLib::FindOp(op_name, OpImplyType::kAKG);
32     if (op_info_ptr == nullptr) {
33       continue;
34     }
35 
36     if (!ParseMetadata(kernel_node, op_info_ptr, Processor(i), kernel_info_list)) {
37       MS_LOG(WARNING) << "Akg parsed metadata of op[" << op_name << "], device[" << support_devices[i] << "] failed.";
38     } else {
39       MS_LOG(DEBUG) << "Akg parsed metadata of op[" << op_name << "], device[" << support_devices[i] << "].";
40       break;
41     }
42   }
43 
44   if (kernel_info_list->empty()) {
45     MS_LOG(WARNING) << "Akg dose not has metadata of op[" << op_name << "].";
46   }
47 }
48 }  // namespace kernel
49 }  // namespace mindspore
50