| 471 | } |
| 472 | |
| 473 | bool TfLiteDriver::CheckResults() { |
| 474 | if (!IsValid()) return false; |
| 475 | bool success = true; |
| 476 | for (const auto& p : expected_output_) { |
| 477 | int id = p.first; |
| 478 | auto* tensor = interpreter_->tensor(id); |
| 479 | if (!p.second->Check(/*verbose=*/false, *tensor)) { |
| 480 | // Do not invalidate anything here. Instead, simply output the |
| 481 | // differences and return false. Invalidating would prevent all |
| 482 | // subsequent invocations from running.. |
| 483 | std::cerr << "There were errors in invocation '" << GetInvocationId() |
| 484 | << "', output tensor '" << id << "':" << std::endl; |
| 485 | p.second->Check(/*verbose=*/true, *tensor); |
| 486 | success = false; |
| 487 | SetOverallSuccess(false); |
| 488 | } |
| 489 | } |
| 490 | for (const auto& p : expected_output_shape_) { |
| 491 | int id = p.first; |
| 492 | auto* tensor = interpreter_->tensor(id); |
| 493 | if (!p.second->CheckShape(/*verbose=*/false, *tensor)) { |
| 494 | // Do not invalidate anything here. Instead, simply output the |
| 495 | // differences and return false. Invalidating would prevent all |
| 496 | // subsequent invocations from running.. |
| 497 | std::cerr << "There were errors in invocation '" << GetInvocationId() |
| 498 | << "', output tensor '" << id << "':" << std::endl; |
| 499 | p.second->CheckShape(/*verbose=*/true, *tensor); |
| 500 | success = false; |
| 501 | SetOverallSuccess(false); |
| 502 | } |
| 503 | } |
| 504 | expected_output_.clear(); |
| 505 | return success; |
| 506 | } |
| 507 | |
| 508 | void TfLiteDriver::ResetLSTMStateTensors() { |
| 509 | interpreter_->ResetVariableTensors(); |