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

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions test/legacy_test/test_unfold_op.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,33 @@ def init_dtype(self):
self.dtype = np.float16


class TestUnfoldZeroSize(TestUnfoldOp):
"""
This is for test on unfold Op with zero size input
"""

def init_data(self):
self.batch_size = 3
self.input_channels = 0
self.input_height = 20
self.input_width = 20
self.kernel_sizes = [3, 3]
self.strides = [1, 1]
self.paddings = [1, 1, 1, 1]
self.dilations = [1, 1]
input_shape = [
self.batch_size,
self.input_channels,
self.input_height,
self.input_width,
]
if self.dtype == np.uint16:
as_type = self.np_dtype
else:
as_type = self.dtype
self.x = np.random.rand(*input_shape).astype(as_type)


@unittest.skipIf(
not core.is_compiled_with_cuda()
or not core.is_bfloat16_supported(core.CUDAPlace(0)),
Expand Down
23 changes: 23 additions & 0 deletions test/xpu/test_unfold_op_xpu.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,29 @@ def test_dygraph(self):
def test_info(self):
str(paddle.nn.Unfold(**self.attrs))

class TestUnfoldZeroSize(TestUnfoldOp):
"""
This is for test on unfold Op with zero size input
"""

def init_data(self):
self.batch_size = 3
self.input_channels = 0
self.input_height = 20
self.input_width = 20

self.kernel_sizes = [2, 2]
self.strides = [1, 1]
self.paddings = [1, 1, 1, 1]
self.dilations = [1, 1]
input_shape = [
self.batch_size,
self.input_channels,
self.input_height,
self.input_width,
]
self.x = np.random.rand(*input_shape).astype(self.dtype)


support_types = get_xpu_op_support_types('unfold')
for stype in support_types:
Expand Down
Loading