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
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):
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)
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