W3cubDocs

/PyTorch 2.9

Specialization

class torch.fx.experimental.symbolic_shapes.Specialization(source, check_fn) [source]

This class is used in multi-graph compilation contexts where we generate multiple specialized graphs and dispatch to the appropriate one at runtime. This allows us to optimize the trade-off between performance and generality by creating specialized versions for common patterns (e.g., x.shape[0] % 16 == 0) while maintaining a general fallback.

© 2025, PyTorch Contributors
PyTorch has a BSD-style license, as found in the LICENSE file.
https://docs.pytorch.org/docs/2.9/generated/torch.fx.experimental.symbolic_shapes.Specialization.html