realesr-general-x4v3 — ONNX (fp32 for DirectML, bf16 for the AMD Ryzen AI NPU)
Fixed-shape ONNX exports of realesr-general-x4v3 (Real-ESRGAN General v3, SRVGGNetCompact with 64 channels
and 32 convolution layers, 4x) by Xintao Wang, from the weights published in
xinntao/Real-ESRGAN v0.2.5.0
(realesr-general-x4v3.pth, SHA-256 8dc7edb9ac80ccdc30c3a5dca6616509367f05fbc184ad95b731f05bece96292).
*_fp32.onnxruns on any ONNX Runtime execution provider. It is used with DirectML on an AMD iGPU.*_bf16cast.onnxis for the ONNX Runtime VitisAI execution provider of Ryzen AI Software 1.8.0 on an XDNA2 NPU.
Input is RGB in [0, 1], float32, NCHW, 3 channels. Output is 4x the input height and width.
Files
| File | Input → output | Precision | Target | SHA-256 |
|---|---|---|---|---|
generalv3_nchw_256x256_fp32.onnx | 1x3x256x256 → 1x3x1024x1024 | fp32 | DirectML / CPU | 4488cb17aeddbd912622eb6c422684d2e43d2b107179133adab70e6c51775518 |
generalv3_nchw_512x512_fp32.onnx | 1x3x512x512 → 1x3x2048x2048 | fp32 | DirectML / CPU | 4f42b00306c4e247ec8929aa087c2d3b713456b24eedd7938aabc7447b6b9cb2 |
generalv3dp_nchw_512x512_bf16cast.onnx | 1x3x512x512 → 1x3x2048x2048 | bf16 (cast) | VitisAI EP, whole model | cbefdef03d27a05cc464e8263f50265f100e0f28ef95dd010f934cfdd3aa5feb |
generalv3dp_body_nchw_512x512_bf16cast.onnx | 1x3x512x512 → 1x48x512x512 | bf16 (cast) | VitisAI EP, body only | 867cc1c1c90d44019db556aaa59b47f63b680f6f32f5f7529d60db574541d9a6 |
generalv3dp_body_nchw_512x512.tail.json | manifest for the body | — | CPU post-processing | 1076f5884e70290561788ce36886c18d83c596dc0e3830928113ef0dc2189d33 |
dp in a file name means the PReLU activations are decomposed into two ReLU branches
(PReLU(x) = ReLU(x) - a * ReLU(-x)), which the VAIML compiler of Ryzen AI 1.8.0 maps onto the NPU as a
single subgraph.
The body file is the same bf16 model with the final DepthToSpace(blocksize=4, CRD) and the
nearest-neighbour skip connection (Resize + Add) cut off. The manifest describes that tail; the host
runs it on the CPU with a few lines of NumPy. This moves a memory-bound operation off the NPU and
produces output bit-identical to the whole model
(tail-cut.md).
How the files were made
- Weights → fixed-shape fp32 ONNX with
scripts/npu/export_generalv3.py(opset 17, no dynamic axes, onnxsim). The script writes the 256 and 512 fp32 files and thedpfp32 file. - fp32 → bf16:
python -m quark.onnx.tools.convert_fp32_to_bf16 --input generalv3dp_nchw_512x512_fp32.onnx --output generalv3dp_nchw_512x512_bf16cast.onnx --format with_cast(AMD Quark, from the Ryzen AI 1.8.0 environment; no calibration data). - Tail cut:
scripts/npu/split_tail.py, which also verifiesbody + NumPy tail == whole modelon the CPU EP (max abs diff < 1e-5).
The full procedure is written up in docs/model-conversion.md.
Running on the NPU
The VitisAI EP compiles the bf16 model with VAIML when the first session is created. On a Ryzen AI 7 PRO 350
this takes about 20 minutes; the result is cached (cache_dir / cache_key session options) and later
sessions start in seconds. The cache is tied to the Ryzen AI Software and NPU driver versions, so it is not
published here; compile it on the target machine.
Measured on a Ryzen AI 7 PRO 350 (XDNA2 NPU, Radeon 860M, 32 GB LPDDR5-8000, Ryzen AI SW 1.8.0, NPU driver 32.0.203.329), one 854x480 frame → 4x, including tiling and merge, steady state, 2026-10-11:
| Execution | Time per frame | PSNR vs fp32 output |
|---|---|---|
| iGPU, DirectML, fp32 (256–512 tiles) | 0.61 s | — |
| NPU, VitisAI EP, bf16, power mode Default (512 tiles) | 0.65 s | 43.7 dB |
PSNR was measured on one 1280x534 photograph against the DirectML fp32 output. Details of the measurement and the compiler workarounds are in tomhda/ryzen-ai-npu-super-resolution-notes.
License and attribution
The model weights are by Xintao Wang and contributors, released under the
BSD 3-Clause License (xinntao/Real-ESRGAN). The ONNX files
here are format conversions of those weights and carry the same license; the original notice is in
LICENSE-BSD-3-Clause-Real-ESRGAN.txt.
This is an independent, personal conversion. It is not affiliated with or endorsed by AMD or the Real-ESRGAN authors. AMD, Ryzen and Ryzen AI are trademarks of Advanced Micro Devices, Inc.
These files are also the model kit of TOGU SCALER, a Windows upscaler that runs them on DirectML and on the Ryzen AI NPU.