You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tvm.apache.org by ju...@apache.org on 2023/10/24 04:05:23 UTC

[tvm] branch unity updated: [UNITY] Fix the symbolic var handling (#15973)

This is an automated email from the ASF dual-hosted git repository.

junrushao pushed a commit to branch unity
in repository https://gitbox.apache.org/repos/asf/tvm.git


The following commit(s) were added to refs/heads/unity by this push:
     new bcdbc3e244 [UNITY] Fix the symbolic var handling (#15973)
bcdbc3e244 is described below

commit bcdbc3e244231c7f2e63d972b98d94d6a8878bcb
Author: Tianqi Chen <tq...@users.noreply.github.com>
AuthorDate: Tue Oct 24 00:05:16 2023 -0400

    [UNITY] Fix the symbolic var handling (#15973)
    
    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.
---
 python/tvm/relax/transform/lazy_transform_params.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/python/tvm/relax/transform/lazy_transform_params.py b/python/tvm/relax/transform/lazy_transform_params.py
index 2bdc784f32..2fe3728f20 100644
--- a/python/tvm/relax/transform/lazy_transform_params.py
+++ b/python/tvm/relax/transform/lazy_transform_params.py
@@ -153,8 +153,8 @@ class LazyTransformParamsMutator(PyExprMutator):
         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))