Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
94 changes: 15 additions & 79 deletions test/legacy_test/test_cov.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,12 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import os
import unittest

import numpy as np
from op_test import get_places

import paddle
from paddle import base


def numpy_cov(np_arr, rowvar=True, ddof=1, fweights=None, aweights=None):
Expand All @@ -38,17 +37,8 @@ def setUp(self):

def test_tensor_cov_default(self):
typelist = ['float64']
places = []
if (
os.environ.get('FLAGS_CI_both_cpu_and_gpu', 'False').lower()
in ['1', 'true', 'on']
or not base.core.is_compiled_with_cuda()
):
places.append(base.CPUPlace())
if base.core.is_compiled_with_cuda():
places.append(base.CUDAPlace(0))

for idx, p in enumerate(places):

for idx, p in enumerate(get_places()):
if idx == 0:
paddle.set_device('cpu')
else:
Expand All @@ -67,17 +57,8 @@ def test_tensor_cov_default(self):

def test_tensor_cov_rowvar(self):
typelist = ['float64']
places = []
if (
os.environ.get('FLAGS_CI_both_cpu_and_gpu', 'False').lower()
in ['1', 'true', 'on']
or not base.core.is_compiled_with_cuda()
):
places.append(base.CPUPlace())
if base.core.is_compiled_with_cuda():
places.append(base.CUDAPlace(0))

for idx, p in enumerate(places):

for idx, p in enumerate(get_places()):
if idx == 0:
paddle.set_device('cpu')
else:
Expand All @@ -100,17 +81,8 @@ def test_tensor_cov_rowvar(self):

def test_tensor_cov_ddof(self):
typelist = ['float64']
places = []
if (
os.environ.get('FLAGS_CI_both_cpu_and_gpu', 'False').lower()
in ['1', 'true', 'on']
or not base.core.is_compiled_with_cuda()
):
places.append(base.CPUPlace())
if base.core.is_compiled_with_cuda():
places.append(base.CUDAPlace(0))

for idx, p in enumerate(places):

for idx, p in enumerate(get_places()):
if idx == 0:
paddle.set_device('cpu')
else:
Expand All @@ -133,17 +105,8 @@ def test_tensor_cov_ddof(self):

def test_tensor_cov_fweights(self):
typelist = ['float64']
places = []
if (
os.environ.get('FLAGS_CI_both_cpu_and_gpu', 'False').lower()
in ['1', 'true', 'on']
or not base.core.is_compiled_with_cuda()
):
places.append(base.CPUPlace())
if base.core.is_compiled_with_cuda():
places.append(base.CUDAPlace(0))

for idx, p in enumerate(places):

for idx, p in enumerate(get_places()):
if idx == 0:
paddle.set_device('cpu')
else:
Expand All @@ -170,17 +133,8 @@ def test_tensor_cov_fweights(self):

def test_tensor_cov_aweights(self):
typelist = ['float64']
places = []
if (
os.environ.get('FLAGS_CI_both_cpu_and_gpu', 'False').lower()
in ['1', 'true', 'on']
or not base.core.is_compiled_with_cuda()
):
places.append(base.CPUPlace())
if base.core.is_compiled_with_cuda():
places.append(base.CUDAPlace(0))

for idx, p in enumerate(places):

for idx, p in enumerate(get_places()):
if idx == 0:
paddle.set_device('cpu')
else:
Expand All @@ -207,17 +161,8 @@ def test_tensor_cov_aweights(self):

def test_tensor_cov_weights(self):
typelist = ['float64']
places = []
if (
os.environ.get('FLAGS_CI_both_cpu_and_gpu', 'False').lower()
in ['1', 'true', 'on']
or not base.core.is_compiled_with_cuda()
):
places.append(base.CPUPlace())
if base.core.is_compiled_with_cuda():
places.append(base.CUDAPlace(0))

for idx, p in enumerate(places):

for idx, p in enumerate(get_places()):
if idx == 0:
paddle.set_device('cpu')
else:
Expand Down Expand Up @@ -349,17 +294,8 @@ def setUp(self):

def test_tensor_cov_default(self):
typelist = ['float64']
places = []
if (
os.environ.get('FLAGS_CI_both_cpu_and_gpu', 'False').lower()
in ['1', 'true', 'on']
or not base.core.is_compiled_with_cuda()
):
places.append(base.CPUPlace())
if base.core.is_compiled_with_cuda():
places.append(base.CUDAPlace(0))

for idx, p in enumerate(places):

for idx, p in enumerate(get_places()):
if idx == 0:
paddle.set_device('cpu')
else:
Expand Down
46 changes: 5 additions & 41 deletions test/legacy_test/test_multiprocess_dataloader_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import os
import unittest

import numpy as np
from op_test import get_places

import paddle
from paddle import base
Expand Down Expand Up @@ -89,16 +89,7 @@ def run_main(self, num_workers, places):
np.testing.assert_allclose(label.numpy(), label_np[i])

def test_main(self):
places = []
if (
os.environ.get('FLAGS_CI_both_cpu_and_gpu', 'False').lower()
in ['1', 'true', 'on']
or not paddle.is_compiled_with_cuda()
):
places.append(paddle.CPUPlace())
if paddle.is_compiled_with_cuda():
places.append(paddle.CUDAPlace(0))
for p in places:
for p in get_places():
self.run_main(num_workers=0, places=p)


Expand Down Expand Up @@ -205,16 +196,7 @@ def assert_basic(input, label):
def test_main(self):
paddle.seed(1)

