Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hotfix pylint #3615

Merged
merged 1 commit into from
Jul 24, 2019
Merged
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
12 changes: 9 additions & 3 deletions topi/python/topi/testing/pool_grad_python.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,17 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
# pylint: disable=invalid-name, unused-argument, unused-variable
"""Gradient of pooling in python"""
import numpy as np


def pool_grad_nchw(a_np, out_grad_np, pool_size, strides, padding, pool_type, ceil_mode,
def pool_grad_nchw(a_np, out_grad_np,
pool_size,
strides,
padding,
pool_type,
ceil_mode,
count_include_pad=True):
"""pool_grad for NCHW layout in python"""
dtype = a_np.dtype
Expand Down Expand Up @@ -47,8 +53,8 @@ def pool_grad_nchw(a_np, out_grad_np, pool_size, strides, padding, pool_type, ce
# take the first element, as they are the same across batch and channel
pad_count = pad_count.ravel()[0]
pad_pool_grad_np[:, :, i*sh:i*sh+kh, j*sw:j*sw+kw] += \
out_grad_np[:, :, i, j].reshape(n,ic,1,1) / np.maximum(pad_count, 1)
elif pool_type =='max':
out_grad_np[:, :, i, j].reshape(n, ic, 1, 1) / np.maximum(pad_count, 1)
elif pool_type == 'max':
for i in range(oh):
for j in range(ow):
a_patch = pad_np[:, :, i*sh:i*sh+kh, j*sw:j*sw+kw]
Expand Down