This repository was archived by the owner on Aug 1, 2025. It is now read-only.
[dynamo] Introduce get_real_value API to TensorVariable
#1575
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Right now, example_value is doing two jobs:
throughout the graph
assume_constant_result)This is further complicated by the fact that we have two modes, one
where
example_valueis a fake tensor, and one where it is a realtensor (this is the
fake_tensor_propagationconfig flag).This leads to scenarios where we don't support every combination of job + mode,
e.g. if
fake_tensor_propagation=False,assume_constant_resultis broken.This is made worse by the fact that "fake tensor mode" is the default
and is required if you want dynamic shapes to work.
So, this PR introduces a
get_real_valueAPI that just runs the graphup to
nodein order to get a concrete value. This API is orthogonal toexample_value, so it doesn't care aboutfake_tensor_propagation.When
fake_tensor_propagation=True:example_valueis a fake tensor,you must use the
get_real_valueAPI to get a concrete value. This willbe the only configuration in the future.
When
fake_tensor_propagation=False:example_valueandget_real_valuewill produce the same value. This is redundant but wewill be removing this config soon.
To support this, I introduce a cache for computed real values, to
memoize the work involved if we're asking for real values a lot.
I attached this state to
OutputGraphbecause it seems to be whathistorically managed
example_valuelifetimes, but idk.