未验证 提交 d71c3463 编写于 作者: D Double_V 提交者: GitHub

fix pool exclusive and delete disable_static (#28655)

* fix pool exclusive and delete disable_static, test=develop

* fix pool1d  exclusive, test=develop
上级 8040fa2b
...@@ -200,7 +200,6 @@ def avg_pool1d(x, ...@@ -200,7 +200,6 @@ def avg_pool1d(x,
.. code-block:: python .. code-block:: python
import paddle import paddle
import paddle.nn.functional as F import paddle.nn.functional as F
paddle.disable_static()
data = paddle.to_tensor(np.random.uniform(-1, 1, [1, 3, 32]).astype(np.float32)) data = paddle.to_tensor(np.random.uniform(-1, 1, [1, 3, 32]).astype(np.float32))
out = F.avg_pool1d(data, kernel_size=2, stride=2, padding=0) out = F.avg_pool1d(data, kernel_size=2, stride=2, padding=0)
# out shape: [1, 3, 16] # out shape: [1, 3, 16]
...@@ -253,7 +252,7 @@ def avg_pool1d(x, ...@@ -253,7 +252,7 @@ def avg_pool1d(x,
"use_cudnn": True, "use_cudnn": True,
"ceil_mode": ceil_mode, "ceil_mode": ceil_mode,
"use_mkldnn": False, "use_mkldnn": False,
"exclusive": not exclusive, "exclusive": exclusive,
"data_format": data_format, "data_format": data_format,
}) })
...@@ -314,7 +313,6 @@ def avg_pool2d(x, ...@@ -314,7 +313,6 @@ def avg_pool2d(x,
import paddle import paddle
import paddle.nn.functional as F import paddle.nn.functional as F
import numpy as np import numpy as np
paddle.disable_static()
# avg pool2d # avg pool2d
x = paddle.to_tensor(np.random.uniform(-1, 1, [1, 3, 32, 32]).astype(np.float32)) x = paddle.to_tensor(np.random.uniform(-1, 1, [1, 3, 32, 32]).astype(np.float32))
out = F.avg_pool2d(x, out = F.avg_pool2d(x,
...@@ -365,7 +363,7 @@ def avg_pool2d(x, ...@@ -365,7 +363,7 @@ def avg_pool2d(x,
"use_cudnn": True, "use_cudnn": True,
"ceil_mode": ceil_mode, "ceil_mode": ceil_mode,
"use_mkldnn": False, "use_mkldnn": False,
"exclusive": not exclusive, "exclusive": exclusive,
"data_format": data_format, "data_format": data_format,
}) })
...@@ -481,7 +479,7 @@ def avg_pool3d(x, ...@@ -481,7 +479,7 @@ def avg_pool3d(x,
"use_cudnn": True, "use_cudnn": True,
"ceil_mode": ceil_mode, "ceil_mode": ceil_mode,
"use_mkldnn": False, "use_mkldnn": False,
"exclusive": not exclusive, "exclusive": exclusive,
"data_format": data_format, "data_format": data_format,
}) })
...@@ -538,7 +536,6 @@ def max_pool1d(x, ...@@ -538,7 +536,6 @@ def max_pool1d(x,
.. code-block:: python .. code-block:: python
import paddle import paddle
import paddle.nn.functional as F import paddle.nn.functional as F
paddle.disable_static()
data = paddle.to_tensor(np.random.uniform(-1, 1, [1, 3, 32]).astype(np.float32)) data = paddle.to_tensor(np.random.uniform(-1, 1, [1, 3, 32]).astype(np.float32))
pool_out = F.max_pool1d(data, kernel_size=2, stride=2, padding=0) pool_out = F.max_pool1d(data, kernel_size=2, stride=2, padding=0)
# pool_out shape: [1, 3, 16] # pool_out shape: [1, 3, 16]
...@@ -661,7 +658,6 @@ def max_pool2d(x, ...@@ -661,7 +658,6 @@ def max_pool2d(x,
import paddle import paddle
import paddle.nn.functional as F import paddle.nn.functional as F
import numpy as np import numpy as np
paddle.disable_static()
# max pool2d # max pool2d
x = paddle.to_tensor(np.random.uniform(-1, 1, [1, 3, 32, 32]).astype(np.float32)) x = paddle.to_tensor(np.random.uniform(-1, 1, [1, 3, 32, 32]).astype(np.float32))
out = F.max_pool2d(x, out = F.max_pool2d(x,
...@@ -791,7 +787,7 @@ def max_pool3d(x, ...@@ -791,7 +787,7 @@ def max_pool3d(x,
import paddle import paddle
import paddle.nn.functional as F import paddle.nn.functional as F
import numpy as np import numpy as np
paddle.disable_static()
# max pool3d # max pool3d
x = paddle.to_tensor(np.random.uniform(-1, 1, [1, 3, 32, 32, 32]).astype(np.float32)) x = paddle.to_tensor(np.random.uniform(-1, 1, [1, 3, 32, 32, 32]).astype(np.float32))
output = F.max_pool2d(x, output = F.max_pool2d(x,
...@@ -905,7 +901,7 @@ def adaptive_avg_pool1d(x, output_size, name=None): ...@@ -905,7 +901,7 @@ def adaptive_avg_pool1d(x, output_size, name=None):
# #
import paddle import paddle
import paddle.nn.functional as F import paddle.nn.functional as F
paddle.disable_static()
data = paddle.to_tensor(np.random.uniform(-1, 1, [1, 3, 32]).astype(np.float32)) data = paddle.to_tensor(np.random.uniform(-1, 1, [1, 3, 32]).astype(np.float32))
pool_out = F.adaptive_average_pool1d(data, output_size=16) pool_out = F.adaptive_average_pool1d(data, output_size=16)
# pool_out shape: [1, 3, 16]) # pool_out shape: [1, 3, 16])
...@@ -982,7 +978,7 @@ def adaptive_avg_pool2d(x, output_size, data_format='NCHW', name=None): ...@@ -982,7 +978,7 @@ def adaptive_avg_pool2d(x, output_size, data_format='NCHW', name=None):
# #
import paddle import paddle
import numpy as np import numpy as np
paddle.disable_static()
input_data = np.random.rand(2, 3, 32, 32) input_data = np.random.rand(2, 3, 32, 32)
x = paddle.to_tensor(input_data) x = paddle.to_tensor(input_data)
# x.shape is [2, 3, 32, 32] # x.shape is [2, 3, 32, 32]
...@@ -1086,7 +1082,7 @@ def adaptive_avg_pool3d(x, output_size, data_format='NCDHW', name=None): ...@@ -1086,7 +1082,7 @@ def adaptive_avg_pool3d(x, output_size, data_format='NCDHW', name=None):
# avg(input[:, :, dstart:dend, hstart: hend, wstart: wend]) # avg(input[:, :, dstart:dend, hstart: hend, wstart: wend])
import paddle import paddle
import numpy as np import numpy as np
paddle.disable_static()
input_data = np.random.rand(2, 3, 8, 32, 32) input_data = np.random.rand(2, 3, 8, 32, 32)
x = paddle.to_tensor(input_data) x = paddle.to_tensor(input_data)
# x.shape is [2, 3, 8, 32, 32] # x.shape is [2, 3, 8, 32, 32]
...@@ -1186,7 +1182,7 @@ def adaptive_max_pool1d(x, output_size, return_mask=False, name=None): ...@@ -1186,7 +1182,7 @@ def adaptive_max_pool1d(x, output_size, return_mask=False, name=None):
# #
import paddle import paddle
import paddle.nn.functional as F import paddle.nn.functional as F
paddle.disable_static()
data = paddle.to_tensor(np.random.uniform(-1, 1, [1, 3, 32]).astype(np.float32)) data = paddle.to_tensor(np.random.uniform(-1, 1, [1, 3, 32]).astype(np.float32))
pool_out = F.adaptive_max_pool1d(data, output_size=16) pool_out = F.adaptive_max_pool1d(data, output_size=16)
# pool_out shape: [1, 3, 16]) # pool_out shape: [1, 3, 16])
...@@ -1266,7 +1262,7 @@ def adaptive_max_pool2d(x, output_size, return_mask=False, name=None): ...@@ -1266,7 +1262,7 @@ def adaptive_max_pool2d(x, output_size, return_mask=False, name=None):
# #
import paddle import paddle
import numpy as np import numpy as np
paddle.disable_static()
input_data = np.random.rand(2, 3, 32, 32) input_data = np.random.rand(2, 3, 32, 32)
x = paddle.to_tensor(input_data) x = paddle.to_tensor(input_data)
# x.shape is [2, 3, 32, 32] # x.shape is [2, 3, 32, 32]
...@@ -1356,7 +1352,7 @@ def adaptive_max_pool3d(x, output_size, return_mask=False, name=None): ...@@ -1356,7 +1352,7 @@ def adaptive_max_pool3d(x, output_size, return_mask=False, name=None):
# #
import paddle import paddle
import numpy as np import numpy as np
paddle.disable_static()
input_data = np.random.rand(2, 3, 8, 32, 32) input_data = np.random.rand(2, 3, 8, 32, 32)
x = paddle.to_tensor(input_data) x = paddle.to_tensor(input_data)
# x.shape is [2, 3, 8, 32, 32] # x.shape is [2, 3, 8, 32, 32]
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册