Redundant condition (#32396)

Summary:
Optimize expression: 'A || (!A && B)' <=> 'A || B'

A: relErr <= maxRelErr
!A : relErr > maxRelErr
B: absErr <= absErrForRelErrFailure
Pull Request resolved: https://github.com/pytorch/pytorch/pull/32396

Differential Revision: D19499370

Pulled By: ezyang

fbshipit-source-id: c19bdcb2d4e7ff7806a8cd181c6e7e9e276b9979
This commit is contained in:
Gaurav Singh 2020-01-21 11:26:22 -08:00 committed by Facebook Github Bot
parent 839fe714de
commit ec4be4e58c

View File

@ -140,8 +140,7 @@ void compare(int N, int inputC, int H, int W,
// For small values / small difference, the relative error
// can be huge but the absolute error will be small
EXPECT_TRUE(relErr <= maxRelErr ||
(relErr > maxRelErr &&
absErr <= absErrForRelErrFailure)) <<
(absErr <= absErrForRelErrFailure)) <<
v1 << " " << v2 << " (rel err " << relErr << ") " <<
"(" << n << " " << c << " " << h << " " << w << ") " <<
"running N " << N << " inputC " << inputC <<