Arm backend: Stop re-creating Ethos-U driver objects per inference on Linux - #22599
Arm backend: Stop re-creating Ethos-U driver objects per inference on Linux#22599vacu9708 wants to merge 1 commit into
Conversation
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/22599
Note: Links to docs will display an error until the docs builds have been completed.
|
|
The following ciflow label(s) have been added but CI has not been triggered yet because the workflows are awaiting approval:
Once a maintainer approves the workflows (scroll to the bottom of the PR page), the corresponding CI jobs will be triggered automatically. Please ping one of the reviewers if you do not have access to approve and run workflows. |
This PR needs a
|
… Linux **Problem** On the Cortex-A path, execute() created the driver objects (the network and the DMA buffers, including a full copy of the weights) on every inference. **Fix** Create them once in platform_init() and keep them for the lifetime of the loaded method. Measured on the Corstone-1000 FVP: 53-77% less CPU time in execute() per inference. Signed-off-by: Youngsik Yang <vacu9708@gmail.com>
153ac43 to
820f84a
Compare
Problem
On the Cortex-A path, the same driver setup is redone on every inference.
sequenceDiagram participant ET as EthosUBackend participant CA as Cortex-A platform participant K as Kernel driver ET->>CA: init() loop every execute() ET->>CA: execute(inputs) CA->>K: create network, weight, intermediate, IFM/OFM buffers<br/>(copies command stream and weights) CA->>K: write inputs CA->>K: run inference K-->>CA: outputs CA->>K: free all of them Note over K: allocated and freed on every inference CA-->>ET: outputs endChanges
sequenceDiagram participant ET as EthosUBackend participant CA as Cortex-A platform participant K as Kernel driver ET->>CA: init() CA->>K: create network, weight, intermediate, IFM/OFM buffers<br/>(copies command stream and weights) Note over K: allocated once, freed in destroy() loop every execute() ET->>CA: execute(inputs) CA->>K: write inputs CA->>K: run inference K-->>CA: outputs CA-->>ET: outputs end ET->>CA: destroy() CA->>K: free all of themThis commit creates the driver objects once in
platform_init()and keeps them inPlatformStatefor the lifetime of the loaded method.invoke_linux_driver()now only writes the inputs, runs the inference, and reads the outputs.PlatformStateinvoke_linux_driver()const PlatformState&and reuses its objects on each inferencecreate_driver_objects()invoke_linux_driver()Measurement
These results were measured on the Corstone-1000 A320 FVP (Ethos-U85) using the CPU time report from #22596.
Additionally, I would like to ask if PR #22596, which I used to benchmark this PR, is mergeable as-is.
execute()CPU time per inference, before -> aftercc @digantdesai @freddan80 @per @zingo @oscarandersson8218 @mansnils @Sebastian-Larsson @robell @rascani