Skip to content

Commit

Permalink
fix: if the input tensor of a graph is int with low/high constraint, …
Browse files Browse the repository at this point in the history
…the faketensor doesn't have the range information, so try using the GraphArg instead.
  • Loading branch information
kiya00 committed Oct 14, 2024
1 parent b34a010 commit d254715
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions thunder/dynamo/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,12 @@ def _get_example_inputs_from_placeholder(node) -> tuple[torch.Tensor]:
from thunder.tests.make_tensor import make_tensor

check(node.op == "placeholder", lambda: f"The node must be placeholder type", ValueError)
# Prefers to use actual example value in GraphArg if available
if "grapharg" in node.meta:
example_value = node.meta["grapharg"].example
if isinstance(example_value, torch.Tensor):
return (example_value.detach().clone().requires_grad_(example_value.requires_grad),)

check("example_value" in node.meta, lambda: "example_value does not exist in the meta of {node}", ValueError)
example_value = node.meta["example_value"]

Expand Down

0 comments on commit d254715

Please sign in to comment.