What problem does it solve?
Optimizing GPU kernels in the MNN OpenCL backend is error-prone: edited .cl files silently fail without codegen, dispatch routing sends shapes to unexpected kernels, and performance numbers on mobile GPUs are distorted by cold starts and thermal drift. This Skill provides a structured workflow covering baseline benchmarking, kernel-level and operator-level optimization, correctness oracles, and real-device verification on Android.
Core Features & Use Cases
- Guided optimization workflows: Three directions—model-level profiling to find bottlenecks, targeted operator optimization, and new OpenCL feature/extension integration with mandatory fallback paths.
- Optimization handbook: 11 proven kernel/memory-level techniques (local memory reduction, image1d_buffer texture cache, register tiling, vectorization) plus 16 documented pitfalls with measured speedups.
- Rigorous validation: Three-layer correctness oracles (CPU numeric comparison, op tests, end-to-end), interleaved A/B performance measurement to defeat thermal drift, and codegen enforcement after every .cl edit.
- Use Case: An engineer needs to speed up int4 GEMM prefill on an Adreno GPU. The Skill walks them through profiling with MNN_GPU_TIME_PROFILE, identifying the register/occupancy wall, testing tile widths, and verifying results on a real Android device.
Quick Start
Ask the AI to optimize the LinearAttention operator's OpenCL kernel performance on an Android Adreno device using the MNN benchmark-then-iterate workflow.