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
1e578a6f
Commit
1e578a6f
authored
Nov 29, 2018
by
Sergei Grechanik
Committed by
Tianqi Chen
Nov 29, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[TVM] Fix segfault for CanonicalSimplify(x % -1) (#2194)
parent
3b91ae28
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
1 deletions
+19
-1
src/arithmetic/canonical.cc
+9
-1
tests/python/unittest/test_arith_simplify.py
+10
-0
No files found.
src/arithmetic/canonical.cc
View file @
1e578a6f
...
...
@@ -515,7 +515,15 @@ class Canonical::Internal : public IRMutator {
n
->
elem
.
push_back
(
e
);
}
Expr
ret
=
Sum2Expr
(
ComExpr
(
n
),
v
.
type
())
%
v
;
return
Binary
(
ret
.
as
<
Mod
>
(),
ret
);
if
(
const
Mod
*
mod
=
ret
.
as
<
Mod
>
())
{
return
Binary
(
mod
,
ret
);
}
else
{
// Sometimes the result is a constant, this may happen when value is -1
CHECK
(
is_const
(
ret
))
<<
"CanonicalSimplify: "
<<
Sum2Expr
(
ComExpr
(
n
),
v
.
type
())
<<
" % "
<<
v
<<
" is "
<<
ret
<<
" which is neither Mod, nor a constant"
;
return
ret
;
}
}
ret_entry_
.
sum
=
pair
[
1
];
ret_entry_
.
max_level
=
stack_
.
back
().
max_level
;
...
...
tests/python/unittest/test_arith_simplify.py
View file @
1e578a6f
...
...
@@ -20,6 +20,16 @@ def test_simplify():
zz
=
zz
.
a
assert
zz
.
a
==
x
and
zz
.
b
.
value
==
4
n
=
tvm
.
var
(
'n'
)
assert
tvm
.
ir_pass
.
Equal
(
tvm
.
ir_pass
.
CanonicalSimplify
(
n
%
(
-
1
)),
tvm
.
const
(
0
))
assert
tvm
.
ir_pass
.
Equal
(
tvm
.
ir_pass
.
CanonicalSimplify
(
n
%
1
),
tvm
.
const
(
0
))
assert
tvm
.
ir_pass
.
Equal
(
tvm
.
ir_pass
.
CanonicalSimplify
(
n
/
1
),
n
)
tvm
.
ir_pass
.
CanonicalSimplify
(
n
/
(
-
1
))
# This is not true in the current implementation
# assert tvm.ir_pass.Equal(tvm.ir_pass.CanonicalSimplify(n / (-1)),
# tvm.ir_pass.CanonicalSimplify(-n))
def
test_simplify_mod
():
"""Not yet working, mock design"""
ib
=
tvm
.
ir_builder
.
create
()
...
...
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