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
0faf7310
Commit
0faf7310
authored
Jun 03, 2019
by
Sergei Grechanik
Committed by
Tianqi Chen
Jun 03, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[ARITH] Bugfix: check arg positiveness for mod rules (#3279)
parent
fc2b2a07
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
2 deletions
+19
-2
src/arithmetic/rewrite_simplify.cc
+3
-1
tests/python/unittest/test_arith_rewrite_simplify.py
+16
-1
No files found.
src/arithmetic/rewrite_simplify.cc
View file @
0faf7310
...
...
@@ -634,10 +634,12 @@ Mutate_(const Mod* op, const Expr& self) {
TVM_TRY_REWRITE_IF
((
x
*
c1
+
y
)
%
c2
,
y
%
c2
,
c2
.
Eval
()
->
value
>
0
&&
c1
.
Eval
()
->
value
%
c2
.
Eval
()
->
value
==
0
&&
CanProveGreaterEqual
((
x
*
c1
).
Eval
(),
0
)
&&
CanProveGreaterEqual
(
y
.
Eval
(),
0
));
TVM_TRY_REWRITE_IF
((
x
+
c1
)
%
c2
,
x
%
c2
,
c2
.
Eval
()
->
value
>
0
&&
c1
.
Eval
()
->
value
>=
0
&&
c1
.
Eval
()
->
value
%
c2
.
Eval
()
->
value
==
0
&&
CanProveGreaterEqual
(
x
.
Eval
(),
0
));
...
...
@@ -645,7 +647,7 @@ Mutate_(const Mod* op, const Expr& self) {
c2
.
Eval
()
->
value
>
0
&&
c1
.
Eval
()
->
value
%
c2
.
Eval
()
->
value
==
0
&&
CanProveGreaterEqual
(
x
.
Eval
(),
0
)
&&
CanProveGreaterEqual
(
y
.
Eval
(),
0
));
CanProveGreaterEqual
(
(
y
*
c1
)
.
Eval
(),
0
));
// canonicalization: x % c == x % (-c) for truncated division
// NOTE: trunc div required
...
...
tests/python/unittest/test_arith_rewrite_simplify.py
View file @
0faf7310
...
...
@@ -302,9 +302,11 @@ def test_div_index_simplify():
def
test_mod_index_simplify
():
ck
=
RewriteChecker
()
x
,
y
,
z
=
tvm
.
var
(
"x"
),
tvm
.
var
(
"
y"
),
tvm
.
var
(
"z"
)
x
,
y
,
nx
,
ny
,
z
=
tvm
.
var
(
"x"
),
tvm
.
var
(
"y"
),
tvm
.
var
(
"nx"
),
tvm
.
var
(
"n
y"
),
tvm
.
var
(
"z"
)
ck
.
analyzer
.
update
(
x
,
tvm
.
arith
.
ConstIntBound
(
0
,
1000
),
override
=
True
)
ck
.
analyzer
.
update
(
y
,
tvm
.
arith
.
ConstIntBound
(
0
,
1000
),
override
=
True
)
ck
.
analyzer
.
update
(
nx
,
tvm
.
arith
.
ConstIntBound
(
-
1000
,
0
),
override
=
True
)
ck
.
analyzer
.
update
(
ny
,
tvm
.
arith
.
ConstIntBound
(
-
1000
,
0
),
override
=
True
)
ck
.
verify
(
x
*
10
%
2
,
0
)
ck
.
verify
((
x
*
10
+
y
)
%
2
,
y
%
2
)
...
...
@@ -317,6 +319,19 @@ def test_mod_index_simplify():
ck
.
verify
((
x
+
y
*
10
)
%
-
2
,
x
%
2
)
ck
.
verify
((
x
*
10
+
1
+
y
*
2
+
2
)
%
-
2
,
1
)
ck
.
verify
(
x
*
(
-
10
)
%
2
,
0
)
ck
.
verify
((
x
*
(
-
10
)
+
y
)
%
2
,
(
x
*
(
-
10
)
+
y
)
%
2
)
ck
.
verify
((
x
+
(
-
10
))
%
2
,
(
x
+
(
-
10
))
%
2
)
ck
.
verify
((
x
+
y
*
(
-
10
))
%
2
,
(
x
+
y
*
(
-
10
))
%
2
)
ck
.
verify
(
x
*
(
-
10
)
%
-
2
,
0
)
ck
.
verify
(
nx
*
10
%
2
,
0
)
ck
.
verify
((
nx
*
(
-
10
)
+
y
)
%
2
,
y
%
2
)
ck
.
verify
((
x
+
ny
*
(
-
10
))
%
2
,
x
%
2
)
ck
.
verify
((
nx
*
(
-
10
)
+
1
+
ny
*
(
-
2
)
+
2
)
%
2
,
1
)
ck
.
verify
(
nx
*
10
%
-
2
,
0
)
ck
.
verify
((
nx
*
(
-
10
)
+
y
)
%
-
2
,
y
%
2
)
ck
.
verify
((
x
+
ny
*
(
-
10
))
%
-
2
,
x
%
2
)
def
test_min_index_simplify
():
ck
=
RewriteChecker
()
...
...
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