• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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/rts/rt_kernel_build.h"
18 #include <string>
19 #include <memory>
20 #include <algorithm>
21 #include "backend/kernel_compiler/rts/rt_kernel.h"
22 #include "backend/session/anf_runtime_algorithm.h"
23 
24 namespace mindspore {
25 namespace kernel {
RtOpBuild(const AnfNodePtr & anf_node)26 KernelModPtr RtOpBuild(const AnfNodePtr &anf_node) {
27   MS_EXCEPTION_IF_NULL(anf_node);
28   std::string op_name = AnfAlgo::GetCNodeName(anf_node);
29   (void)std::transform(op_name.begin(), op_name.end(), op_name.begin(), ::tolower);
30   MS_LOG(INFO) << "Op Name(tolower)[" << op_name << "]";
31   auto ker_ptr = RtKernelFactory::Create(op_name);
32   MS_EXCEPTION_IF_NULL(ker_ptr);
33   if (!ker_ptr->Init(anf_node)) {
34     MS_LOG(ERROR) << "Rt Op initialize failed!";
35     return nullptr;
36   }
37 
38   return ker_ptr;
39 }
40 }  // namespace kernel
41 }  // namespace mindspore
42