This is an automated email from the ASF dual-hosted git repository.
mshr pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tvm.git
The following commit(s) were added to refs/heads/main by this push:
new 54c3fb42a7 [Relax][PyTorch] Handle unknown output shapes for
_sym_size_int (#18521)
54c3fb42a7 is described below
commit 54c3fb42a71ca64c6aafb2af67de27349a2d9919
Author: Guan-Ming (Wesley) Chiu <[email protected]>
AuthorDate: Sun Nov 30 18:13:31 2025 +0800
[Relax][PyTorch] Handle unknown output shapes for _sym_size_int (#18521)
---
python/tvm/relax/frontend/torch/base_fx_graph_translator.py | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/python/tvm/relax/frontend/torch/base_fx_graph_translator.py
b/python/tvm/relax/frontend/torch/base_fx_graph_translator.py
index 33a22b34fc..e9a9cdd939 100644
--- a/python/tvm/relax/frontend/torch/base_fx_graph_translator.py
+++ b/python/tvm/relax/frontend/torch/base_fx_graph_translator.py
@@ -2553,6 +2553,11 @@ class BaseFXGraphImporter(metaclass=abc.ABCMeta):
shape = self.shape_of(x)
dim = node.args[1] if len(node.args) > 1 else node.kwargs.get("dim", 0)
+ # Handle case where shape is unknown (None) - this can happen for
operations
+ # with dynamic output shapes.
+ if shape is None:
+ return self.block_builder.emit(relax.const(0, "int64"))
+
shape_dim = shape[dim]
if hasattr(shape_dim, "value"):
return self.block_builder.emit(relax.const(shape_dim.value,
dtype="int32"))