Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
tvm
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
cld
ml
tvm
Commits
f2f1526d
Commit
f2f1526d
authored
8 years ago
by
Haichen Shen
Committed by
Tianqi Chen
8 years ago
Browse files
Options
Downloads
Patches
Plain Diff
[PASS] Export simplify and equal to python (#14)
* [PASS] Export simplify and equal to python * fix naming convention
parent
7e025234
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
include/tvm/ir_pass.h
+17
-0
17 additions, 0 deletions
include/tvm/ir_pass.h
src/c_api/c_api_pass.cc
+21
-0
21 additions, 0 deletions
src/c_api/c_api_pass.cc
tests/python/test_pass_basic.py
+10
-0
10 additions, 0 deletions
tests/python/test_pass_basic.py
with
48 additions
and
0 deletions
include/tvm/ir_pass.h
+
17
−
0
View file @
f2f1526d
...
...
@@ -9,6 +9,8 @@
#ifndef TVM_IR_PASS_H_
#define TVM_IR_PASS_H_
#include
<ir/IREquality.h>
#include
<pass/Simplify.h>
#include
<tvm/ir_functor.h>
#include
<unordered_map>
#include
<vector>
...
...
@@ -19,6 +21,21 @@
namespace
tvm
{
namespace
ir
{
inline
bool
Equal
(
Expr
a
,
Expr
b
)
{
return
Halide
::
Internal
::
equal
(
a
,
b
);
}
inline
bool
Equal
(
Stmt
a
,
Stmt
b
)
{
return
Halide
::
Internal
::
equal
(
a
,
b
);
}
inline
Expr
Simplify
(
Expr
a
)
{
return
Halide
::
Internal
::
simplify
(
a
);
}
inline
Stmt
Simplify
(
Stmt
a
)
{
return
Halide
::
Internal
::
simplify
(
a
);
}
/*!
* \brief Schedule s' dependent operations.
...
...
This diff is collapsed.
Click to expand it.
src/c_api/c_api_pass.cc
+
21
−
0
View file @
f2f1526d
...
...
@@ -13,6 +13,27 @@ namespace ir {
using
ArgStack
=
const
std
::
vector
<
APIVariantValue
>
;
using
RetValue
=
APIVariantValue
;
TVM_REGISTER_API
(
_pass_Simplify
)
.
set_body
([](
const
ArgStack
&
args
,
RetValue
*
ret
)
{
CHECK
(
args
.
at
(
0
).
type_id
==
kNodeHandle
);
if
(
dynamic_cast
<
Expr
::
ContainerType
*>
(
args
.
at
(
0
).
sptr
.
get
()))
{
*
ret
=
Simplify
(
args
.
at
(
0
).
operator
Expr
());
}
else
{
*
ret
=
Simplify
(
args
.
at
(
0
).
operator
Stmt
());
}
});
TVM_REGISTER_API
(
_pass_Equal
)
.
set_body
([](
const
ArgStack
&
args
,
RetValue
*
ret
)
{
CHECK
(
args
.
at
(
0
).
type_id
==
kNodeHandle
);
CHECK
(
args
.
at
(
1
).
type_id
==
kNodeHandle
);
if
(
dynamic_cast
<
Expr
::
ContainerType
*>
(
args
.
at
(
0
).
sptr
.
get
()))
{
*
ret
=
Equal
(
args
.
at
(
0
).
operator
Expr
(),
args
.
at
(
1
).
operator
Expr
());
}
else
{
*
ret
=
Equal
(
args
.
at
(
0
).
operator
Stmt
(),
args
.
at
(
1
).
operator
Stmt
());
}
});
// make from two arguments
#define REGISTER_PASS1(PassName) \
TVM_REGISTER_API(_pass_## PassName) \
...
...
This diff is collapsed.
Click to expand it.
tests/python/test_pass_basic.py
+
10
−
0
View file @
f2f1526d
import
tvm
def
test_simplify
():
x
=
tvm
.
Var
(
'
x
'
)
e1
=
tvm
.
ir_pass
.
Simplify
(
x
+
2
+
1
)
assert
(
tvm
.
ir_pass
.
Equal
(
e1
,
x
+
3
))
e2
=
tvm
.
ir_pass
.
Simplify
(
x
*
3
+
5
*
x
)
assert
(
tvm
.
ir_pass
.
Equal
(
e2
,
x
*
8
))
e3
=
tvm
.
ir_pass
.
Simplify
(
x
-
x
/
3
*
3
)
assert
(
tvm
.
ir_pass
.
Equal
(
e3
,
tvm
.
make
.
Mod
(
x
,
3
)))
def
test_verify_ssa
():
x
=
tvm
.
Var
(
'
x
'
)
y
=
tvm
.
Var
()
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment