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
e23913f5
Commit
e23913f5
authored
Mar 22, 2019
by
Josh Pollock
Committed by
Tianqi Chen
Mar 22, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Relay][Text Format] Reverse CallNode Print Order (#2882)
parent
8a7f41ce
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
2 deletions
+19
-2
src/relay/ir/pretty_printer.cc
+3
-1
tests/python/relay/test_ir_text_printer.py
+16
-1
No files found.
src/relay/ir/pretty_printer.cc
View file @
e23913f5
...
...
@@ -416,11 +416,13 @@ class PrettyPrinter :
Doc
VisitExpr_
(
const
CallNode
*
op
)
final
{
Doc
doc
;
doc
<<
Print
(
op
->
op
);
// visit args first so they are lifted before the op
// this places op closer to its call site
std
::
vector
<
Doc
>
args
;
for
(
Expr
arg
:
op
->
args
)
{
args
.
push_back
(
Print
(
arg
));
}
doc
<<
Print
(
op
->
op
);
return
doc
<<
"("
<<
PrintVec
(
args
)
<<
PrintAttrs
(
op
->
attrs
,
op
->
op
)
<<
")"
;
}
...
...
tests/python/relay/test_ir_text_printer.py
View file @
e23913f5
...
...
@@ -3,9 +3,10 @@ import tvm.relay.testing
import
numpy
as
np
from
tvm
import
relay
do_print
=
[
False
]
SEMVER
=
"v0.0.1
\n
"
def
show
(
text
):
if
do_print
[
0
]:
print
(
"---------------------------"
)
...
...
@@ -152,6 +153,19 @@ def test_densenet():
net
,
params
=
tvm
.
relay
.
testing
.
densenet
.
get_workload
(
batch_size
=
1
)
net
.
astext
()
def
test_call_node_order
():
x
=
relay
.
var
(
"x"
)
y
=
relay
.
var
(
"y"
)
assert
relay
.
Call
(
relay
.
Function
([
x
],
x
),
[
relay
.
Call
(
relay
.
Function
([
y
],
y
),
[
relay
.
const
(
1
)])])
.
astext
()
==
SEMVER
+
\
(
"
%0
= fn (
%
y) {
\n
"
"
%
y
\n
"
"}
\n
"
"
%1
=
%0
(1)
\n
"
"
%2
= fn (
%
x) {
\n
"
"
%
x
\n
"
"}
\n
"
"
%3
=
%2
(
%1
)
\n
"
"
%3
"
)
if
__name__
==
"__main__"
:
do_print
[
0
]
=
True
...
...
@@ -170,3 +184,4 @@ if __name__ == "__main__":
test_call_attrs
()
test_let_if_scope
()
test_variable_name
()
test_call_node_order
()
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