From 195563c67fd7e333ddbb5725337ab4e402928349 Mon Sep 17 00:00:00 2001 From: yujianfeng Date: Sat, 30 Oct 2021 14:09:12 +0800 Subject: [PATCH] Fix the random failure of ut tests in ci --- .../python/optimizer/test_bprop_mindir_dfx.py | 65 ------------------- 1 file changed, 65 deletions(-) delete mode 100644 tests/ut/python/optimizer/test_bprop_mindir_dfx.py diff --git a/tests/ut/python/optimizer/test_bprop_mindir_dfx.py b/tests/ut/python/optimizer/test_bprop_mindir_dfx.py deleted file mode 100644 index 30695dee1df..00000000000 --- a/tests/ut/python/optimizer/test_bprop_mindir_dfx.py +++ /dev/null @@ -1,65 +0,0 @@ -# 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. -# ============================================================================ -"""DFX test for bprop mindir""" - -import os -import numpy as np - -import mindspore.nn as nn -from mindspore import Tensor -from mindspore.ops import operations as P -import mindspore.ops as ops -import mindspore.ops._grad as g - - -class Net(nn.Cell): - def __init__(self, op): - super(Net, self).__init__() - self.op = op - - def construct(self, *inputs): - return self.op(*inputs) - - -class GradNet(nn.Cell): - def __init__(self, network): - super(GradNet, self).__init__() - self.grad = ops.GradOperation(get_all=True) - self.network = network - - def construct(self, *inputs): - gout = self.grad(self.network)(*inputs) - return gout - - -def test_remove_bprop_fle(): - """ - Feature: Bprop pre-compilation. - Description: Remove a bprop file, compile a grad net with a bprop not defined in this file. - Expectation: The grad net can be complied successfully. - """ - bprop_path = g.__file__ - bprop_installed_dir = bprop_path[: bprop_path.rindex('/')] - nn_bprop_path = bprop_installed_dir + '/grad_nn_ops.py' - new_path = bprop_installed_dir + '/new' - os.mkdir(new_path) - new_nn_bprop_path = bprop_installed_dir + '/new/grad_nn_ops.py' - os.rename(nn_bprop_path, new_nn_bprop_path) - x = Tensor(np.array([[0, 1], [2, 1]]).astype(np.int32)) - ones_like = Net(P.OnesLike()) - grad = GradNet(ones_like) - grad.compile(x) - os.rename(new_nn_bprop_path, nn_bprop_path) - os.rmdir(new_path)