This is an automated email from the ASF dual-hosted git repository.
ruihangl 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 20c21a3ac3 [Relax] check for tensor_meta in
exported_program_translator (#17774)
20c21a3ac3 is described below
commit 20c21a3ac302edffc2e17145d04e05049ea6d9ca
Author: Hugo Latendresse <[email protected]>
AuthorDate: Mon Mar 24 10:38:58 2025 -0400
[Relax] check for tensor_meta in exported_program_translator (#17774)
Ran into an example of a pytorch program for which a user input to
the forward() function has a node matching (node.name == name_hint)
but that node's meta dict does not have a "tensor_meta" key,
hence the translation would crash.
---
python/tvm/relax/frontend/torch/exported_program_translator.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/python/tvm/relax/frontend/torch/exported_program_translator.py
b/python/tvm/relax/frontend/torch/exported_program_translator.py
index 2abc0b0248..bf01bd6531 100644
--- a/python/tvm/relax/frontend/torch/exported_program_translator.py
+++ b/python/tvm/relax/frontend/torch/exported_program_translator.py
@@ -370,7 +370,7 @@ class ExportedProgramImporter(BaseFXGraphImporter):
torch_dtype =
exported_program.tensor_constants[spec.target].dtype
elif spec.kind is
torch.export.graph_signature.InputKind.USER_INPUT:
for node in
exported_program.graph.find_nodes(op="placeholder", target=spec.target):
- if node.name == name_hint:
+ if node.name == name_hint and "tensor_meta" in node.meta:
shape = node.meta["tensor_meta"].shape
torch_dtype = node.meta["tensor_meta"].dtype
break