From c312b47ae187ea44821800395817188ea194e8de Mon Sep 17 00:00:00 2001 From: jjfeing Date: Mon, 25 May 2020 15:09:18 +0800 Subject: [PATCH] adapte Second order optimization ops --- mindspore/ops/_op_impl/__init__.py | 1 + mindspore/ops/_op_impl/_custom_op/__init__.py | 16 ++++++++++++++++ mindspore/ops/op_info_register.py | 6 +++++- 3 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 mindspore/ops/_op_impl/_custom_op/__init__.py diff --git a/mindspore/ops/_op_impl/__init__.py b/mindspore/ops/_op_impl/__init__.py index 65a12cd73c..725977877d 100644 --- a/mindspore/ops/_op_impl/__init__.py +++ b/mindspore/ops/_op_impl/__init__.py @@ -19,5 +19,6 @@ from .aicpu import * if "Windows" not in platform.system(): from .akg.gpu import * from .tbe import * + from ._custom_op import * __all__ = [] diff --git a/mindspore/ops/_op_impl/_custom_op/__init__.py b/mindspore/ops/_op_impl/_custom_op/__init__.py new file mode 100644 index 0000000000..5fe583a60f --- /dev/null +++ b/mindspore/ops/_op_impl/_custom_op/__init__.py @@ -0,0 +1,16 @@ +# Copyright 2020 Huawei Technologies Co., Ltd +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ============================================================================ + +"""custom ops""" diff --git a/mindspore/ops/op_info_register.py b/mindspore/ops/op_info_register.py index 3ca616f2dc..3096e90250 100644 --- a/mindspore/ops/op_info_register.py +++ b/mindspore/ops/op_info_register.py @@ -23,6 +23,7 @@ from mindspore._checkparam import Validator as validator # path of built-in op info register. BUILT_IN_OPS_REGISTER_PATH = "mindspore/ops/_op_impl" +BUILT_IN_CUSTOM_OPS_REGISTER_PATH = "mindspore/ops/_op_impl/_custom_op" def op_info_register(op_info): @@ -47,7 +48,10 @@ def op_info_register(op_info): op_lib = Oplib() file_path = os.path.realpath(inspect.getfile(func)) # keep the path custom ops implementation. - imply_path = "" if BUILT_IN_OPS_REGISTER_PATH in file_path else file_path + if BUILT_IN_CUSTOM_OPS_REGISTER_PATH in file_path: + imply_path = file_path + else: + imply_path = "" if BUILT_IN_OPS_REGISTER_PATH in file_path else file_path if not op_lib.reg_op(op_info_real, imply_path): raise ValueError('Invalid op info {}:\n{}\n'.format(file_path, op_info_real))