torch.fx.experimental¶
Warning
These APIs are experimental and subject to change without notice.
torch.fx.experimental.symbolic_shapes¶
torch.fx.experimental.symbolic_shapes
provides interfaces for interacting with
our symbolic shapes reasoning system that is used heavily in torch.compile. Although
this is not generally considered public API, when writing framework code in PyTorch
as well as extensions to PyTorch (e.g., in custom operator implementations), you may
need to make use of these APIs to setup dynamic shapes support appropriately.
Controls how to perform symbol allocation for a dimension. 

For clients: the size at this dimension must be within 'vr' (which specifies a lower and upper bound, inclusiveinclusive) AND it must be nonnegative and should not be 0 or 1 (but see NB below). 

For clients: no explicit constraint; constraint is whatever is implicitly inferred by guards from tracing. 

Represent and decide various kinds of equality constraints between input sources. 

Data structure specifying how we should create symbols in 

Create symbols in 

Create symbols in 

The correct symbolic context for a given inner tensor of a traceable tensor subclass may differ from that of the outer symbolic context. 

Custom solver for a system of constraints on symbolic dimensions. 

Encapsulates all shape env settings that could potentially affect FakeTensor dispatch. 

Retrieve the hint for an int (based on the underlying real values as observed at runtime). 

Utility to check if underlying object in SymInt is concrete value. 

Utility to check if underlying object in SymBool is concrete value. 

Faster version of bool(free_symbols(val)) 

Returns True only if we can tell that a is True, possibly introducing a guard in the process. 

Returns True only if we can tell that a is False, possibly introducing a guard in the process. 

Perform a guard on a symbolic boolean expression in a size oblivious way. 

Evaluate the logical OR of several arguments, avoiding guarding on unbacked SymInts if another argument is definitely True. 

Evaluate the logical FALSE of several arguments, avoiding guarding on unbacked SymInts if another argument is definitely False. 

Like ==, but when run on list/tuple, it will recursively test equality and use sym_and to join the results together, without guarding. 

Applies a constraint that the passed in SymInt must lie between minmax inclusiveinclusive, WITHOUT introducing a guard on the SymInt (meaning that it can be used on unbacked SymInts). 

Given two SymInts, constrain them so that they must be equal. 

Canonicalize a boolean expression by transforming it into a lt / le inequality and moving all the nonconstant terms to the rhs. 

Returns True if x can be simplified to a constant and is true. 

Test that two "meta" values (typically either Tensor or SymInt) have the same values, e.g., after retracing. 