Rate this Page

torch.fx.experimental.symbolic_shapes.free_symbols#

torch.fx.experimental.symbolic_shapes.free_symbols(val)[source]#

Recursively collect all free symbols from a value.

This function traverses various data structures (tensors, lists, tuples, etc.) and extracts all sympy symbols contained within them. It’s useful for finding all symbolic variables that a complex nested structure depends on.

Parameters:

val (SymInt | SymFloat | SymBool | int | float | bool | Basic | Tensor | Sequence[SymInt | SymFloat | SymBool | int | float | bool | Basic | Tensor]) – The value to extract symbols from. Can be a symbolic type (SymInt, SymFloat, SymBool), a container (tuple, list), a tensor, or None.

Returns:

An ordered set of all free symbols found in the value.

Return type:

OrderedSet[sympy.Symbol]