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
6c81d784
Unverified
Commit
6c81d784
authored
Jun 30, 2019
by
Tianqi Chen
Committed by
GitHub
Jun 30, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[ARITH] Canonicalize comparison to move constant to one side (#3467)
parent
79e071c9
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
0 deletions
+12
-0
src/arithmetic/rewrite_simplify.cc
+6
-0
tests/python/unittest/test_arith_canonical_simplify.py
+6
-0
No files found.
src/arithmetic/rewrite_simplify.cc
View file @
6c81d784
...
...
@@ -1187,6 +1187,12 @@ Mutate_(const LT* op, const Expr& self) {
TVM_TRY_RECURSIVE_REWRITE
(
z
<
min
(
x
,
y
),
z
<
x
&&
z
<
y
);
TVM_TRY_RECURSIVE_REWRITE
(
z
<
max
(
x
,
y
),
z
<
x
||
z
<
y
);
TVM_TRY_RECURSIVE_REWRITE
(
x
<
c1
-
y
,
x
+
y
<
c1
);
TVM_TRY_RECURSIVE_REWRITE
(
x
<
c1
+
y
,
x
-
y
<
c1
);
TVM_TRY_RECURSIVE_REWRITE
(
c1
-
y
<
x
,
c1
<
x
+
y
);
TVM_TRY_RECURSIVE_REWRITE
(
c1
+
y
<
x
,
c1
<
x
-
y
);
TVM_TRY_REWRITE
(
x
-
c1
<
0
,
x
<
c1
);
TVM_TRY_REWRITE
(
x
+
c1
<
c2
,
x
<
c2
-
c1
);
}
...
...
tests/python/unittest/test_arith_canonical_simplify.py
View file @
6c81d784
...
...
@@ -166,12 +166,18 @@ def test_simplify_if_then_else():
tvm
.
if_then_else
(
24512
<=
((((
x
*
4
)
+
y
)
-
466036
)
%
24528
),
(((((
x
*
4
)
+
y
)
-
466036
)
%
24528
)
-
24512
)
%
16
,
x
),
y
)
res2
=
tvm
.
if_then_else
((
x
*
4
)
>=
466036
-
y
,
tvm
.
if_then_else
(
24512
<=
((((
x
*
4
)
+
y
)
-
466036
)
%
24528
),
(((((
x
*
4
)
+
y
)
-
466036
)
%
24528
)
-
24512
)
%
16
,
x
),
y
)
expected
=
tvm
.
if_then_else
(
tvm
.
expr
.
LE
(
466036
,
(
x
*
4
+
y
)),
tvm
.
if_then_else
(
tvm
.
expr
.
LE
(
24512
,
((((
x
*
4
)
+
y
)
-
4
)
%
24528
)),
(((
x
*
4
)
+
y
)
-
4
)
%
16
,
x
),
y
)
ck
.
verify
(
res
,
expected
)
ck
.
verify
(
res2
,
expected
)
# can only simplify if condition
res
=
tvm
.
expr
.
Select
(
tvm
.
all
(
x
>=
-
1
,
y
>=
0
),
(
x
+
y
+
100
)
%
3
,
(
x
+
100
)
%
3
)
expected
=
tvm
.
expr
.
Select
(
tvm
.
all
(
x
>=
-
1
,
y
>=
0
),
(
x
+
y
+
1
)
%
3
,
(
x
+
100
)
%
3
)
...
...
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