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

[relay] preserve the order of input_info of pytorch #14462

Merged
merged 4 commits into from
Apr 6, 2023
Merged
Changes from 1 commit
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
11 changes: 11 additions & 0 deletions python/tvm/relay/frontend/pytorch.py
Original file line number Diff line number Diff line change
Expand Up @@ -5014,6 +5014,17 @@ def from_pytorch(
data_inputs.append(arg)
else:
func_args.append(arg)

# Ensures that the order of data_input is the same as the order of inputs specified in input_info.
_data_inputs = []
for input_info in input_infos:
_data_input = [di for di in data_inputs if di.name_hint == input_info[0]]
if len(_data_input) != 1:
msg = "Unexpected input name ({}) which is unreachable.".format(input_info[0])
raise RuntimeError(msg)
_data_inputs.append(_data_input[0])
data_inputs = _data_inputs

func_args = data_inputs + func_args

mod["main"] = tvm.relay.Function(func_args, ret)
Expand Down