Stop reporting errors after 10 mismatching tensor values, cutting down log size on failing builds.

PiperOrigin-RevId: 318010085
Change-Id: I9a8b70256b4f04134d9034deae606db61b1135fb
This commit is contained in:
Christian Sigg 2020-06-23 23:30:15 -07:00 committed by TensorFlower Gardener
parent 867c19e99b
commit 19e03663aa

View File

@ -42,11 +42,15 @@ void ExpectClose(const Tensor& x, const Tensor& y, double atol, double rtol) {
<< "typed_atol is negative: " << typed_atol;
ASSERT_GE(typed_rtol, static_cast<RealType>(0.0))
<< "typed_rtol is negative: " << typed_rtol;
const int max_failures = 10;
int num_failures = 0;
for (int i = 0; i < size; ++i) {
EXPECT_TRUE(
internal::Helper<T>::IsClose(Tx[i], Ty[i], typed_atol, typed_rtol))
<< "index = " << i << " x = " << Tx[i] << " y = " << Ty[i]
<< " typed_atol = " << typed_atol << " typed_rtol = " << typed_rtol;
<< "index = " << (++num_failures, i) << " x = " << Tx[i]
<< " y = " << Ty[i] << " typed_atol = " << typed_atol
<< " typed_rtol = " << typed_rtol;
ASSERT_LT(num_failures, max_failures) << "Too many mismatches, giving up.";
}
}