Skip to content

Commit 5bae5f3

Browse files
committed
remove unreachable assertion
1 parent eb75592 commit 5bae5f3

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

python/tvm/relay/frontend/pytorch.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5016,14 +5016,13 @@ def from_pytorch(
50165016
func_args.append(arg)
50175017

50185018
# Ensures the order of data_input is the same as the order of inputs specified in input_info.
5019-
_data_inputs = []
5020-
for input_info in input_infos:
5021-
_data_input = [di for di in data_inputs if di.name_hint == input_info[0]]
5022-
if len(_data_input) != 1:
5023-
msg = "Unexpected input name ({}) which is unreachable.".format(input_info[0])
5024-
raise RuntimeError(msg)
5025-
_data_inputs.append(_data_input[0])
5026-
data_inputs = _data_inputs
5019+
order_input_infos = {input_info[0]: idx for idx, input_info in enumerate(input_infos)}
5020+
data_inputs = sorted(
5021+
data_inputs,
5022+
key=lambda data_input: order_input_infos[data_input.name_hint]
5023+
if data_input.name_hint in order_input_infos
5024+
else -1,
5025+
)
50275026

50285027
func_args = data_inputs + func_args
50295028

0 commit comments

Comments
 (0)