places = []
if (
os.environ.get('FLAGS_CI_both_cpu_and_gpu', 'False').lower()
in ['1', 'true', 'on']
or not paddle.is_compiled_with_cuda()
):
places.append(paddle.CPUPlace())
if paddle.is_compiled_with_cuda():
places.append(paddle.CUDAPlace(0))
for p in places:
for p in get_places():
self.run_main(num_workers=0, places=p)


Expand Down Expand Up @@ -242,16 +224,7 @@ def run_main(self, num_workers, places):
idx += 1

def test_main(self):
places = []
if (
os.environ.get('FLAGS_CI_both_cpu_and_gpu', 'False').lower()
in ['1', 'true', 'on']
or not paddle.is_compiled_with_cuda()
):
places.append(paddle.CPUPlace())
if paddle.is_compiled_with_cuda():
places.append(paddle.CUDAPlace(0))
for p in places:
for p in get_places():
self.run_main(num_workers=0, places=p)


Expand Down Expand Up @@ -472,16 +445,7 @@ def run_main(self, num_workers, places):
result[11]

def test_main(self):
places = []
if (
os.environ.get('FLAGS_CI_both_cpu_and_gpu', 'False').lower()
in ['1', 'true', 'on']
or not paddle.is_compiled_with_cuda()
):
places.append(paddle.CPUPlace())
if paddle.is_compiled_with_cuda():
places.append(paddle.CUDAPlace(0))
for p in places:
for p in get_places():
self.run_main(num_workers=0, places=p)

def test_iterable_dataset_err(self):
Expand Down
23 changes: 3 additions & 20 deletions test/legacy_test/test_pool2d_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import os
import sys
import unittest

import numpy as np

sys.path.append("../deprecated/legacy_test")
from op_test import get_places
from test_pool2d_op import (
avg_pool2D_forward_naive,
max_pool2D_forward_naive,
Expand All @@ -27,22 +27,13 @@

import paddle
from paddle import base
from paddle.base import core
from paddle.nn.functional import avg_pool2d, lp_pool2d, max_pool2d


class TestPool2D_API(unittest.TestCase):
def setUp(self):
np.random.seed(123)
self.places = []
if (
os.environ.get('FLAGS_CI_both_cpu_and_gpu', 'False').lower()
in ['1', 'true', 'on']
or not core.is_compiled_with_cuda()
):
self.places.append(base.CPUPlace())
if core.is_compiled_with_cuda():
self.places.append(base.CUDAPlace(0))
self.places = get_places()

def check_avg_static_results(self, place):
with paddle.static.program_guard(
Expand Down Expand Up @@ -1066,15 +1057,7 @@ def run_zero_norm_type():
class TestPool2D_API_ZeroSize(unittest.TestCase):
def setUp(self):
np.random.seed(123)
self.places = []
if (
os.environ.get('FLAGS_CI_both_cpu_and_gpu', 'False').lower()
in ['1', 'true', 'on']
or not core.is_compiled_with_cuda()
):
self.places.append(base.CPUPlace())
if core.is_compiled_with_cuda():
self.places.append(base.CUDAPlace(0))
self.places = get_places()

def check_avg_dygraph_results(self, place):
with base.dygraph.guard(place):
Expand Down
44 changes: 5 additions & 39 deletions test/legacy_test/test_unflatten.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import os
import unittest

import numpy as np
from op_test import get_places

import paddle

Expand Down Expand Up @@ -69,15 +69,7 @@ def setUp(self):
self.set_api()
self.set_args()
self.get_output()
self.places = []
if (
os.environ.get('FLAGS_CI_both_cpu_and_gpu', 'False').lower()
in ['1', 'true', 'on']
or not paddle.device.is_compiled_with_cuda()
):
self.places.append(paddle.CPUPlace())
if paddle.device.is_compiled_with_cuda():
self.places.append(paddle.CUDAPlace(0))
self.places = get_places()

def func_dygraph(self):
for place in self.places:
Expand All @@ -96,16 +88,7 @@ def test_dygraph(self):

def test_static(self):
paddle.enable_static()
places = []
if (
os.environ.get('FLAGS_CI_both_cpu_and_gpu', 'False').lower()
in ['1', 'true', 'on']
or not paddle.device.is_compiled_with_cuda()
):
places.append(paddle.CPUPlace())
if paddle.device.is_compiled_with_cuda():
places.append(paddle.CUDAPlace(0))
for place in places:
for place in get_places():
with paddle.static.program_guard(
paddle.static.Program(), paddle.static.Program()
):
Expand Down Expand Up @@ -273,27 +256,10 @@ def set_args(self):

def setUp(self):
self.set_args()
self.places = []
if (
os.environ.get('FLAGS_CI_both_cpu_and_gpu', 'False').lower()
in ['1', 'true', 'on']
or not paddle.device.is_compiled_with_cuda()
):
self.places.append(paddle.CPUPlace())
if paddle.device.is_compiled_with_cuda():
self.places.append(paddle.CUDAPlace(0))
self.places = get_places()

def test_layer(self):
places = []
if (
os.environ.get('FLAGS_CI_both_cpu_and_gpu', 'False').lower()
in ['1', 'true', 'on']
or not paddle.device.is_compiled_with_cuda()
):
places.append(paddle.CPUPlace())
if paddle.device.is_compiled_with_cuda():
places.append(paddle.CUDAPlace(0))
for place in places:
for place in get_places():
paddle.disable_static()
x = paddle.to_tensor(self.x, dtype='float32', place=place)
unflatten = paddle.nn.Unflatten(self.axis, self.shape)
Expand Down
Loading
Loading