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
f7beea4b
Unverified
Commit
f7beea4b
authored
Jan 15, 2019
by
Tianqi Chen
Committed by
GitHub
Jan 15, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[OP] Fix reduce op problem when axis=None (#2436)
parent
ac3b5bb3
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
6 additions
and
5 deletions
+6
-5
src/relay/op/tensor/reduce.cc
+4
-3
tests/python/relay/test_op_level4.py
+2
-2
No files found.
src/relay/op/tensor/reduce.cc
View file @
f7beea4b
...
...
@@ -101,6 +101,7 @@ inline std::vector<int64_t> GetReduceAxes(const uint32_t indim,
// Get axis under exclude condition.
Array
<
Integer
>
GetExcludeAxes
(
size_t
indim
,
const
Array
<
Integer
>&
inaxis
)
{
CHECK
(
inaxis
.
defined
())
<<
"Cannot set exclude when axis=None"
;
std
::
vector
<
bool
>
axis_flag
(
indim
,
true
);
for
(
auto
i
:
inaxis
)
{
int64_t
axis
=
i
->
value
;
...
...
@@ -137,9 +138,9 @@ Array<Tensor> ReduceCompute(const Attrs& attrs,
auto
axes
=
param
->
axis
;
if
(
param
->
exclude
)
{
axes
=
GetExcludeAxes
(
inputs
[
0
]
->
shape
.
size
(),
param
->
axis
);
}
if
(
axes
.
size
()
==
0
)
{
return
{
topi
::
identity
(
inputs
[
0
])
};
if
(
axes
.
size
()
==
0
)
{
return
{
topi
::
identity
(
inputs
[
0
])
};
}
}
return
{
f
(
inputs
[
0
],
axes
,
param
->
keepdims
,
false
)
};
}
...
...
tests/python/relay/test_op_level4.py
View file @
f7beea4b
...
...
@@ -135,7 +135,7 @@ def verify_reduce(funcs, data, axis, keepdims, exclude, output, dtype="float32")
out_type
=
"int32"
if
test_func
in
[
relay
.
argmin
,
relay
.
argmax
]
else
dtype
assert
zz
.
checked_type
==
relay
.
ty
.
TensorType
(
output
,
out_type
)
if
all
(
isinstance
(
v
,
tvm
.
expr
.
Var
)
==
1
for
v
in
data
)
or
len
(
output
)
==
0
:
if
all
(
isinstance
(
v
,
tvm
.
expr
.
Var
)
==
1
for
v
in
data
):
return
func
=
relay
.
Function
([
x
],
z
)
...
...
@@ -187,7 +187,7 @@ def test_reduce_functions():
verify_reduce
(
func
,
(
2
,
3
,
4
),
1
,
True
,
False
,
(
2
,
1
,
4
))
verify_reduce
(
func
,
(
2
,
3
,
4
),
(
1
,),
True
,
False
,
(
2
,
1
,
4
))
verify_reduce
(
func
,
(
2
,
3
,
4
),
(
0
,
1
,
2
),
False
,
False
,
())
verify_reduce
(
func
,
(
4
,
4
,
3
),
None
,
False
,
Tru
e
,
())
verify_reduce
(
func
,
(
4
,
4
,
3
),
None
,
False
,
Fals
e
,
())
verify_reduce
(
func
,
(
4
,
4
,
3
),
(
0
,
2
),
False
,
False
,
(
4
,))
verify_reduce
(
func
,
(
128
,
24
,
128
),
(
0
,
1
),
False
,
False
,
(
128
,))
verify_reduce
(
func
,
(
128
,
24
,
128
),
(
0
,
2
),
False
,
False
,
(
24
,))
...
...
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