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 "frontend/operator/ops.h"
18 #include <string>
19 #include "include/common/utils/python_adapter.h"
20 #include "pipeline/jit/ps/parse/data_converter.h"
21
22 namespace mindspore {
23 // namespace to support primitive operators
24 namespace prim {
GetPythonOps(const std::string & op_name,const std::string & module_name,bool use_signature)25 ValuePtr GetPythonOps(const std::string &op_name, const std::string &module_name, bool use_signature) {
26 py::object obj = python_adapter::GetPyFn(module_name, op_name);
27 ValuePtr node = nullptr;
28 bool succ = parse::ConvertData(obj, &node, use_signature);
29 if (!succ) {
30 MS_LOG(INTERNAL_EXCEPTION) << "Get Python op " << op_name << " from " << module_name << " fail.";
31 }
32 return node;
33 }
34 } // namespace prim
35 } // namespace mindspore
36