!39216 Add testcase to watch complex control testcase core dump

Merge pull request !39216 from chenfei_mindspore/master-develop
This commit is contained in:
i-robot 2022-08-02 02:24:47 +00:00 committed by Gitee
commit 87b20a49d3
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
2 changed files with 78 additions and 1 deletions

View File

@ -351,7 +351,7 @@ void CheckSequenceNodesValid(const AnfNodeWeakPtrList &sequence_nodes) {
MS_LOG(ERROR) << "current_sequence_node is null.";
return;
}
MS_LOG(ERROR) << "sequence_nodes[" << i << "]: " << current_sequence_node << "/"
MS_LOG(DEBUG) << "sequence_nodes[" << i << "]: " << current_sequence_node << "/"
<< current_sequence_node->DebugString()
<< ", flags: " << GetSequenceNodeElementsUseFlags(current_sequence_node);
}

View File

@ -0,0 +1,77 @@
# Copyright 2022 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.
# ============================================================================
from mindspore.nn import Cell
from mindspore.common import Tensor, dtype, Parameter
import mindspore.ops.functional as F
import numpy as np
import pytest
class Net(Cell):
def __init__(self):
super().__init__()
self.w = Parameter(Tensor([2], dtype.float32), name='weight')
self.b = Parameter(Tensor([(- 2)], dtype.float32), name='bias')
def construct(self, x, y):
if self.w != 3:
self.b = 3 + x
if self.w == self.b:
self.w = self.b + y
return self.b
if x <= self.w:
return x
elif self.b >= y:
for _ in range(2):
x = 2 + y
if x != 3:
pass
elif y <= 3:
while x == self.w:
return y
for f in range(2):
if x != self.w:
x = 3 + x
x = f / y
self.w = y + x
elif self.w >= 1:
return x
elif self.w > y:
return self.w
elif self.w != 5:
return self.b
else:
return self.w
if y == self.b:
continue
return x + y
@pytest.mark.level0
@pytest.mark.platform_x86_gpu_training
@pytest.mark.env_onecard
def test_watch_core_dump():
"""
Feature: Control flow.
Description: This complex control flow testcase has been cause core dump before, so add this case to watch graph
compiling.
Expectation: No core dump happened.
"""
x = np.array([4], np.float32)
y = np.array([5], np.float32)
net1 = Net()
grad_net = F.grad(net1, grad_position=(0, 1))
grad_net(Tensor(x), Tensor(y))