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
c9aa55cd
Commit
c9aa55cd
authored
Oct 24, 2019
by
Yao Wang
Committed by
Tianqi Chen
Oct 24, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Split adaptive_pool2d_avg into sum and div (#4186)
parent
2460f908
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
3 deletions
+20
-3
topi/include/topi/nn/pooling.h
+15
-3
topi/python/topi/x86/pooling.py
+5
-0
No files found.
topi/include/topi/nn/pooling.h
View file @
c9aa55cd
...
@@ -492,7 +492,7 @@ inline Tensor adaptive_pool_impl(const Tensor& x,
...
@@ -492,7 +492,7 @@ inline Tensor adaptive_pool_impl(const Tensor& x,
return
tvm
::
max
(
x
(
indices
),
{
dheight
,
dwidth
});
// NOLINT(*)
return
tvm
::
max
(
x
(
indices
),
{
dheight
,
dwidth
});
// NOLINT(*)
},
"tensor"
,
"adaptive_pool_max"
);
},
"tensor"
,
"adaptive_pool_max"
);
}
else
if
(
pool_type
==
kAvgPool
)
{
}
else
if
(
pool_type
==
kAvgPool
)
{
return
tvm
::
compute
(
out_shape
,
[
&
](
const
Array
<
Var
>&
output
)
{
auto
pool_sum
=
tvm
::
compute
(
out_shape
,
[
&
](
const
Array
<
Var
>&
output
)
{
Array
<
Expr
>
indices
;
Array
<
Expr
>
indices
;
for
(
const
Var
&
var
:
output
)
indices
.
push_back
(
var
);
for
(
const
Var
&
var
:
output
)
indices
.
push_back
(
var
);
auto
i_start_h
=
start_index
(
output
[
height_axis
],
out_height
,
height
);
auto
i_start_h
=
start_index
(
output
[
height_axis
],
out_height
,
height
);
...
@@ -505,8 +505,20 @@ inline Tensor adaptive_pool_impl(const Tensor& x,
...
@@ -505,8 +505,20 @@ inline Tensor adaptive_pool_impl(const Tensor& x,
auto
dwidth
=
tvm
::
reduce_axis
(
Range
(
0
,
i_end_w
-
i_start_w
),
"rv2"
);
auto
dwidth
=
tvm
::
reduce_axis
(
Range
(
0
,
i_end_w
-
i_start_w
),
"rv2"
);
indices
.
Set
(
height_axis
,
i_start_h
+
dheight
);
indices
.
Set
(
height_axis
,
i_start_h
+
dheight
);
indices
.
Set
(
width_axis
,
i_start_w
+
dwidth
);
indices
.
Set
(
width_axis
,
i_start_w
+
dwidth
);
return
tvm
::
sum
(
div
(
x
(
indices
),
divide_factor
),
{
dheight
,
dwidth
});
return
tvm
::
sum
(
x
(
indices
),
{
dheight
,
dwidth
});
},
"tensor"
,
"adaptive_pool_avg"
);
},
"tensor"
,
"adaptive_pool_sum"
);
return
tvm
::
compute
(
out_shape
,
[
&
](
const
Array
<
Var
>&
output
)
{
Array
<
Expr
>
indices
;
for
(
const
Var
&
var
:
output
)
indices
.
push_back
(
var
);
auto
i_start_h
=
start_index
(
output
[
height_axis
],
out_height
,
height
);
auto
i_end_h
=
end_index
(
output
[
height_axis
],
out_height
,
height
);
auto
i_start_w
=
start_index
(
output
[
width_axis
],
out_width
,
width
);
auto
i_end_w
=
end_index
(
output
[
width_axis
],
out_width
,
width
);
auto
divide_factor
=
tvm
::
cast
(
x
->
dtype
,
(
i_end_h
-
i_start_h
)
*
(
i_end_w
-
i_start_w
));
return
div
(
pool_sum
(
indices
),
divide_factor
);
},
"tensor"
,
kElementWise
);
}
else
{
}
else
{
LOG
(
ERROR
)
<<
"Unrecognized pool_type: "
<<
pool_type
;
LOG
(
ERROR
)
<<
"Unrecognized pool_type: "
<<
pool_type
;
return
x
;
return
x
;
...
...
topi/python/topi/x86/pooling.py
View file @
c9aa55cd
...
@@ -147,6 +147,11 @@ def schedule_adaptive_pool(outs):
...
@@ -147,6 +147,11 @@ def schedule_adaptive_pool(outs):
traverse
(
tensor
.
op
)
traverse
(
tensor
.
op
)
# schedule pool
# schedule pool
elif
OP
.
tag
.
startswith
(
'adaptive_pool'
):
elif
OP
.
tag
.
startswith
(
'adaptive_pool'
):
if
OP
!=
outs
[
0
]
.
op
:
output
=
outs
[
0
]
output_fused
=
s
[
output
]
.
fuse
(
output
.
op
.
axis
[
0
],
output
.
op
.
axis
[
1
])
s
[
output
]
.
parallel
(
output_fused
)
Pool
=
OP
.
output
(
0
)
Pool
=
OP
.
output
(
0
)
_parallel_sch
(
s
[
Pool
],
outs
[
0
]
.
shape
)
_parallel_sch
(
s
[
Pool
],
outs
[
0
]
.
shape
)
else
:
else
:
...
...
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