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
0f2e4328
Commit
0f2e4328
authored
Feb 03, 2019
by
Zhi
Committed by
Tianqi Chen
Feb 03, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
print ast w/o metadata (#2533)
parent
e0af5c20
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
1 deletions
+12
-1
python/tvm/relay/base.py
+4
-1
tests/python/relay/test_ir_text_printer.py
+8
-0
No files found.
python/tvm/relay/base.py
View file @
0f2e4328
...
...
@@ -54,7 +54,7 @@ class RelayNode(NodeBase):
Note
----
The metadata section is necessary to fully parse the text format.
However, it can contain dumps that are big (e.g constant weights)
a
,
However, it can contain dumps that are big (e.g constant weights),
so it can be helpful to skip printing the meta data section.
Returns
...
...
@@ -67,6 +67,9 @@ class RelayNode(NodeBase):
def
set_span
(
self
,
span
):
_base
.
set_span
(
self
,
span
)
def
__str__
(
self
):
return
self
.
astext
(
show_meta_data
=
False
)
@register_relay_node
class
Span
(
RelayNode
):
...
...
tests/python/relay/test_ir_text_printer.py
View file @
0f2e4328
...
...
@@ -32,7 +32,9 @@ def test_env():
env
[
"myf"
]
=
f
text
=
env
.
astext
()
assert
"def @myf"
in
text
assert
"def @myf"
in
str
(
env
)
assert
"
%1
= add(
%0
,
%0
) # ty=float32"
in
text
assert
"
%1
= add(
%0
,
%0
) # ty=float32"
in
str
(
env
)
show
(
env
.
astext
(
annotate
=
lambda
x
:
str
(
x
.
checked_type
.
dtype
)))
show
(
text
)
...
...
@@ -47,9 +49,15 @@ def test_meta_data():
channels
=
2
)
f
=
relay
.
Function
([
x
,
w
],
z
)
text
=
f
.
astext
()
text_no_meta
=
str
(
f
)
assert
"channels=2"
in
text
assert
"channels=2"
in
text_no_meta
assert
"meta[Variable][0]"
in
text
assert
"meta[Variable][0]"
in
text_no_meta
assert
"type_key"
in
text
assert
"type_key"
not
in
text_no_meta
show
(
text
)
show
(
f
)
text
=
relay
.
const
([
1
,
2
,
3
])
.
astext
()
assert
"meta[relay.Constant][0]"
in
text
...
...
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