!3031 fix context mode and device target dependency issue

Merge pull request !3031 from wangqiuliang/fix-tensor-bool-operation
This commit is contained in:
mindspore-ci-bot 2020-07-13 19:52:32 +08:00 committed by Gitee
commit c465ea3269
2 changed files with 4 additions and 6 deletions

View File

@ -176,10 +176,7 @@ class _Context:
self._context_switches.push(True, None)
else:
if self.enable_debug_runtime:
if self.device_target == "CPU":
self.set_backend_policy("vm")
else:
self.set_backend_policy("ge")
self.set_backend_policy("ge")
self._context_switches.push(False, None)
def set_backend_policy(self, policy):
@ -221,6 +218,8 @@ class _Context:
success = self._context_handle.set_device_target(target)
if not success:
raise ValueError("Target device name is invalid!!!")
if self.enable_debug_runtime and self.device_target == "CPU":
self.set_backend_policy("vm")
@property
def device_id(self):

View File

@ -29,8 +29,7 @@ from .....mindspore_test_framework.utils.bprop_util import bprop
def setup_module(module):
context.set_context(device_target="CPU")
context.set_context(mode=context.GRAPH_MODE)
context.set_context(mode=context.GRAPH_MODE, device_target="CPU")
def teardown_module(module):
context.set_context(device_target="Ascend")