Run ONNX models on AMD GPUs from C#, with MIGraphX inference and HIP image processing.
English | ็ฎไฝไธญๆ
AMD MIGraphX is a graph inference engine in the ROCm ecosystem. It compiles deep learning models into GPU programs and optimizes their execution for AMD hardware.
MIGraphX CSharp API is a .NET wrapper for AMD MIGraphX. It lets C# developers load ONNX models, compile GPU programs, work with tensors and run inference directly from their applications. The optional HIP adapter connects GPU preprocessing, model execution and postprocessing on the same stream.
The repository includes complete YOLO26 and PP-OCRv4/v5/v6 examples. All three OCR generations use one PaddleOcr project. Image processing, inference, result decoding and timing are written in C# and HIP; running the examples requires no Python or OpenCV.
| Core advantage | What it means for your application |
|---|---|
| ๐ AMD GPU inference | Use MIGraphX model compilation and execution through a managed C# API |
| โก GPU image pipelines | Keep numerical preprocessing and postprocessing on the GPU with HIP streams and device buffers |
| ๐งฉ .NET integration | 15 target frameworks from .NET Framework 4.6 to .NET 10, with Chinese/English XML API comments |
| ๐ Complete examples | YOLO26 five tasks and PP-OCRv4/v5/v6 detection/recognition, including OCR batching and multiple recognition instances |
- Adds
RunDeviceIntoAsyncfor device output buffers and subsequent HIP processing. - Moves numerical preprocessing and postprocessing in both vision examples to HIP.
- Adds OCR recognition batching and multiple instances; full-image recognition defaults to batch 4 with 2 instances.
Complete 0.0.2 release notes ยท All releases ยท Download v0.0.2
Install ROCm 7.2.1 and MIGraphX 2.15.0 on a compatible Linux host first; see the runtime deployment guide. Then create your application:
dotnet new console -n MigraphxDemo
cd MigraphxDemo
dotnet add package JYPPX.ROCm.MIGraphX.CSharp.API --version 0.0.2This example uses a static float32 ONNX model whose input is named input and contains four elements. Replace the model path, input name and data with those required by your model.
using JYPPX.ROCm.MIGraphXSharp;
const string nativePath = "/opt/rocm/lib/libmigraphx_c.so.3";
// Parse the model and read its input shapes.
using var options = new MIGraphXOnnxOptions(nativePath);
using var program = MIGraphXProgram.ParseOnnxFile("/models/model.onnx", options);
var inputShapes = program.GetParameterShapes();
// Compile once, then reuse the program for subsequent inputs.
using var target = new MIGraphXTarget(nativePath, "gpu");
using var compileOptions = new MIGraphXCompileOptions(nativePath, offloadCopy: true);
program.Compile(target, compileOptions);
// Supply the model input and execute inference.
using var input = MIGraphXArgument.Create(
nativePath, inputShapes["input"], new[] { 1f, 2f, 3f, 4f });
using var parameters = new MIGraphXParameterMap(nativePath);
parameters.Add("input", input);
using var outputs = program.Run(parameters);
float[] result = outputs[0].ToArray<float>();
Console.WriteLine(string.Join(", ", result));dotnet run -c ReleaseStart with the YOLO26 example or PaddleOCR example for image models. The getting started guide covers installation and native-library diagnostics.
| Feature | Description |
|---|---|
| ONNX inference | Parse models from files or memory, compile for GPU and execute with multiple inputs/outputs |
| Typed tensors | Inspect shapes, types and strides; create typed host inputs and copy results into C# arrays |
| Dynamic shapes | Configure fixed input overrides or dimension ranges before parsing |
| Program reuse | Save/load compiled programs and use an explicit model cache |
| HIP integration | Host/device-input asynchronous submission, stream synchronization and caller-owned device output buffers |
| Graph APIs | Program-owned modules, parameters, literals, instructions and typed operation attributes |
| Advanced APIs | TensorFlow parsing, FP16/BF16/INT8/FP8 quantization and experimental custom-operation callbacks |
| Resource management | Deterministic Dispose, native loading diagnostics and resource leases for pending HIP work |
See the API guides and platform support for the applicable runtime and experimental feature boundaries.
Install the adapter only when you need HIP integration:
dotnet add package JYPPX.ROCm.MIGraphX.CSharp.API.HIP.Interop --version 0.0.2The adapter requires core 0.0.2 and HipSharp 0.10.0; NuGet restores these dependencies. The core namespace is JYPPX.ROCm.MIGraphXSharp. AMD native libraries are installed separately. GitHub Releases also provide packages, source and offline HTML documentation.
| Example | Tasks | Included functionality |
|---|---|---|
| YOLO26 | Detection, classification, instance segmentation, pose and oriented boxes | HIP resize/normalization, output decoding, masks, keypoints and annotated results |
| PP-OCRv4/v5/v6 | v4/v5 mobile and server; v6 tiny, small and medium; full images or recognition only | HIP text-box extraction, perspective crops, batched recognition, multiple instances and CTC decoding |
| CLIP | Image/text matching and retrieval | ViT-B/32 GPU dual encoders, English BPE, image batching and HTML results |
| PP-Structure | Document orientation, layout, OCR and tables | MIGraphX GPU document/table models and HIP OCR; optional, explicitly selected ORT CPU formula recognition |
All four projects are self-contained and target .NET 10. YOLO26 and PaddleOcr include a CPU preprocessing/postprocessing option; both options use MIGraphX GPU model execution. CLIP uses CPU image processing with GPU encoders. PP-Structure's formula recognition is an explicit ORT CPU option. Supply models and inputs separately; each example documents its processing and timing scope.
The unified PaddleOcr entry point, v4/v5 support, CLIP and PP-Structure are available in the current main source. The published v0.0.2 tag retains the original PaddleOcrV6 example.
On the documented gfx1100 FP32 baseline, whole-image HIP processing averages 2.75 ms for YOLO26n detection and 10.97 ms for PP-OCRv6 tiny with 16 text lines. These timings exclude file decode, compilation, drawing and export. The 0.0.2 notes contain the complete results and measurement conditions; the vision guide explains the options.
| Resource | Contents |
|---|---|
| Getting started | Install packages and run the first inference |
| Managed objects | Models, tensors, inputs/outputs and resource ownership |
| Dynamic shapes and cache | Input overrides, program persistence and cache reuse |
| HIP integration | Asynchronous execution and GPU buffers |
| Advanced APIs | Graphs, TensorFlow and quantization |
| API reference | API documentation and offline reference |
| Release history | Changes, compatibility and upgrade instructions by version |
| Technical blog | Chinese project and application articles |
Set your model's input dimensions before parsing; compile and run it using the same object API shown above.
using var options = new MIGraphXOnnxOptions(nativePath);
options.SetInputParameterShape("images", new long[] { 1, 3, 640, 640 });
using var program = MIGraphXProgram.ParseOnnxFile("/models/yolo26n.onnx", options);using var fileOptions = new MIGraphXFileOptions(nativePath, "msgpack");
program.Save("/models/compiled.msgpack", fileOptions);
using var restored = MIGraphXProgram.Load("/models/compiled.msgpack", fileOptions);Use a compatible native runtime and compilation target when reusing a saved program. Device output and GPU postprocessing are covered in the HIP guide.
| Component | Requirements |
|---|---|
| Managed library | .NET Framework 4.6โ4.8.1, .NET Core 3.1, .NET 5โ10; 15 target frameworks |
| Validated native platform | Ubuntu 24.04 x86-64, ROCm 7.2.1, MIGraphX 2.15.0, gfx1100 |
| Native library | /opt/rocm/lib/libmigraphx_c.so.3, or the absolute path in your ROCm installation |
| Vision examples | .NET 10; HIPRTC with the matching GPU architecture, or a precompiled HIP module |
Managed framework compatibility does not provide a Windows/macOS MIGraphX runtime. Use the AMD installation instructions and deployment guide to prepare the target host. Other GPU/runtime combinations are described in platform support.
MIGraphXSharp/
โโโ src/
โ โโโ JYPPX.ROCm.MIGraphX.CSharp.API/ # Core library
โ โโโ JYPPX.ROCm.MIGraphX.CSharp.API.HIP.Interop/ # HIP adapter
โโโ samples/
โ โโโ Yolo26/ # Five vision tasks
โ โโโ PaddleOcr/ # Text detection and recognition
โโโ docs/
โ โโโ guides/ # Installation and usage
โ โโโ release-notes/ # Version history
โ โโโ blog/ # Technical articles
โโโ eng/ # Build and packaging scripts
โโโ MIGraphXSharp.sln
Install the SDK selected by global.json, PowerShell 7 and the HipSharp source dependency. Run from the repository root:
./eng/build.ps1 -Configuration Release -Version 0.0.2
./eng/pack.ps1 -Configuration Release -Version 0.0.2 -NoBuildBuilds without an explicit version use 0.0.0. Outputs go to the sibling MIGraphXSharp.Workspace/ directory. See CONTRIBUTING.md for the full build setup.
Issues and pull requests are welcome. Include package versions, ROCm/MIGraphX versions, operating system, GPU and a minimal reproduction when reporting an issue.
The project is licensed under Apache-2.0; see NOTICE. Thanks to AMD MIGraphX and ROCm for the native inference and GPU computing stack. Third-party libraries and model assets retain their own licenses.
Related projects: OpenVINO C# API ยท TensorRT C# API ยท HIP C# API.
- GitHub: @guojin-yan
- NuGet: JYPPX.ROCm.MIGraphX.CSharp.API
This project uses AI-assisted development. Feedback, issue reports and contributions help improve the library. The software is provided under the Apache-2.0 license without warranties; evaluate your application's models, native runtime and deployment requirements before production use. Refer to platform support for known limitations and experimental APIs.
Copyright ยฉ 2026 Guojin Yan.
