# Agent brief: Profile and verify Android inference

- **Lesson id:** 06
- **Goal:** Measure cold and warm LiteRT latency, then find layout, output, asset, and accelerator problems.
- **Prerequisites:** Working debug app, preferably a physical Android device, [human lesson](06-profile-verify-android.html).
- **Inputs:** Bundled image, classifier, Logcat.
- **Outputs/artifacts:** Cold latency, 30-call warm mean/P50, stable sample label, and failure notes.

## Steps

1. Build and install, then clear Logcat. Run a fixed sample.
2. Time the first call separately, then 30 warm calls. Report device, runtime, and accelerator.
3. Check output length 10 and finite values. Compare Python and Android top labels.
4. Test all-zero and full-one inputs for stale buffers. Check APK asset packaging.
5. Optionally try `Accelerator.GPU`. Keep a CPU fallback and do not mix older delegates.

## Constraints

Do not report emulator timing as phone speed. Do not mix image prep time with graph run time. Link the [human lesson](06-profile-verify-android.html).

## Key concepts

- Measure cold latency on the first call and warm latency on later calls.
- Use a physical device for timing. The emulator is for functional checks.
- Try GPU or NPU only after CPU labels are correct. Fall back to CPU if creation fails.
- Check a fixed sample, finite outputs, and Python versus Android top-class match.

## Takeaways

- Time image prep separately from `compiledModel.run` when you optimize.
- Do not mix old TensorFlow Lite delegates into this course.
- Record device, Android version, runtime, accelerator, and cold versus warm in your notes.

## Acceptance checks

A log contains cold and warm timings, a stable label, and a written response to any unsupported accelerator.
