Skip to content

Commit 7e56055

Browse files
velconiaJiabinYang
authored andcommitted
Imperative fix bugs (cherry pick to 1.4) (#16680)
* Fix imperative bugs test=release/1.4 * Polish code test=release/1.4
1 parent 29f3441 commit 7e56055

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

python/paddle/fluid/tests/unittests/test_imperative_ptb_rnn.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
import unittest
1818
import paddle.fluid as fluid
19+
from paddle.fluid import core
1920
from paddle.fluid.dygraph.nn import Embedding
2021
import paddle.fluid.framework as framework
2122
from paddle.fluid.optimizer import SGDOptimizer
@@ -278,7 +279,8 @@ def test_ptb_rnn_cpu_float32(self):
278279
num_steps=num_steps,
279280
init_scale=init_scale)
280281

281-
exe = fluid.Executor(fluid.CPUPlace())
282+
exe = fluid.Executor(fluid.CPUPlace(
283+
) if not core.is_compiled_with_cuda() else fluid.CUDAPlace(0))
282284
sgd = SGDOptimizer(learning_rate=1e-3)
283285
x = fluid.layers.data(
284286
name="x", shape=[-1, num_steps, 1], dtype='int64')

0 commit comments

Comments
 (0)