diff --git a/python/tvm/relay/backend/vmobj.py b/python/tvm/relay/backend/vmobj.py index d6b11604fb8b..4c92e9bf38a6 100644 --- a/python/tvm/relay/backend/vmobj.py +++ b/python/tvm/relay/backend/vmobj.py @@ -85,7 +85,7 @@ def __getitem__(self, idx): return self.fields[idx] def __len__(self): - return self.num_fields + return len(self.fields) def __iter__(self): return iter(self.fields) diff --git a/tests/python/relay/test_vm.py b/tests/python/relay/test_vm.py index 706c8587596a..fbb6ce55d0b9 100644 --- a/tests/python/relay/test_vm.py +++ b/tests/python/relay/test_vm.py @@ -213,6 +213,9 @@ def test_list_constructor(): mod["main"] = f result = veval(mod) + assert len(result) == 2 + assert len(result[1]) == 2 + obj = vmobj_to_list(result) tvm.testing.assert_allclose(obj, np.array([3,2,1]))