Skip to content

Commit e080bac

Browse files
Revert "Introduce guard_or_true, guard_or_false (pytorch#148430)"
This reverts commit d5593ea. Reverted pytorch#148430 on behalf of https://github.com/laithsakka due to need to fix stuff ([comment](pytorch#148430 (comment)))
1 parent 7482523 commit e080bac

File tree

4 files changed

+0
-40
lines changed

4 files changed

+0
-40
lines changed

docs/source/fx.experimental.rst

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,6 @@ torch.fx.experimental.symbolic_shapes
4040
has_free_unbacked_symbols
4141
definitely_true
4242
definitely_false
43-
guard_or_true
44-
guard_or_false
4543
guard_size_oblivious
4644
sym_eq
4745
constrain_range

test/allowlist_for_publicAPI.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2009,8 +2009,6 @@
20092009
"constrain_unify",
20102010
"definitely_false",
20112011
"definitely_true",
2012-
"guard_or_true",
2013-
"guard_or_false",
20142012
"error",
20152013
"eval_guards",
20162014
"eval_is_non_overlapping_and_dense",

torch/fx/experimental/sym_node.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -853,7 +853,6 @@ def _optimized_add(
853853
from sympy.core.basic import _args_sortkey as sortkey
854854

855855
def make_optimized(ordered_args):
856-
print(" optimized")
857856
result = sympy.Add(*ordered_args, evaluate=False)
858857
return (True, result)
859858

@@ -888,7 +887,6 @@ def make_optimized(ordered_args):
888887
if new_args is not None:
889888
return make_optimized(new_args)
890889

891-
print("not optimized")
892890
result = sympy.Add(lhs, rhs)
893891
return (_is_symbols_binary_summation(result), result)
894892

torch/fx/experimental/symbolic_shapes.py

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,6 @@ class PendingUnbackedSymbolNotFound(RuntimeError):
122122
aten = torch._ops.ops.aten # type: ignore[has-type]
123123

124124
__all__ = [
125-
"guard_or_false",
126-
"guard_or_true",
127125
"has_symbolic_sizes_strides",
128126
"create_contiguous",
129127
"ShapeEnv",
@@ -1183,38 +1181,6 @@ def compute_unbacked_bindings(
11831181
return symbol_to_path
11841182

11851183

1186-
# The following two functions are common utilities used while defining unbacked semantics
1187-
# of various framework code. Those would be used in situations you prefer to guard and know
1188-
# the result of the expression over not guarding, but in case you hit a data dependent error
1189-
# you are ok with just returning true or false.
1190-
# Some reasons you might be ok with returning true/false instead could be:
1191-
# (1) It's an optimization/additional check I do not want to fail for not performing it.
1192-
# (2) I am willing to deviate from the normal semantics when I have unbacked for the
1193-
# benefit of not failing.
1194-
def guard_or_false(a: BoolLikeType) -> bool:
1195-
"""
1196-
Try to gaurd a, if data dependent error encountered just return false.
1197-
"""
1198-
if isinstance(a, SymBool):
1199-
try:
1200-
guard_bool(a)
1201-
except GuardOnDataDependentSymNode:
1202-
return False
1203-
return bool(a)
1204-
1205-
1206-
def guard_or_true(a: BoolLikeType) -> bool:
1207-
"""
1208-
Try to gaurd a, if data dependent error encountered just return true.
1209-
"""
1210-
if isinstance(a, SymBool):
1211-
try:
1212-
guard_bool(a)
1213-
except GuardOnDataDependentSymNode:
1214-
return True
1215-
return bool(a)
1216-
1217-
12181184
def definitely_true(a: BoolLikeType) -> bool:
12191185
"""
12201186
Returns True only if we can tell that a is True, possibly introducing

0 commit comments

Comments
 (0)