Skip to content

Commit

Permalink
[UNITY] Fix the symbolic var handling (#15973)
Browse files Browse the repository at this point in the history
This PR fix a bug that only appears on windows on symbolic var handling.
For the function parameter var with Tuple struct info, directly
iterate over that variable will cause out of bound error(which is
properly handled in linux but not necessarily in windows due to how iteration is handled).

Note that the var itself is not iterable and likely it relied on a sugar that
var[i] dispatches to tuple_getitem and when it gets out of bound the exception
get caught by the python iterator.

This PR fixes it by directly iterate over the struct info array in the annotation.
  • Loading branch information
tqchen authored Oct 24, 2023
1 parent ea588c1 commit bcdbc3e
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions python/tvm/relax/transform/lazy_transform_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,8 @@ def transform(self, func: relax.Function) -> relax.Function:
params = []
symbolic_vars = relax.analysis.defined_symbolic_vars(func)
if symbolic_vars:
for param in self.input_tuple_param:
sinfo = param.struct_info
# direct iterate over the struct info annotation
for sinfo in self.input_tuple_param.struct_info.fields:
if not isinstance(sinfo, relax.TensorStructInfo):
params.append(relax.Var("symbolic_var_holder", sinfo))

Expand Down

0 comments on commit bcdbc3e

Please sign in to comment.