How operator support changes delegation

Local Response Normalization (LRN) rescales each activation using values from nearby channels at the same spatial position. It was used in older CNNs to reduce the relative strength of activations surrounded by other strong responses, and it is not part of standard MobileNetV2. You will insert it here to show how unsupported operators can impact Ethos-U delegation.

Before attempting to lower a model with some additional unsupported operators, try to predict what might happen:

  • Will the model still have Ethos-U delegated regions?
  • Will the graph remain one large delegate or split into multiple delegates?
  • Which evidence would show that LRN introduced fallback work?
  • What problem or problems could this cause?

Identify the output that would confirm your prediction. Consider also any potential impacts of your prediction on performance.

Insert LocalResponseNorm into MobileNetV2 before quantization and lowering:

    

        
        
python module-4-ethos-npu-accelerated-inference/scripts/aot/quantize_lower_ethosu.py \
  --spec module-4-ethos-npu-accelerated-inference/artifacts/mobilenetv2/model_spec.json \
  --calibration-images module-4-ethos-npu-accelerated-inference/artifacts/mobilenetv2/calibration_images \
  --num-calib 100 \
  --target ethos-u85-256 \
  --system-config Ethos_U85_SYS_DRAM_Mid \
  --memory-mode Shared_Sram \
  --insert-lrn

    

The wrapper used by the script adds LRN after the MobileNetV2 feature extractor:

    

        
        
def forward(self, image):
    x = self.features(image)
    x = self.lrn(x)
    x = F.adaptive_avg_pool2d(x, (1, 1))
    x = torch.flatten(x, 1)
    return self.classifier(x)

    

The script prints the top-level ExecuTorch delegation summary. You should expect output similar to this:

    

        
        
PTE size: 3.60 MB

Delegation
==========
Ethos-U delegate call sites: 2
Fallback call_function ops:  13
  aten.avg_pool3d.out (1)
  cortex_m.dequantize_per_tensor.out (2)
  cortex_m.quantize_per_tensor.out (2)
  ...

    

The supported operations on either side of the LRN path still compile through Vela, but aten.avg_pool3d.out remains non-delegated between two NPU-delegated regions. Vela therefore generates two Ethos-U command streams instead of one. The cortex_m.quantize_per_tensor and cortex_m.dequantize_per_tensor entries are the boundary q/dq nodes that the script rewrites before packaging. The full output also contains getitem and alloc entries. These small operations select outputs and allocate memory.

Compare the non-LRN Vela report with the two LRN-region Vela reports:

Graph regionNPU operatorsSRAM usedDRAM usedEstimated DRAM trafficMACs
Baseline INT8561474.72 KiB3494.75 KiB3.44 MB/inference300,988,800
LRN region 1591474.72 KiB2301.31 KiB71.88 MB/inference299,833,156
LRN region 26262.50 KiB1194.08 KiB1.17 MB/inference1,469,440

These are per-region compiler estimates, not measured latency. The reports show that the LRN variant is split into two compilable NPU regions and that its estimated memory traffic differs substantially from the baseline.

A single-delegate pattern looks like:

    

        
        
ExecuTorch runtime -> [large Ethos-U delegated region] -> ExecuTorch runtime

    

The LRN variant looks closer to:

    

        
        
ExecuTorch runtime -> [Ethos-U region] -> [q/dq + non-delegated avg_pool3d] -> [Ethos-U region] -> ExecuTorch runtime

    

The second pattern still uses the NPU, but moving between two delegates can add q/dq operations, synchronization, and tensor movement.

Whether the non-delegated operation can execute on a target CPU also depends on the kernels included in that target runtime, and even if it can execute, it could add a lot of additional overhead, bottlenecking your application, and potentially obscuring benefits gained through NPU acceleration.

Before moving on to running the original INT8 model on the FVP, you may wish to use Model Explorer to visualize the different artifacts.

Optional activity

Inspect the artifacts with Model ExplorerModel Explorer setup

Reuse the Model Explorer environment configured in Module 1. If you skipped that setup, follow Inspect GPT-2 delegation with Model Explorer through starting Model Explorer with the PTE adapter.

If you created the Module 4 artifacts on a remote Linux host, copy the three .pte files to your development machine before opening them in Model Explorer.

Open these three artifacts in Model Explorer:

  • mobilenetv2_fp32_ethosu.pte
  • mobilenetv2_int8_ethosu.pte
  • mobilenetv2_lrn_int8_ethosu.pte

Compare the number of EthosUBackend delegate calls and the operations that remain outside them. Check that the FP32 graph has no Ethos-U delegate, the baseline INT8 graph has one, and the LRN graph has two with aten.avg_pool3d.out between them. Expand the delegate calls and inspect the input and output boundary operations for each graph.

Previous page Complete and continue