MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / Repeatedly

Method Repeatedly

tensorflow/compiler/tests/randomized_tests.cc:392–422  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

390}
391
392void OpTest::Repeatedly(const std::function<TestResult(void)>& fn) {
393 int const max_repetitions = tf_xla_test_repetitions;
394 int valid_test_runs = 0;
395 // We run up to 100 * max_repetitions times; the idea is that if we roll the
396 // dice enough times we will find some valid parameters. We want to put an
397 // upper limit on the number iterations just in case the probability of
398 // finding feasible parameters is very low.
399 for (int i = 0; !HasFailure() && i < max_repetitions * 100 &&
400 valid_test_runs < max_repetitions;
401 ++i) {
402 TestResult result = fn();
403 switch (result) {
404 case kOk:
405 ++valid_test_runs;
406 break;
407
408 case kFatalError:
409 ASSERT_TRUE(false) << "Test had fatal failure";
410 return;
411
412 case kInvalid:
413 break;
414 }
415 }
416 if (!HasFailure()) {
417 EXPECT_GE(valid_test_runs, max_repetitions)
418 << "Not enough test instances passed; this means that either the "
419 "golden implementation is buggy or the operator harness is not "
420 "producing well-formed test cases with a high probability.";
421 }
422}
423
424template <typename T>
425T OpTest::Choose(absl::Span<const T> candidates) {

Callers

nothing calls this directly

Calls 1

fnFunction · 0.50

Tested by

no test coverage detected