C# ORT Inference using VITISAI EP
This document describes how to set up C# ORT inference using VITISAI EP, with the AMD provided Nuget packages.
Structure of the repository
- RyzenAI-clip-vit-base-patch16-NPU: Contains clip model (patch 16) for NPU:
/models/clip_text_model.onnx- CLIP model for handling text/models/clip_vision_model.onnx- CLIP model for handling vision/models/clip_text_cache- pre-compiled cache for the text model/models/clip_vision_cache- pre-compiled cache for the ficion model/src/Program.cs/- Contains C# source code for running clip inference using the CLIP-vit-base-patch16 model:
Prerequisites
- Download and unzip the file containing the Nuget packages provided by AMD
- Clone the hugging face repository containing the application code, models, and cache
cdinto the cloned repo- Create a directory for the Nuget packages inside the repo
mkdir nupkgs
Copy the contents of the unzipped Nuget packages to the nupkgs directory
If dotnet is not installed, install using the executable from https://builds.dotnet.microsoft.com/dotnet/Sdk/9.0.305/dotnet-sdk-9.0.305-win-x64.exe
Instructions to create a new project
- From inside the cloned repo, create a new console application
dotnet.exe new console -n clip_project
a new directory named clip_project will be created
- Change into the project directory
cd clip_project
- Add the required Nuget packages to the project
dotnet add package System.Memory --version 4.6.3
dotnet add package System.Numerics.Tensors --version 9.0.9
dotnet add package Microsoft.ML.OnnxRuntime.Managed --version 1.23.0-dev-20250928-1204-d70213d40e --source path_to_nupkgs
dotnet add package RyzenAI_Deployment --version 1.6.0 --source path_to_nupkgs
- The version numbers of the packages may change, please check the nupkgs directory for the correct version numbers.
- The path_to_nupkgs should be replaced with the actual path to the nupkgs directory created in step
Instructions to run the provided examples
Modify the
Program.cssource code file in theRyzenAI-clip-vit-base-patch16-NPU/srcdirectory, replacing the paths that reference models and cache locations to the actual paths on your system.Copy the
Program.csfile from thesrcdirectory to the project directory created in the previous steps.
Copy ..\src\Program.cs .
- Build the project
dotnet build
- Run the project
dotnet run