Fix Add.flatten when terms have S.NaN
Merge pull request #2652 from skirpichev/gh2633

Fix Add.flatten when terms have S.NaN