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
5d9647e2
Commit
5d9647e2
authored
Sep 28, 2017
by
Xingjian Shi
Committed by
Tianqi Chen
Sep 28, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix squeeze to output (1,) if all axes are squeezed. E.g squeeze((1,1,1...), None) case (#498)
parent
e44b38e3
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
8 additions
and
1 deletions
+8
-1
topi/python/topi/transform.py
+2
-0
topi/tests/python/test_topi_transform.py
+6
-1
No files found.
topi/python/topi/transform.py
View file @
5d9647e2
...
...
@@ -114,6 +114,8 @@ def squeeze(a, axis=None):
for
i
,
a_dim
in
enumerate
(
a_shape
):
if
i
not
in
search_axis
:
out_shape
.
append
(
a_dim
)
if
not
out_shape
:
out_shape
.
append
(
1
)
def
_compute
(
*
indices
):
real_indices
=
[]
flag
=
0
...
...
topi/tests/python/test_topi_transform.py
View file @
5d9647e2
...
...
@@ -82,7 +82,11 @@ def verify_squeeze(src_shape, axis):
data_npy
=
np
.
random
.
normal
(
size
=
src_shape
)
.
astype
(
A
.
dtype
)
out_npy
=
np
.
squeeze
(
data_npy
,
axis
=
axis
)
data_nd
=
tvm
.
nd
.
array
(
data_npy
,
ctx
)
out_nd
=
tvm
.
nd
.
empty
(
out_npy
.
shape
,
ctx
=
ctx
,
dtype
=
B
.
dtype
)
if
out_npy
.
shape
==
():
out_nd_shape
=
(
1
,)
else
:
out_nd_shape
=
out_npy
.
shape
out_nd
=
tvm
.
nd
.
empty
(
out_nd_shape
,
ctx
=
ctx
,
dtype
=
B
.
dtype
)
foo
(
data_nd
,
out_nd
)
np
.
testing
.
assert_allclose
(
out_nd
.
asnumpy
(),
out_npy
)
...
...
@@ -159,6 +163,7 @@ def test_squeeze():
verify_squeeze
((
1
,
2
,
3
,
4
),
0
)
verify_squeeze
((
1
,
2
,
1
,
4
),
None
)
verify_squeeze
((
1
,
1
,
1
,
4
),
(
1
,
2
))
verify_squeeze
((
1
,
1
,
1
,
1
),
None
)
def
test_concatenate
():
...
...
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