W3cubDocs

/PyTorch 2.9

strict_fusion

class torch.jit.strict_fusion [source]

Give errors if not all nodes have been fused in inference, or symbolically differentiated in training.

Example: Forcing fusion of additions.

@torch.jit.script
def foo(x):
    with torch.jit.strict_fusion():
        return x + x + x

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