mirror of
https://github.com/pytorch/pytorch.git
synced 2025-10-20 21:14:14 +08:00
[ez] add docblock for _expandsums (#154397)
Pull Request resolved: https://github.com/pytorch/pytorch/pull/154397 Approved by: https://github.com/laithsakka ghstack dependencies: #154400, #154398, #154396, #154399
This commit is contained in:
committed by
PyTorch MergeBot
parent
0c00e32632
commit
d62a33c002
@ -2161,6 +2161,22 @@ IndicatorTypes = (IsNonOverlappingAndDenseIndicator,)
|
||||
|
||||
|
||||
def _expandsums(args: list[sympy.Expr]) -> tuple[sympy.Expr, bool]:
|
||||
"""
|
||||
Expand products of sums into sums of products.
|
||||
|
||||
This function takes a list of sympy expressions and separates them into
|
||||
additive expressions (those with is_Add=True) and other expressions.
|
||||
It then computes the distributive product, expanding (a+b)*(c+d) into a*c + a*d + b*c + b*d.
|
||||
|
||||
Args:
|
||||
args: A list of sympy expressions to expand
|
||||
|
||||
Returns:
|
||||
A tuple containing:
|
||||
- The expanded expression as a sympy.Expr
|
||||
- A boolean indicating whether expansion occurred (True if multiple additive
|
||||
expressions were present or if there was at least one additive and one other expression)
|
||||
"""
|
||||
adds, other = [], []
|
||||
for arg in args:
|
||||
if arg.is_Add:
|
||||
|
||||
Reference in New Issue
Block a user