| 409 | } |
| 410 | |
| 411 | unsigned int TfLiteExecutor::CompareAndPrintResult(std::vector<const void*> otherOutput) |
| 412 | { |
| 413 | // Track the per output tensor results. Return the last non-zero value. |
| 414 | unsigned int overallResult = 0; |
| 415 | for (unsigned int outputIndex = 0; outputIndex < m_TfLiteInterpreter->outputs().size(); ++outputIndex) |
| 416 | { |
| 417 | auto tfLiteDelegateOutputId = m_TfLiteInterpreter->outputs()[outputIndex]; |
| 418 | size_t size = m_TfLiteInterpreter->tensor(tfLiteDelegateOutputId)->bytes; |
| 419 | double result = 1; // Presume failure. |
| 420 | switch (m_TfLiteInterpreter->tensor(tfLiteDelegateOutputId)->type) |
| 421 | { |
| 422 | case kTfLiteFloat32: |
| 423 | { |
| 424 | auto tfLiteDelegateOutputData = m_TfLiteInterpreter->typed_tensor<float>(tfLiteDelegateOutputId); |
| 425 | result = ComputeByteLevelRMSE(tfLiteDelegateOutputData, otherOutput[outputIndex], size); |
| 426 | break; |
| 427 | } |
| 428 | case kTfLiteInt32: |
| 429 | { |
| 430 | auto tfLiteDelegateOutputData = m_TfLiteInterpreter->typed_tensor<int32_t>(tfLiteDelegateOutputId); |
| 431 | result = ComputeByteLevelRMSE(tfLiteDelegateOutputData, otherOutput[outputIndex], size); |
| 432 | break; |
| 433 | } |
| 434 | case kTfLiteUInt8: |
| 435 | { |
| 436 | auto tfLiteDelegateOutputData = m_TfLiteInterpreter->typed_tensor<uint8_t>(tfLiteDelegateOutputId); |
| 437 | result = ComputeByteLevelRMSE(tfLiteDelegateOutputData, otherOutput[outputIndex], size); |
| 438 | break; |
| 439 | } |
| 440 | case kTfLiteInt8: |
| 441 | { |
| 442 | auto tfLiteDelegateOutputData = m_TfLiteInterpreter->typed_tensor<int8_t>(tfLiteDelegateOutputId); |
| 443 | result = ComputeByteLevelRMSE(tfLiteDelegateOutputData, otherOutput[outputIndex], size); |
| 444 | break; |
| 445 | } |
| 446 | case kTfLiteBool: |
| 447 | { |
| 448 | auto tfLiteDelegateOutputData = m_TfLiteInterpreter->typed_tensor<bool>(tfLiteDelegateOutputId); |
| 449 | result = ComputeByteLevelRMSE(tfLiteDelegateOutputData, otherOutput[outputIndex], size); |
| 450 | break; |
| 451 | } |
| 452 | default: |
| 453 | { |
| 454 | LogAndThrow("Unsupported output type"); |
| 455 | } |
| 456 | } |
| 457 | std::cout << "Byte level root mean square error: " << result << "\n"; |
| 458 | if (result != 0) |
| 459 | { |
| 460 | overallResult = static_cast<unsigned int>(result); |
| 461 | } |
| 462 | } |
| 463 | return overallResult; |
| 464 | }; |
nothing calls this directly
no test coverage detected