Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
T
tic
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wenyuanbo
tic
Commits
023fc6b4
Unverified
Commit
023fc6b4
authored
Jul 24, 2019
by
Tianqi Chen
Committed by
GitHub
Jul 24, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Hotfix pylint (#3615)
parent
90eee087
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
3 deletions
+9
-3
topi/python/topi/testing/pool_grad_python.py
+9
-3
No files found.
topi/python/topi/testing/pool_grad_python.py
View file @
023fc6b4
...
@@ -14,11 +14,17 @@
...
@@ -14,11 +14,17 @@
# KIND, either express or implied. See the License for the
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# specific language governing permissions and limitations
# under the License.
# under the License.
# pylint: disable=invalid-name, unused-argument, unused-variable
"""Gradient of pooling in python"""
"""Gradient of pooling in python"""
import
numpy
as
np
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
):
count_include_pad
=
True
):
"""pool_grad for NCHW layout in python"""
"""pool_grad for NCHW layout in python"""
dtype
=
a_np
.
dtype
dtype
=
a_np
.
dtype
...
@@ -47,8 +53,8 @@ def pool_grad_nchw(a_np, out_grad_np, pool_size, strides, padding, pool_type, ce
...
@@ -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
# take the first element, as they are the same across batch and channel
pad_count
=
pad_count
.
ravel
()[
0
]
pad_count
=
pad_count
.
ravel
()[
0
]
pad_pool_grad_np
[:,
:,
i
*
sh
:
i
*
sh
+
kh
,
j
*
sw
:
j
*
sw
+
kw
]
+=
\
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
)
out_grad_np
[:,
:,
i
,
j
]
.
reshape
(
n
,
ic
,
1
,
1
)
/
np
.
maximum
(
pad_count
,
1
)
elif
pool_type
==
'max'
:
elif
pool_type
==
'max'
:
for
i
in
range
(
oh
):
for
i
in
range
(
oh
):
for
j
in
range
(
ow
):
for
j
in
range
(
ow
):
a_patch
=
pad_np
[:,
:,
i
*
sh
:
i
*
sh
+
kh
,
j
*
sw
:
j
*
sw
+
kw
]
a_patch
=
pad_np
[:,
:,
i
*
sh
:
i
*
sh
+
kh
,
j
*
sw
:
j
*
sw
+
kw
]
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment