better error message (#147532)

Differential Revision: [D69939736](https://our.internmc.facebook.com/intern/diff/D69939736)
Pull Request resolved: https://github.com/pytorch/pytorch/pull/147532
Approved by: https://github.com/avikchaudhuri, https://github.com/zou3519
This commit is contained in:
Tugsbayasgalan Manlaibaatar 2025-02-20 22:17:42 +00:00 committed by PyTorch MergeBot
parent a8ce4d1846
commit 6a6de0e09d

View File

@ -94,7 +94,13 @@ def fakify(
return t
if not isinstance(t, torch.Tensor):
raise ValueError(f"Unsupported input type {type(t)}")
raise ValueError(
f"Unsupported input type {type(t)}. "
"Export only supports pytree containers of basic types (Tensor, int, float, ...) as input. "
"To register a custom dataclass, use torch.export.register_dataclass. "
"To register a custom container type, use torch.utils._pytree.register_pytree_node. "
"To register a constant input, use torch.utils._pytree.register_constant"
)
n_dims = len(t.shape)
dynamic_sizes = []
constraint_sizes = [None] * n_dims