1 /** 2 * Copyright 2019 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/hccl/hccl_kernel_build.h" 18 19 #include <string> 20 #include <memory> 21 #include "backend/kernel_compiler/hccl/hccl_kernel.h" 22 #include "backend/session/anf_runtime_algorithm.h" 23 24 namespace mindspore { 25 namespace kernel { HcclOpBuild(const AnfNodePtr & anf_node)26KernelModPtr HcclOpBuild(const AnfNodePtr &anf_node) { 27 MS_EXCEPTION_IF_NULL(anf_node); 28 std::string opname = AnfAlgo::GetCNodeName(anf_node); 29 MS_LOG(INFO) << "Hccl op [" << opname << "]"; 30 auto kerPtr = HcclKernelFactory::Get(opname); 31 if (kerPtr == nullptr) { 32 MS_LOG(ERROR) << "Hccl can't find Kernel[" << opname << "]"; 33 return nullptr; 34 } 35 if (!kerPtr->Init(anf_node)) { 36 MS_LOG(ERROR) << "Kernel initialize failed!"; 37 return nullptr; 38 } 39 return kerPtr; 40 } 41 } // namespace kernel 42 } // namespace mindspore 43