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
859bda8a
Commit
859bda8a
authored
Jan 24, 2019
by
Salem Derisavi
Committed by
Tianqi Chen
Jan 24, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1) fixed constant folding for mod operation in CanonicalSimplify 2) added a unit test (#2487)
parent
12aca82e
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
1 deletions
+11
-1
src/arithmetic/canonical.cc
+1
-1
tests/cpp/ir_simplify_test.cc
+10
-0
No files found.
src/arithmetic/canonical.cc
View file @
859bda8a
...
...
@@ -363,7 +363,7 @@ class Canonical::Internal : public IRMutator {
return
Binary_
(
op
,
e
,
a
.
value
,
b
.
value
);
}
if
(
is_const
(
a
.
value
)
&&
is_const
(
b
.
value
))
{
return
ComputeExpr
<
M
ul
>
(
a
.
value
,
b
.
value
);
return
ComputeExpr
<
M
od
>
(
a
.
value
,
b
.
value
);
}
else
if
(
is_const
(
b
.
value
))
{
return
SumModConst
(
a
.
AsSum
(),
b
.
value
);
}
else
{
...
...
tests/cpp/ir_simplify_test.cc
View file @
859bda8a
...
...
@@ -27,6 +27,16 @@ TEST(IRSIMPLIFY, Mul) {
CHECK
(
is_zero
(
es
));
}
TEST
(
IRSIMPLIFY
,
Mod
)
{
auto
x
=
tvm
::
Integer
(
10
);
auto
y
=
tvm
::
Integer
(
12
);
// Mod::make is used instead of % to avoid constant folding during
// calling operator%(x,y). Mod::make doesn't try constant folding,
// and therefore, the constant folding will be attempted in CanonicalSimplify
auto
mod
=
tvm
::
ir
::
CanonicalSimplify
(
tvm
::
ir
::
Mod
::
make
(
x
,
y
));
auto
es
=
tvm
::
ir
::
CanonicalSimplify
(
mod
-
x
);
CHECK
(
is_zero
(
es
));
}
int
main
(
int
argc
,
char
**
argv
)
{
testing
::
InitGoogleTest
(
&
argc
,
argv
);
testing
::
FLAGS_gtest_death_test_style
=
"threadsafe"
;
...
...
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