Add a experimental bprop directory to store new bprop

This commit is contained in:
yujianfeng 2021-06-28 21:11:27 +08:00
parent b1e337d8bd
commit 773959fbd3
2 changed files with 23 additions and 0 deletions

View File

@ -28,7 +28,11 @@ namespace mindspore {
py::function GetBpropFunctionByObj(py::object obj) {
static const std::string get_bprop_fn = "get_bprop_fn";
static const std::string ad_module = "mindspore.ops._grad";
static const std::string ad_experimental_module = "mindspore.ops._grad_experimental";
py::function fn = parse::python_adapter::GetPyFn(ad_module, get_bprop_fn)(obj);
if (!fn || py::isinstance<py::none>(fn)) {
fn = parse::python_adapter::GetPyFn(ad_experimental_module, get_bprop_fn)(obj);
}
return fn;
}

View File

@ -0,0 +1,19 @@
# Copyright 2021 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.
# ============================================================================
"""grad experimental impl."""
from .._grad.grad_base import get_bprop_fn
__all__ = ['get_bprop_fn']