Skip to content

Commit 4377a56

Browse files
authored
[Jarvis][Nightly] address zero division jarvis-nightly-operators-test-aten-div-out
Differential Revision: D85364549 Pull Request resolved: #15496
1 parent 7a5bca6 commit 4377a56

File tree

1 file changed

+19
-8
lines changed

1 file changed

+19
-8
lines changed

backends/cadence/utils/facto_util.py

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -344,14 +344,25 @@ def random_size_constraint(deps: object, r: int, d: int) -> int:
344344
]
345345
)
346346
case "div.Tensor":
347-
tensor_constraints.extend(
348-
[
349-
cp.Value.Ne(lambda deps, dtype, struct: 0),
350-
cp.Value.Le(lambda deps, dtype, struct: 2**3),
351-
cp.Size.Le(lambda deps, r, d: 2**3),
352-
cp.Rank.Le(lambda deps: 2**2),
353-
]
354-
)
347+
if index == 1: # Only apply zero-prevention to divisor
348+
tensor_constraints.extend(
349+
[
350+
cp.Value.Ne(
351+
lambda deps, dtype, struct: 0
352+
), # Prevent division by zero
353+
cp.Value.Le(lambda deps, dtype, struct: 2**3),
354+
cp.Size.Le(lambda deps, r, d: 2**3),
355+
cp.Rank.Le(lambda deps: 2**2),
356+
]
357+
)
358+
else:
359+
tensor_constraints.extend(
360+
[
361+
cp.Value.Le(lambda deps, dtype, struct: 2**3),
362+
cp.Size.Le(lambda deps, r, d: 2**3),
363+
cp.Rank.Le(lambda deps: 2**2),
364+
]
365+
)
355366
case "pow.Tensor_Scalar":
356367
tensor_constraints.extend(
357368
[

0 commit comments

Comments
 (0)