}
Doc RelayTextPrinter::PrintFinal(const ObjectRef& node) {
- if (node->IsInstance<BaseFuncNode>() && !node->IsInstance<relay::FunctionNode>()) {
+ if (node.defined() && node->IsInstance<BaseFuncNode>() &&
+ !node->IsInstance<relay::FunctionNode>()) {
// Temporarily skip non-relay functions.
// TODO(tvm-team) enhance the code to work for all functions
} else if (node.as<ExprNode>()) {
}
Doc RelayTextPrinter::Print(const ObjectRef& node, bool meta, bool try_inline) {
- bool is_non_relay_func =
- node->IsInstance<BaseFuncNode>() && !node->IsInstance<relay::FunctionNode>();
+ bool is_non_relay_func = node.defined() && node->IsInstance<BaseFuncNode>() &&
+ !node->IsInstance<relay::FunctionNode>();
if (node.as<ExprNode>() && !is_non_relay_func) {
return PrintExpr(Downcast<Expr>(node), meta, try_inline);
} else if (node.as<TypeNode>()) {
assert main_def_str.strip() in mod_str
+def test_null_attribute():
+ x = relay.var("x")
+ y = relay.var("y")
+ z = relay.Function([x], y)
+ z = z.with_attr("TestAttribute", None)
+ txt = astext(z)
+ assert "TestAttribute=(nullptr)" in txt
+
+
if __name__ == "__main__":
do_print[0] = True
test_lstm()
test_variable_name()
test_call_node_order()
test_unapplied_constructor()
+ test_null_attribute()