Shortcuts

torch.fx.experimental.symbolic_shapes.definitely_true

torch.fx.experimental.symbolic_shapes.definitely_true(a)[source]

Returns True only if we can tell that a is True, possibly introducing a guard in the process. If a depends on some unbacked SymInt, we may return False even though there may exist a possible value of the SymInt that would cause the expression to return True.

When is it appropriate to use definitely_true? First, if you can use a higher level combinator like parallel_or/parallel_and, prefer using those instead, they are definitely safe (modulo short-circuiting). Second, it can be used if the program would behave equivalently if definitely_true always returned False (parallel_or/parallel_and are examples of this pattern, modulo short-circuiting). Finally, it even be OK if the program wouldn’t behave equivalently, so long as the change is semantics preserving. It can be semantics preserving if the program errors in more cases than it did previously (but otherwise behaves identically), or if it changes some quantity in a way that doesn’t matter (e.g., strides often fall in this bucket.)

Docs

Access comprehensive developer documentation for PyTorch

View Docs

Tutorials

Get in-depth tutorials for beginners and advanced developers

View Tutorials

Resources

Find development resources and get your questions answered

View Resources