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
1598e329
Commit
1598e329
authored
Jun 20, 2019
by
Wei Chen
Committed by
Haichen Shen
Jun 20, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add EtaExpand to transform API (#3406)
* Add EtaExpand to transform API * Add test case
parent
f7d15f64
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
34 additions
and
3 deletions
+34
-3
python/tvm/relay/transform.py
+9
-0
src/relay/pass/eta_expand.cc
+15
-0
tests/python/relay/test_pass_eta_expand.py
+10
-3
No files found.
python/tvm/relay/transform.py
View file @
1598e329
...
...
@@ -406,6 +406,15 @@ def ToANormalForm():
"""
return
_transform
.
ToANormalForm
()
def
EtaExpand
():
"""Add abstraction over a function
Returns
-------
ret: tvm.relay.Pass
The registered pass that eta expands an expression.
"""
return
_transform
.
EtaExpand
()
def
ToGraphNormalForm
():
"""Turn A Normal Form expression into Graph Normal Form expression
...
...
src/relay/pass/eta_expand.cc
View file @
1598e329
...
...
@@ -67,5 +67,20 @@ Expr EtaExpand(const Expr& e, const Module& mod) {
TVM_REGISTER_API
(
"relay._ir_pass.eta_expand"
).
set_body_typed
(
EtaExpand
);
namespace
transform
{
Pass
EtaExpand
()
{
runtime
::
TypedPackedFunc
<
Function
(
Function
,
Module
,
PassContext
)
>
pass_func
=
[
=
](
Function
f
,
Module
m
,
PassContext
pc
)
{
return
Downcast
<
Function
>
(
EtaExpand
(
f
,
m
));
};
return
CreateFunctionPass
(
pass_func
,
1
,
"EtaExpand"
,
{});
}
TVM_REGISTER_API
(
"relay._transform.EtaExpand"
)
.
set_body_typed
(
EtaExpand
);
}
// namespace transform
}
// namespace relay
}
// namespace tvm
tests/python/relay/test_pass_eta_expand.py
View file @
1598e329
...
...
@@ -15,13 +15,20 @@
# specific language governing permissions and limitations
# under the License.
from
tvm
import
relay
import
tvm.relay.module
as
_module
import
tvm.relay.transform
as
_transform
def
test_eta_expand_basic
():
mod
=
relay
.
Module
()
x
=
relay
.
var
(
'x'
,
'int32'
)
y
=
relay
.
var
(
'y'
,
'int32'
)
orig
=
relay
.
Function
([
x
],
x
)
got
=
relay
.
ir_pass
.
eta_expand
(
orig
,
mod
)
mod
=
_module
.
Module
.
from_expr
(
orig
)
seq
=
_transform
.
Sequential
([
_transform
.
EtaExpand
()])
with
_transform
.
PassContext
(
opt_level
=
3
):
mod
=
seq
(
mod
)
got
=
mod
[
mod
.
entry_func
.
name_hint
]
y
=
relay
.
var
(
'y'
,
'int32'
)
expected
=
relay
.
Function
([
y
],
orig
(
y
))
got
=
relay
.
ir_pass
.
infer_type
(
got
,
mod
)
...
...
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