| 413 | } |
| 414 | |
| 415 | void TfLiteDriver::SetExpectation(int id, const string& csv_values) { |
| 416 | if (!IsValid()) return; |
| 417 | auto* tensor = interpreter_->tensor(id); |
| 418 | if (expected_output_.count(id) != 0) { |
| 419 | Invalidate(absl::StrCat("Overridden expectation for tensor '", id, "'")); |
| 420 | } |
| 421 | expected_output_[id].reset( |
| 422 | new Expectation(relative_threshold_, absolute_threshold_)); |
| 423 | switch (tensor->type) { |
| 424 | case kTfLiteFloat32: |
| 425 | expected_output_[id]->SetData<float>(csv_values); |
| 426 | break; |
| 427 | case kTfLiteInt32: |
| 428 | expected_output_[id]->SetData<int32_t>(csv_values); |
| 429 | break; |
| 430 | case kTfLiteInt64: |
| 431 | expected_output_[id]->SetData<int64_t>(csv_values); |
| 432 | break; |
| 433 | case kTfLiteUInt8: |
| 434 | expected_output_[id]->SetData<uint8_t>(csv_values); |
| 435 | break; |
| 436 | case kTfLiteInt8: |
| 437 | expected_output_[id]->SetData<int8_t>(csv_values); |
| 438 | break; |
| 439 | case kTfLiteBool: |
| 440 | expected_output_[id]->SetData<bool>(csv_values); |
| 441 | break; |
| 442 | case kTfLiteString: |
| 443 | expected_output_[id]->SetData<string>(csv_values); |
| 444 | break; |
| 445 | case kTfLiteComplex64: |
| 446 | expected_output_[id]->SetData<std::complex<float>>(csv_values); |
| 447 | break; |
| 448 | default: |
| 449 | Invalidate(absl::StrCat("Unsupported tensor type ", |
| 450 | TfLiteTypeGetName(tensor->type), |
| 451 | " in TfLiteDriver::SetExpectation")); |
| 452 | return; |
| 453 | } |
| 454 | } |
| 455 | |
| 456 | void TfLiteDriver::SetShapeExpectation(int id, const string& csv_values) { |
| 457 | if (!IsValid()) return; |