|
12 | 12 | # See the License for the specific language governing permissions and |
13 | 13 | # limitations under the License. |
14 | 14 |
|
15 | | -import os |
16 | 15 | import unittest |
17 | 16 |
|
18 | 17 | import numpy as np |
19 | | -from op_test import check_out_dtype, paddle_static_guard |
| 18 | +from op_test import check_out_dtype, get_places, paddle_static_guard |
20 | 19 |
|
21 | 20 | import paddle |
22 | 21 | import paddle.nn.functional as F |
23 | 22 | from paddle import base |
24 | | -from paddle.base import core |
25 | 23 |
|
26 | 24 |
|
27 | 25 | def adaptive_start_index(index, input_size, output_size): |
@@ -74,15 +72,7 @@ def max_pool1D_forward_naive( |
74 | 72 | class TestPool1D_API(unittest.TestCase): |
75 | 73 | def setUp(self): |
76 | 74 | np.random.seed(123) |
77 | | - self.places = [] |
78 | | - if ( |
79 | | - os.environ.get('FLAGS_CI_both_cpu_and_gpu', 'False').lower() |
80 | | - in ['1', 'true', 'on'] |
81 | | - or not core.is_compiled_with_cuda() |
82 | | - ): |
83 | | - self.places.append(base.CPUPlace()) |
84 | | - if core.is_compiled_with_cuda(): |
85 | | - self.places.append(base.CUDAPlace(0)) |
| 75 | + self.places = get_places() |
86 | 76 |
|
87 | 77 | def check_adaptive_max_dygraph_results(self, place): |
88 | 78 | with base.dygraph.guard(place): |
@@ -149,15 +139,7 @@ def test_max_pool(self): |
149 | 139 | class TestPool1D_API_ZeroSize(unittest.TestCase): |
150 | 140 | def setUp(self): |
151 | 141 | np.random.seed(123) |
152 | | - self.places = [] |
153 | | - if ( |
154 | | - os.environ.get('FLAGS_CI_both_cpu_and_gpu', 'False').lower() |
155 | | - in ['1', 'true', 'on'] |
156 | | - or not core.is_compiled_with_cuda() |
157 | | - ): |
158 | | - self.places.append(base.CPUPlace()) |
159 | | - if core.is_compiled_with_cuda(): |
160 | | - self.places.append(base.CUDAPlace(0)) |
| 142 | + self.places = get_places() |
161 | 143 |
|
162 | 144 | def check_adaptive_max_dygraph_results(self, place): |
163 | 145 | with base.dygraph.guard(place): |
|
0 commit comments