Skip to content

Commit

Permalink
Remove redundant code
Browse files Browse the repository at this point in the history
  • Loading branch information
From00 committed Apr 2, 2022
1 parent 79accac commit eb7df92
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 31 deletions.
1 change: 0 additions & 1 deletion python/paddle/fluid/dygraph/nn.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
import os
import paddle.utils.deprecated as deprecated
from paddle import _C_ops
from ..framework import _in_legacy_dygraph, in_dygraph_mode

__all__ = [
'Conv2D', 'Conv3D', 'Pool2D', 'Linear', 'BatchNorm', 'Dropout', 'Embedding',
Expand Down
32 changes: 2 additions & 30 deletions python/paddle/nn/functional/pooling.py
Original file line number Diff line number Diff line change
Expand Up @@ -1301,14 +1301,7 @@ def adaptive_avg_pool1d(x, output_size, name=None):
pool_size = [1] + utils.convert_to_list(output_size, 1, 'pool_size')

x = unsqueeze(x, [2])

if in_dygraph_mode():
pool_out = _C_ops.final_state_pool2d(x, pool_size, [1, 1], [0, 0],
False, True, "NCDHW", pool_type,
False, True, "EXPLICIT")
return squeeze(pool_out, [2])

if _in_legacy_dygraph():
if in_dynamic_mode():
pool_out = _C_ops.pool2d(x, 'pooling_type', pool_type, 'ksize',
pool_size, 'adaptive', True)
return squeeze(pool_out, [2])
Expand Down Expand Up @@ -1517,12 +1510,7 @@ def adaptive_avg_pool3d(x, output_size, data_format='NCDHW', name=None):
if output_size[2] == None:
output_size[2] = in_w

if in_dygraph_mode():
return _C_ops.final_state_pool3d(x, output_size, [1, 1, 1], [0, 0, 0],
False, True, data_format, 'avg', False,
True, "EXPLICIT")

if _in_legacy_dygraph():
if in_dynamic_mode():
return _C_ops.pool3d(x, 'pooling_type', 'avg', 'ksize', output_size,
'global_pooling', False, 'adaptive', True,
'data_format', data_format)
Expand Down Expand Up @@ -1606,12 +1594,6 @@ def adaptive_max_pool1d(x, output_size, return_mask=False, name=None):

x = unsqueeze(x, [2])
if in_dygraph_mode():
pool_out = _C_ops.final_state_max_pool2d_with_index(
x, pool_size, [1, 1], [0, 0], False, True)
return (squeeze(pool_out[0], [2]), squeeze(
pool_out[1], [2])) if return_mask else squeeze(pool_out[0], [2])

if _in_legacy_dygraph():
pool_out = _C_ops.max_pool2d_with_index(
x, 'pooling_type', pool_type, 'ksize', pool_size, 'adaptive', True)
return (squeeze(pool_out[0], [2]), squeeze(
Expand Down Expand Up @@ -1701,11 +1683,6 @@ def adaptive_max_pool2d(x, output_size, return_mask=False, name=None):
output_size[1] = in_w

if in_dygraph_mode():
pool_out = _C_ops.final_state_max_pool2d_with_index(
x, output_size, [1, 1], [0, 0], False, True)
return pool_out if return_mask else pool_out[0]

if _in_legacy_dygraph():
pool_out = _C_ops.max_pool2d_with_index(
x, 'pooling_type', 'max', 'ksize', output_size, 'adaptive', True)
return pool_out if return_mask else pool_out[0]
Expand Down Expand Up @@ -1799,11 +1776,6 @@ def adaptive_max_pool3d(x, output_size, return_mask=False, name=None):
output_size[2] = in_w

if in_dygraph_mode():
pool_out = _C_ops.final_state_max_pool3d_with_index(
x, output_size, [1, 1, 1], [0, 0, 0], False, True)
return pool_out if return_mask else pool_out[0]

if _in_legacy_dygraph():
pool_out = _C_ops.max_pool3d_with_index(
x, 'pooling_type', 'max', 'ksize', output_size, 'adaptive', True)
return pool_out if return_mask else pool_out[0]
Expand Down

0 comments on commit eb7df92

Please sign in to comment.