From ac6b3d4a02384d58c1a7be2309c2ea5fce6ff913 Mon Sep 17 00:00:00 2001 From: tqchen Date: Mon, 10 Dec 2018 12:53:40 -0800 Subject: [PATCH] [RELAY] Fix serialization of OpNode --- src/relay/ir/op.cc | 4 ++-- tests/python/relay/test_ir_nodes.py | 6 ++++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/relay/ir/op.cc b/src/relay/ir/op.cc index d0ae57bb01e19..75ff4cbc7d9b6 100644 --- a/src/relay/ir/op.cc +++ b/src/relay/ir/op.cc @@ -139,8 +139,8 @@ TVM_REGISTER_API("relay.op._Register") }); NodePtr CreateOp(const std::string& name) { - auto op = Op::Get(name); - CHECK(!op.defined()) << "Cannot find op \'" << name << '\''; + const Op& op = Op::Get(name); + CHECK(op.defined()) << "Cannot find op \'" << name << '\''; return op.node_; } diff --git a/tests/python/relay/test_ir_nodes.py b/tests/python/relay/test_ir_nodes.py index 2159dd02de955..8c402cbd35e96 100644 --- a/tests/python/relay/test_ir_nodes.py +++ b/tests/python/relay/test_ir_nodes.py @@ -18,6 +18,11 @@ def test_bad_constructor(): pass +def test_op(): + x = relay.op.op.get("add") + check_json_roundtrip(x) + + # Span def test_span(): span = relay.Span(None, 1, 1) @@ -210,6 +215,7 @@ def test_tuple_get_item(): if __name__ == "__main__": + test_op() test_bad_constructor() test_span() test_tensor_type()