torch.fx.experimental.symbolic_shapes.definitely_true¶
- torch.fx.experimental.symbolic_shapes.definitely_true(a)[source][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 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. 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.)
- Return type