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
2a8e0746
Commit
2a8e0746
authored
Dec 27, 2017
by
Xingjian Shi
Committed by
Tianqi Chen
Dec 27, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[TOPI]Support dim-0 tensor in topi broadcast/reduce (#731)
* support dim-0 tensor in topi ops revert transform * revert
parent
85e4058c
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
7 additions
and
4 deletions
+7
-4
topi/python/topi/reduction.py
+1
-3
topi/tests/python/test_topi_broadcast.py
+2
-0
topi/tests/python/test_topi_reduce.py
+4
-1
No files found.
topi/python/topi/reduction.py
View file @
2a8e0746
...
@@ -107,10 +107,8 @@ def comm_reduce(data, axis=None, keepdims=False, func=tvm.sum, is_idx_reduce=Fal
...
@@ -107,10 +107,8 @@ def comm_reduce(data, axis=None, keepdims=False, func=tvm.sum, is_idx_reduce=Fal
ret : tvm.Tensor
ret : tvm.Tensor
"""
"""
ndim
=
len
(
data
.
shape
)
ndim
=
len
(
data
.
shape
)
assert
ndim
!=
0
,
"Reduce a dim-0 input is not supported!"
real_axis
=
_get_real_axis
(
ndim
,
axis
)
real_axis
=
_get_real_axis
(
ndim
,
axis
)
if
real_axis
==
list
(
range
(
ndim
))
and
keepdims
is
False
:
raise
ValueError
(
"Currently we do not support all reduce + keepdims = False!"
" axis={}, keepdims={}"
.
format
(
axis
,
keepdims
))
reduce_axes
=
[
tvm
.
reduce_axis
((
0
,
data
.
shape
[
i
]),
"k
%
d"
%
i
)
for
i
in
real_axis
]
reduce_axes
=
[
tvm
.
reduce_axis
((
0
,
data
.
shape
[
i
]),
"k
%
d"
%
i
)
for
i
in
real_axis
]
if
keepdims
:
if
keepdims
:
target_shape
=
[
1
if
i
in
real_axis
else
data
.
shape
[
i
]
for
i
in
range
(
ndim
)]
target_shape
=
[
1
if
i
in
real_axis
else
data
.
shape
[
i
]
for
i
in
range
(
ndim
)]
...
...
topi/tests/python/test_topi_broadcast.py
View file @
2a8e0746
...
@@ -89,12 +89,14 @@ def verify_broadcast_binary_ele(lhs_shape, rhs_shape, typ="add"):
...
@@ -89,12 +89,14 @@ def verify_broadcast_binary_ele(lhs_shape, rhs_shape, typ="add"):
def
test_broadcast_to
():
def
test_broadcast_to
():
verify_broadcast_to_ele
((
1
,),
(
10
,))
verify_broadcast_to_ele
((
1
,),
(
10
,))
verify_broadcast_to_ele
((),
(
10
,))
verify_broadcast_to_ele
((
1
,
1
,
5
,
4
),
(
3
,
4
,
4
,
4
,
5
,
4
))
verify_broadcast_to_ele
((
1
,
1
,
5
,
4
),
(
3
,
4
,
4
,
4
,
5
,
4
))
verify_broadcast_to_ele
((
1
,
128
,
1
,
32
),
(
64
,
128
,
64
,
32
))
verify_broadcast_to_ele
((
1
,
128
,
1
,
32
),
(
64
,
128
,
64
,
32
))
def
test_broadcast_binary
():
def
test_broadcast_binary
():
verify_broadcast_binary_ele
((
5
,
2
,
3
),
(
2
,
1
),
typ
=
"add"
)
verify_broadcast_binary_ele
((
5
,
2
,
3
),
(
2
,
1
),
typ
=
"add"
)
verify_broadcast_binary_ele
((
5
,
2
,
3
),
(),
typ
=
"add"
)
verify_broadcast_binary_ele
((
5
,
64
,
128
),
(
2
,
5
,
64
,
1
),
typ
=
"mul"
)
verify_broadcast_binary_ele
((
5
,
64
,
128
),
(
2
,
5
,
64
,
1
),
typ
=
"mul"
)
verify_broadcast_binary_ele
((
2
,
3
,
1
,
32
),
(
64
,
32
),
typ
=
"div"
)
verify_broadcast_binary_ele
((
2
,
3
,
1
,
32
),
(
64
,
32
),
typ
=
"div"
)
verify_broadcast_binary_ele
((
1
,
32
),
(
64
,
32
),
typ
=
"sub"
)
verify_broadcast_binary_ele
((
1
,
32
),
(
64
,
32
),
typ
=
"sub"
)
...
...
topi/tests/python/test_topi_reduce.py
View file @
2a8e0746
...
@@ -108,7 +108,10 @@ def test_reduce_map():
...
@@ -108,7 +108,10 @@ def test_reduce_map():
axis
=
None
,
axis
=
None
,
keepdims
=
True
,
keepdims
=
True
,
type
=
"argmax"
)
type
=
"argmax"
)
verify_reduce_map_ele
(
in_shape
=
(
31
,
21
,
15
),
axis
=
None
,
keepdims
=
False
,
type
=
"sum"
)
if
__name__
==
"__main__"
:
if
__name__
==
"__main__"
:
test_reduce_map
()
test_reduce_map
()
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