Browse Source

!10114 cpu check

From: @lijiaqi0612
Reviewed-by: @zhunaipan,@zhoufeng54
Signed-off-by: @zhoufeng54
tags/v1.1.0
mindspore-ci-bot Gitee 5 years ago
parent
commit
a2ff6e4c11
2 changed files with 12 additions and 0 deletions
  1. +6
    -0
      mindspore/nn/optim/adam.py
  2. +6
    -0
      mindspore/nn/optim/lazyadam.py

+ 6
- 0
mindspore/nn/optim/adam.py View File

@@ -357,6 +357,12 @@ class Adam(Optimizer):
if value not in ('CPU', 'Ascend', 'GPU'):
raise ValueError("The value must be 'CPU', 'Ascend' or 'GPU', but got value {}".format(value))

if self._target == "CPU" and value in('Ascend', 'GPU'):
raise ValueError("In the CPU environment, target cannot be set to 'GPU' and 'Ascend'.")

if self._target == "Ascend" and value == 'GPU':
raise ValueError("In the Ascend environment, target cannot be set to 'GPU'.")

self._is_device = (value != 'CPU')
self._target = value



+ 6
- 0
mindspore/nn/optim/lazyadam.py View File

@@ -263,5 +263,11 @@ class LazyAdam(Optimizer):
if value not in ('CPU', 'Ascend', 'GPU'):
raise ValueError("The value must be 'CPU', 'Ascend' or 'GPU', but got value {}".format(value))

if self._target == "CPU" and value in('Ascend', 'GPU'):
raise ValueError("In the CPU environment, target cannot be set to 'GPU' and 'Ascend'.")

if self._target == "Ascend" and value == 'GPU':
raise ValueError("In the Ascend environment, target cannot be set to 'GPU'.")

self._is_device = (value != 'CPU')
self._target = value

Loading…
Cancel
Save