diff --git a/python/tvm/topi/testing/poolnd_python.py b/python/tvm/topi/testing/poolnd_python.py index 43440d32f44e..28bf5fc26497 100644 --- a/python/tvm/topi/testing/poolnd_python.py +++ b/python/tvm/topi/testing/poolnd_python.py @@ -18,12 +18,60 @@ """Ground truth max and average pooling operators in python.""" import itertools import math -from typing import List, Tuple +from typing import List, Tuple, Optional import numpy as np import tvm +def _get_supported_layout(dims: int): + """ + Returns layout that is supported by poolnd_python based on number of + dimensions of input tensor + """ + assert dims in [3, 4, 5], f"{dims}-dimensional tensor is not supported" + if dims == 3: + return "NCW" + if dims == 4: + return "NCHW" + # dims == 5 + return "NCDHW" + + +def _convert_to_layout( + input_tensor: np.ndarray, + layout: str, +) -> np.ndarray: + """ + Converts back to original layout after the algorithm is finished + """ + supported_layout = _get_supported_layout(input_tensor.ndim) + if layout is not None and supported_layout != layout: + # Generate transpose list + transpose_list = [] + for d in layout: + transpose_list.append(supported_layout.index(d)) + return input_tensor.transpose(transpose_list) + return input_tensor + + +def _convert_from_layout( + input_tensor: np.ndarray, + layout: str, +) -> np.ndarray: + """ + Converts tensor to one of suppored layouts + """ + supported_layout = _get_supported_layout(input_tensor.ndim) + if layout is not None and supported_layout != layout: + # Generate transpose list + transpose_list = [] + for d in supported_layout: + transpose_list.append(layout.index(d)) + return input_tensor.transpose(transpose_list) + return input_tensor + + def get_slice( spatial_dimensions: int, pad_np: np.array, @@ -90,8 +138,12 @@ def poolnd_python( count_include_pad: bool = True, ceil_mode: bool = False, dtype: str = "float32", + layout: Optional[str] = None, ) -> np.array: """Ground truth pooling operator impelmented in numpy.""" + + np_data = _convert_from_layout(np_data, layout) + out_shape = [np_data.shape[0], np_data.shape[1]] for dim in range(2, len(np_data.shape)): i = dim - 2 @@ -158,4 +210,4 @@ def poolnd_python( else: raise ValueError("Pool type {} is not supported".format(pool_type)) - return ret_np + return _convert_to_layout(ret_np, layout) diff --git a/python/tvm/topi/x86/pooling.py b/python/tvm/topi/x86/pooling.py index 91108ac7485d..db0f9faf1970 100644 --- a/python/tvm/topi/x86/pooling.py +++ b/python/tvm/topi/x86/pooling.py @@ -26,8 +26,8 @@ def vectorize(fused_axis, num_parallel_axis, vectorize_limit=64): reorder_axis = [fused_axis] for i in range(num_parallel_axis, len(sch.op.axis) - 1): reorder_axis.append(sch.op.axis[i]) - kw, kh = sch.op.reduce_axis - fuse_k = sch.fuse(kw, kh) + k = sch.op.reduce_axis + fuse_k = sch.fuse(*k) c = sch.op.axis[len(sch.op.axis) - 1] reorder_axis += [fuse_k, c] sch.reorder(*reorder_axis) @@ -83,7 +83,7 @@ def schedule_pool(outs, layout): def _schedule(PaddedInput, Pool): if isinstance(PaddedInput.op, te.tensor.ComputeOp): s[PaddedInput].compute_inline() - do_vectorize = layout[-1] not in "HWhw" + do_vectorize = layout[-1] not in "DHWdhw" _parallel_sch(s[Pool], outs[0].shape, do_vectorize) def traverse(OP): diff --git a/tests/python/topi/python/test_topi_pooling.py b/tests/python/topi/python/test_topi_pooling.py index 57877e3d202c..b7f11de1391f 100644 --- a/tests/python/topi/python/test_topi_pooling.py +++ b/tests/python/topi/python/test_topi_pooling.py @@ -315,6 +315,7 @@ def verify_poolnd( pool_type, count_include_pad, ceil_mode, + layout=layout, ) np.testing.assert_equal(tuple(output_shape), tuple(ref_np.shape)) @@ -355,7 +356,7 @@ def verify_pool3d( padding, pool_type, ceil_mode, - layout="NCDHW", + layout=layout, count_include_pad=count_include_pad, ) @@ -363,18 +364,106 @@ def verify_pool3d( @tvm.testing.uses_gpu def test_pool3d(): """test cases of pool3d""" + verify_pool3d( + [1, 16, 32, 32, 32], [2, 2, 2], [2, 2, 2], [1, 1, 1], [0, 0, 0, 0, 0, 0], "avg", False, True + ) + verify_pool3d( + [1, 16, 31, 31, 31], [3, 3, 3], [3, 3, 3], [1, 1, 1], [1, 1, 2, 2, 2, 1], "avg", False, True + ) + verify_pool3d( + [1, 16, 32, 32, 32], + [2, 2, 2], + [2, 2, 2], + [1, 1, 1], + [1, 1, 2, 2, 2, 1], + "avg", + False, + False, + ) + verify_pool3d( + [1, 16, 31, 31, 31], + [4, 4, 4], + [4, 4, 4], + [1, 1, 1], + [3, 3, 3, 3, 3, 3], + "avg", + False, + False, + ) + verify_pool3d( + [1, 16, 31, 31, 31], + [4, 4, 4], + [4, 4, 4], + [1, 1, 1], + [0, 0, 0, 0, 0, 0], + "avg", + False, + False, + ) + verify_pool3d( + [1, 16, 32, 32, 32], [2, 2, 2], [2, 2, 2], [1, 1, 1], [0, 0, 0, 0, 0, 0], "max", False + ) + verify_pool3d( + [1, 16, 31, 31, 31], [3, 3, 3], [3, 3, 3], [1, 1, 1], [2, 2, 1, 1, 1, 2], "max", False + ) + verify_pool3d( + [1, 16, 31, 31, 31], [3, 3, 3], [3, 3, 3], [1, 1, 1], [2, 2, 1, 1, 1, 2], "max", True + ) + + verify_pool3d( + [1, 16, 31, 31, 31], [3, 3, 3], [3, 3, 3], [1, 1, 1], [2, 1, 0, 5, 4, 3], "avg", False, True + ) + verify_pool3d( + [1, 16, 32, 32, 32], + [2, 2, 2], + [2, 2, 2], + [1, 1, 1], + [0, 5, 4, 3, 2, 1], + "avg", + False, + False, + ) + verify_pool3d( + [1, 16, 31, 31, 31], [3, 3, 3], [3, 3, 3], [1, 1, 1], [1, 0, 5, 4, 3, 2], "max", False + ) + verify_pool3d( + [1, 16, 31, 31, 31], [3, 3, 3], [3, 3, 3], [1, 1, 1], [3, 2, 1, 0, 5, 4], "max", True + ) + + # Test non-1 dilation + verify_pool3d( + [1, 16, 31, 31, 31], [3, 3, 3], [3, 3, 3], [3, 3, 3], [2, 1, 0, 5, 4, 3], "avg", False, True + ) verify_pool3d( [1, 16, 32, 32, 32], [2, 2, 2], [2, 2, 2], + [2, 2, 2], + [0, 5, 4, 3, 2, 1], + "avg", + False, + False, + ) + verify_pool3d( + [1, 16, 31, 31, 31], [3, 3, 3], [3, 3, 3], [2, 1, 3], [1, 0, 5, 4, 3, 2], "max", False + ) + verify_pool3d( + [1, 16, 31, 31, 31], [3, 3, 3], [3, 3, 3], [2, 2, 3], [3, 2, 1, 0, 5, 4], "max", True + ) + # Test channel last layouts + verify_pool3d( + [1, 32, 32, 32, 16], + [2, 2, 2], + [2, 2, 2], [1, 1, 1], [0, 0, 0, 0, 0, 0], "avg", False, True, + layout="NDHWC", ) verify_pool3d( - [1, 16, 31, 31, 31], + [1, 31, 31, 31, 16], [3, 3, 3], [3, 3, 3], [1, 1, 1], @@ -382,9 +471,10 @@ def test_pool3d(): "avg", False, True, + layout="NDHWC", ) verify_pool3d( - [1, 16, 32, 32, 32], + [1, 32, 32, 32, 16], [2, 2, 2], [2, 2, 2], [1, 1, 1], @@ -392,9 +482,10 @@ def test_pool3d(): "avg", False, False, + layout="NDHWC", ) verify_pool3d( - [1, 16, 31, 31, 31], + [1, 31, 31, 31, 16], [4, 4, 4], [4, 4, 4], [1, 1, 1], @@ -402,9 +493,10 @@ def test_pool3d(): "avg", False, False, + layout="NDHWC", ) verify_pool3d( - [1, 16, 31, 31, 31], + [1, 31, 31, 31, 16], [4, 4, 4], [4, 4, 4], [1, 1, 1], @@ -412,37 +504,41 @@ def test_pool3d(): "avg", False, False, + layout="NDHWC", ) verify_pool3d( - [1, 16, 32, 32, 32], + [1, 32, 32, 32, 16], [2, 2, 2], [2, 2, 2], [1, 1, 1], [0, 0, 0, 0, 0, 0], "max", False, + layout="NDHWC", ) verify_pool3d( - [1, 16, 31, 31, 31], + [1, 31, 31, 31, 16], [3, 3, 3], [3, 3, 3], [1, 1, 1], [2, 2, 1, 1, 1, 2], "max", False, + layout="NDHWC", ) verify_pool3d( - [1, 16, 31, 31, 31], + [1, 31, 31, 31, 16], [3, 3, 3], [3, 3, 3], [1, 1, 1], [2, 2, 1, 1, 1, 2], "max", True, + layout="NDHWC", ) verify_pool3d( - [1, 16, 31, 31, 31], + [1, 31, 31, 31, 16], [3, 3, 3], [3, 3, 3], [1, 1, 1], @@ -450,9 +546,10 @@ def test_pool3d(): "avg", False, True, + layout="NDHWC", ) verify_pool3d( - [1, 16, 32, 32, 32], + [1, 32, 32, 32, 16], [2, 2, 2], [2, 2, 2], [1, 1, 1], @@ -460,36 +557,32 @@ def test_pool3d(): "avg", False, False, + layout="NDHWC", ) verify_pool3d( - [1, 16, 31, 31, 31], + [1, 31, 31, 31, 16], [3, 3, 3], [3, 3, 3], [1, 1, 1], [1, 0, 5, 4, 3, 2], "max", False, + layout="NDHWC", ) verify_pool3d( - [1, 16, 31, 31, 31], + [1, 31, 31, 31, 16], [3, 3, 3], [3, 3, 3], [1, 1, 1], [3, 2, 1, 0, 5, 4], "max", True, + layout="NDHWC", ) # Test non-1 dilation verify_pool3d( - [1, 16, 31, 31, 31], - [3, 3, 3], - [3, 3, 3], - [3, 3, 3], - [2, 1, 0, 5, 4, 3], - "avg", - False, - True, + [1, 16, 31, 31, 31], [3, 3, 3], [3, 3, 3], [3, 3, 3], [2, 1, 0, 5, 4, 3], "avg", False, True ) verify_pool3d( [1, 16, 32, 32, 32], @@ -502,27 +595,23 @@ def test_pool3d(): False, ) verify_pool3d( - [1, 16, 31, 31, 31], - [3, 3, 3], - [3, 3, 3], - [2, 1, 3], - [1, 0, 5, 4, 3, 2], - "max", - False, + [1, 16, 31, 31, 31], [3, 3, 3], [3, 3, 3], [2, 1, 3], [1, 0, 5, 4, 3, 2], "max", False ) verify_pool3d( - [1, 16, 31, 31, 31], - [3, 3, 3], - [3, 3, 3], - [2, 2, 3], - [3, 2, 1, 0, 5, 4], - "max", - True, + [1, 16, 31, 31, 31], [3, 3, 3], [3, 3, 3], [2, 2, 3], [3, 2, 1, 0, 5, 4], "max", True ) def verify_pool2d( - input_shape, kernel, stride, dilation, padding, pool_type, ceil_mode, count_include_pad=True + input_shape, + kernel, + stride, + dilation, + padding, + pool_type, + ceil_mode, + count_include_pad=True, + layout="NCHW", ): verify_poolnd( 2, @@ -533,7 +622,7 @@ def verify_pool2d( padding, pool_type, ceil_mode, - layout="NCHW", + layout=layout, count_include_pad=count_include_pad, ) @@ -541,162 +630,69 @@ def verify_pool2d( @tvm.testing.uses_gpu def test_pool2d(): """test cases of pool""" + verify_pool2d([1, 16, 32, 32], [2, 2], [2, 2], [1, 1], [0, 0, 0, 0], "avg", False, True) + verify_pool2d([1, 16, 31, 31], [3, 3], [3, 3], [1, 1], [1, 2, 1, 2], "avg", False, True) + verify_pool2d([1, 16, 32, 32], [2, 2], [2, 2], [1, 1], [1, 2, 1, 2], "avg", False, False) + verify_pool2d([1, 16, 31, 31], [4, 4], [4, 4], [1, 1], [3, 3, 3, 3], "avg", False, False) + verify_pool2d([1, 16, 31, 31], [4, 4], [4, 4], [1, 1], [0, 0, 0, 0], "avg", False, False) + verify_pool2d([1, 16, 32, 32], [2, 3], [2, 2], [1, 1], [0, 0, 0, 0], "max", False) + verify_pool2d([1, 16, 31, 31], [3, 3], [3, 3], [1, 1], [2, 1, 2, 1], "max", False) + verify_pool2d([1, 16, 31, 31], [3, 3], [3, 3], [1, 1], [2, 1, 2, 1], "max", True) + + verify_pool2d([1, 16, 31, 31], [3, 3], [3, 3], [1, 1], [2, 1, 0, 3], "avg", False, True) + verify_pool2d([1, 16, 32, 32], [2, 3], [2, 2], [1, 1], [0, 3, 2, 1], "avg", False, False) + verify_pool2d([1, 16, 31, 31], [3, 3], [3, 3], [1, 1], [1, 0, 3, 2], "max", False) + verify_pool2d([1, 16, 31, 31], [3, 3], [3, 3], [1, 1], [3, 2, 1, 0], "max", True) + + # Test non-1 dilations + verify_pool2d([1, 16, 31, 31], [3, 3], [3, 3], [2, 1], [2, 1, 0, 3], "avg", False, True) + verify_pool2d([1, 16, 32, 32], [2, 3], [2, 2], [2, 3], [0, 3, 2, 1], "avg", False, False) + verify_pool2d([1, 16, 31, 31], [3, 3], [3, 3], [3, 3], [1, 0, 3, 2], "max", False) + verify_pool2d([1, 16, 31, 31], [3, 3], [3, 3], [2, 2], [3, 2, 1, 0], "max", True) + # Test channel last verify_pool2d( - [1, 16, 32, 32], - [2, 2], - [2, 2], - [1, 1], - [0, 0, 0, 0], - "avg", - False, - True, - ) - verify_pool2d( - [1, 16, 31, 31], - [3, 3], - [3, 3], - [1, 1], - [1, 2, 1, 2], - "avg", - False, - True, + [1, 32, 32, 16], [2, 2], [2, 2], [1, 1], [0, 0, 0, 0], "avg", False, True, layout="NHWC" ) verify_pool2d( - [1, 16, 32, 32], - [2, 2], - [2, 2], - [1, 1], - [1, 2, 1, 2], - "avg", - False, - False, + [1, 31, 31, 16], [3, 3], [3, 3], [1, 1], [1, 2, 1, 2], "avg", False, True, layout="NHWC" ) verify_pool2d( - [1, 16, 31, 31], - [4, 4], - [4, 4], - [1, 1], - [3, 3, 3, 3], - "avg", - False, - False, + [1, 32, 32, 16], [2, 2], [2, 2], [1, 1], [1, 2, 1, 2], "avg", False, False, layout="NHWC" ) verify_pool2d( - [1, 16, 31, 31], - [4, 4], - [4, 4], - [1, 1], - [0, 0, 0, 0], - "avg", - False, - False, + [1, 31, 31, 16], [4, 4], [4, 4], [1, 1], [3, 3, 3, 3], "avg", False, False, layout="NHWC" ) verify_pool2d( - [1, 16, 32, 32], - [2, 3], - [2, 2], - [1, 1], - [0, 0, 0, 0], - "max", - False, + [1, 31, 31, 16], [4, 4], [4, 4], [1, 1], [0, 0, 0, 0], "avg", False, False, layout="NHWC" ) verify_pool2d( - [1, 16, 31, 31], - [3, 3], - [3, 3], - [1, 1], - [2, 1, 2, 1], - "max", - False, + [1, 32, 32, 16], [2, 3], [2, 2], [1, 1], [0, 0, 0, 0], "max", False, layout="NHWC" ) verify_pool2d( - [1, 16, 31, 31], - [3, 3], - [3, 3], - [1, 1], - [2, 1, 2, 1], - "max", - True, + [1, 31, 31, 16], [3, 3], [3, 3], [1, 1], [2, 1, 2, 1], "max", False, layout="NHWC" ) + verify_pool2d([1, 31, 31, 16], [3, 3], [3, 3], [1, 1], [2, 1, 2, 1], "max", True, layout="NHWC") verify_pool2d( - [1, 16, 31, 31], - [3, 3], - [3, 3], - [1, 1], - [2, 1, 0, 3], - "avg", - False, - True, - ) - verify_pool2d( - [1, 16, 32, 32], - [2, 3], - [2, 2], - [1, 1], - [0, 3, 2, 1], - "avg", - False, - False, - ) - verify_pool2d( - [1, 16, 31, 31], - [3, 3], - [3, 3], - [1, 1], - [1, 0, 3, 2], - "max", - False, + [1, 31, 31, 16], [3, 3], [3, 3], [1, 1], [2, 1, 0, 3], "avg", False, True, layout="NHWC" ) verify_pool2d( - [1, 16, 31, 31], - [3, 3], - [3, 3], - [1, 1], - [3, 2, 1, 0], - "max", - True, + [1, 32, 32, 16], [2, 3], [2, 2], [1, 1], [0, 3, 2, 1], "avg", False, False, layout="NHWC" ) - - # Test non-1 dilations verify_pool2d( - [1, 16, 31, 31], - [3, 3], - [3, 3], - [2, 1], - [2, 1, 0, 3], - "avg", - False, - True, + [1, 31, 31, 16], [3, 3], [3, 3], [1, 1], [1, 0, 3, 2], "max", False, layout="NHWC" ) + verify_pool2d([1, 31, 31, 16], [3, 3], [3, 3], [1, 1], [3, 2, 1, 0], "max", True, layout="NHWC") verify_pool2d( - [1, 16, 32, 32], - [2, 3], - [2, 2], - [2, 3], - [0, 3, 2, 1], - "avg", - False, - False, + [1, 31, 31, 16], [3, 3], [3, 3], [2, 1], [2, 1, 0, 3], "avg", False, True, layout="NHWC" ) verify_pool2d( - [1, 16, 31, 31], - [3, 3], - [3, 3], - [3, 3], - [1, 0, 3, 2], - "max", - False, + [1, 32, 32, 16], [2, 3], [2, 2], [2, 3], [0, 3, 2, 1], "avg", False, False, layout="NHWC" ) verify_pool2d( - [1, 16, 31, 31], - [3, 3], - [3, 3], - [2, 2], - [3, 2, 1, 0], - "max", - True, + [1, 31, 31, 16], [3, 3], [3, 3], [3, 3], [1, 0, 3, 2], "max", False, layout="NHWC" ) + verify_pool2d([1, 31, 31, 16], [3, 3], [3, 3], [2, 2], [3, 2, 1, 0], "max", True, layout="NHWC") def verify_pool1d( @@ -719,7 +715,7 @@ def verify_pool1d( padding, pool_type, ceil_mode, - layout="NCW", + layout=layout, count_include_pad=count_include_pad, ) @@ -727,162 +723,43 @@ def verify_pool1d( @tvm.testing.uses_gpu def test_pool1d(): """test cases of pool1d""" - verify_pool1d( - [1, 16, 32], - [2], - [2], - [1], - [0, 0], - "avg", - False, - True, - ) - verify_pool1d( - [1, 16, 31], - [3], - [3], - [1], - [1, 2], - "avg", - False, - True, - ) - verify_pool1d( - [1, 16, 32], - [2], - [2], - [1], - [1, 2], - "avg", - False, - False, - ) - verify_pool1d( - [1, 16, 31], - [4], - [4], - [1], - [3, 3], - "avg", - False, - False, - ) - verify_pool1d( - [1, 16, 31], - [4], - [4], - [1], - [0, 0], - "avg", - False, - False, - ) - verify_pool1d( - [1, 16, 32], - [2], - [2], - [1], - [0, 0], - "max", - False, - ) - verify_pool1d( - [1, 16, 31], - [3], - [3], - [1], - [2, 1], - "max", - False, - ) - verify_pool1d( - [1, 16, 31], - [3], - [3], - [1], - [2, 1], - "max", - True, - ) - - verify_pool1d( - [1, 16, 31], - [3], - [3], - [1], - [2, 5], - "avg", - False, - True, - ) - verify_pool1d( - [1, 16, 32], - [2], - [2], - [1], - [0, 3], - "avg", - False, - False, - ) - verify_pool1d( - [1, 16, 31], - [3], - [3], - [1], - [1, 4], - "max", - False, - ) - verify_pool1d( - [1, 16, 31], - [3], - [3], - [1], - [3, 0], - "max", - True, - ) + verify_pool1d([1, 16, 32], [2], [2], [1], [0, 0], "avg", False, True) + verify_pool1d([1, 16, 31], [3], [3], [1], [1, 2], "avg", False, True) + verify_pool1d([1, 16, 32], [2], [2], [1], [1, 2], "avg", False, False) + verify_pool1d([1, 16, 31], [4], [4], [1], [3, 3], "avg", False, False) + verify_pool1d([1, 16, 31], [4], [4], [1], [0, 0], "avg", False, False) + verify_pool1d([1, 16, 32], [2], [2], [1], [0, 0], "max", False) + verify_pool1d([1, 16, 31], [3], [3], [1], [2, 1], "max", False) + verify_pool1d([1, 16, 31], [3], [3], [1], [2, 1], "max", True) + + verify_pool1d([1, 16, 31], [3], [3], [1], [2, 5], "avg", False, True) + verify_pool1d([1, 16, 32], [2], [2], [1], [0, 3], "avg", False, False) + verify_pool1d([1, 16, 31], [3], [3], [1], [1, 4], "max", False) + verify_pool1d([1, 16, 31], [3], [3], [1], [3, 0], "max", True) # Test non-1 dilations - verify_pool1d( - [1, 16, 31], - [3], - [3], - [2], - [2, 5], - "avg", - False, - True, - ) - verify_pool1d( - [1, 16, 32], - [2], - [2], - [3], - [0, 3], - "avg", - False, - False, - ) - verify_pool1d( - [1, 16, 31], - [3], - [3], - [2], - [1, 4], - "max", - False, - ) - verify_pool1d( - [1, 16, 31], - [3], - [3], - [3], - [3, 0], - "max", - True, - ) + verify_pool1d([1, 16, 31], [3], [3], [2], [2, 5], "avg", False, True) + verify_pool1d([1, 16, 32], [2], [2], [3], [0, 3], "avg", False, False) + verify_pool1d([1, 16, 31], [3], [3], [2], [1, 4], "max", False) + verify_pool1d([1, 16, 31], [3], [3], [3], [3, 0], "max", True) + # Test Channel last + verify_pool1d([1, 32, 16], [2], [2], [1], [0, 0], "avg", False, True, layout="NWC") + verify_pool1d([1, 31, 16], [3], [3], [1], [1, 2], "avg", False, True, layout="NWC") + verify_pool1d([1, 32, 16], [2], [2], [1], [1, 2], "avg", False, False, layout="NWC") + verify_pool1d([1, 31, 16], [4], [4], [1], [3, 3], "avg", False, False, layout="NWC") + verify_pool1d([1, 31, 16], [4], [4], [1], [0, 0], "avg", False, False, layout="NWC") + verify_pool1d([1, 32, 16], [2], [2], [1], [0, 0], "max", False, layout="NWC") + verify_pool1d([1, 31, 16], [3], [3], [1], [2, 1], "max", False, layout="NWC") + verify_pool1d([1, 31, 16], [3], [3], [1], [2, 1], "max", True, layout="NWC") + + verify_pool1d([1, 31, 16], [3], [3], [1], [2, 5], "avg", False, True, layout="NWC") + verify_pool1d([1, 31, 16], [2], [2], [1], [0, 3], "avg", False, False, layout="NWC") + verify_pool1d([1, 31, 16], [3], [3], [1], [1, 4], "max", False, layout="NWC") + verify_pool1d([1, 31, 16], [3], [3], [1], [3, 0], "max", True, layout="NWC") + verify_pool1d([1, 31, 16], [3], [3], [2], [2, 5], "avg", False, True, layout="NWC") + verify_pool1d([1, 32, 16], [2], [2], [3], [0, 3], "avg", False, False, layout="NWC") + verify_pool1d([1, 31, 16], [3], [3], [2], [1, 4], "max", False, layout="NWC") + verify_pool1d([1, 31, 16], [3], [3], [3], [3, 0], "max", True, layout="NWC") if __name__ == "__main__":