mshr-h commented on code in PR #18429:
URL: https://github.com/apache/tvm/pull/18429#discussion_r2513977745


##########
python/tvm/relax/frontend/torch/exported_program_translator.py:
##########
@@ -1097,11 +1097,28 @@ def create_convert_map(
 
     def create_input_vars(
         self, exported_program: torch.export.ExportedProgram
-    ) -> Tuple[Dict[str, relax.Var], Dict[str, relax.Var]]:
+    ) -> Tuple[Dict[str, relax.Var], Dict[str, relax.Var], Dict[str, 
Tuple[int, int]]]:
         """Create relax input vars."""
         parameters_buffers_constants = OrderedDict()
         user_inputs = OrderedDict()
         torch_symbol_to_relax_var: Dict[str, tvm.tir.Var] = {}
+        range_constraints = {}
+
+        if hasattr(exported_program, "range_constraints"):
+            for symbol, value_range in 
exported_program.range_constraints.items():
+                symbol_name = str(symbol)
+                if hasattr(value_range, "lower") and hasattr(value_range, 
"upper"):
+                    try:
+                        lower = int(value_range.lower)
+                    except (OverflowError, AttributeError, TypeError):
+                        continue
+
+                    try:
+                        upper = int(value_range.upper)
+                    except (OverflowError, AttributeError, TypeError):
+                        continue
+
+                    range_constraints[symbol_name] = (lower, upper)

Review Comment:
   Make sense to me.
   @guan404ming Can you apply the change?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to