Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Frontend][Relay][Parser] fix unparsable yolo formals #6963

Merged
merged 3 commits into from
Nov 26, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion python/tvm/relay/frontend/darknet.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def _darknet_not_support(attr, op="relay"):

def _get_params_prefix(opname, layer_num):
"""Makes the params prefix name from opname and layer number."""
return str(opname) + str(layer_num)
return str(opname).replace(".", "_") + str(layer_num)


def _get_params_name(prefix, item):
Expand Down
15 changes: 15 additions & 0 deletions tests/python/frontend/darknet/test_forward.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,17 @@
)


def astext(program, unify_free_vars=False):
"""check that program is parsable in text format"""
text = program.astext()
if isinstance(program, relay.Expr):
roundtrip_program = tvm.parser.parse_expr(text)
else:
roundtrip_program = tvm.parser.fromtext(text)

tvm.ir.assert_structural_equal(roundtrip_program, program, map_free_vars=True)


def _read_memory_buffer(shape, data, dtype="float32"):
length = 1
for x in shape:
Expand All @@ -59,6 +70,10 @@ def _get_tvm_output(net, data, build_dtype="float32", states=None):
"""Compute TVM output"""
dtype = "float32"
mod, params = relay.frontend.from_darknet(net, data.shape, dtype)
# verify that from_darknet creates a valid, parsable relay program
mod = relay.transform.InferType()(mod)
astext(mod)
hypercubestart marked this conversation as resolved.
Show resolved Hide resolved

target = "llvm"
shape_dict = {"data": data.shape}
lib = relay.build(mod, target, params=params)
Expand Down
5 changes: 2 additions & 3 deletions tests/python/relay/test_ir_text_printer.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import numpy as np
from tvm.relay import Expr
from tvm.relay.analysis import free_vars
import pytest

DEBUG_PRINT = False

Expand Down Expand Up @@ -269,6 +270,4 @@ def test_span():


if __name__ == "__main__":
import sys

pytext.argv(sys.argv)
pytest.main([__file__])