| 510 | } |
| 511 | |
| 512 | string TfLiteDriver::ReadOutput(int id) { |
| 513 | auto* tensor = interpreter_->tensor(id); |
| 514 | int num_elements = 1; |
| 515 | |
| 516 | for (int i = 0; i < tensor->dims->size; ++i) { |
| 517 | num_elements *= tensor->dims->data[i]; |
| 518 | } |
| 519 | |
| 520 | switch (tensor->type) { |
| 521 | case kTfLiteFloat32: |
| 522 | return JoinDefault(tensor->data.f, num_elements, ","); |
| 523 | case kTfLiteInt32: |
| 524 | return JoinDefault(tensor->data.i32, num_elements, ","); |
| 525 | case kTfLiteInt64: |
| 526 | return JoinDefault(tensor->data.i64, num_elements, ","); |
| 527 | case kTfLiteUInt8: |
| 528 | return Join(tensor->data.uint8, num_elements, ","); |
| 529 | case kTfLiteInt8: |
| 530 | return Join(tensor->data.int8, num_elements, ","); |
| 531 | case kTfLiteBool: |
| 532 | return JoinDefault(tensor->data.b, num_elements, ","); |
| 533 | default: |
| 534 | Invalidate(absl::StrCat("Unsupported tensor type ", |
| 535 | TfLiteTypeGetName(tensor->type), |
| 536 | " in TfLiteDriver::ReadOutput")); |
| 537 | return ""; |
| 538 | } |
| 539 | } |
| 540 | |
| 541 | } // namespace testing |
| 542 | } // namespace tflite |
nothing calls this directly
no test coverage detected