mirror of
https://github.com/saymrwulf/onnxruntime.git
synced 2026-05-22 22:01:08 +00:00
Sahar/csharp support openvino (refined) (#4835)
* Sahar/csharp support openvino (#4703) * Temp changes and include openvino to ensure nuget package is created with linux till we configure azure ci pipeline * string id change * native nuget indentation changes * documentation changes * Update Openvino_execution_provider.md Documentation includes openvino execution provider * Update OpenVino-ExecutionProvider.md update details to build csharp api for openvino execution provider . * vadm backend revert * Update Openvino-Execution-Provider.md updated for review comments * Update OpenVino-Execution-Provider.md * Update OpenVINO-ExecutionProvider.md * nuget package custome support for openvino change in native nuget spec python script for including linux runtime * change to make path to boolean flag * removed the tab * Update OpenVINO-ExecutionProvider.md updated for review comments * chnages to include pep8 warnings modification to documentation Co-authored-by: saharfraza <sfatima.3001@gmail.com> Co-authored-by: sfatimar <sahar.fatima@intel/com> * Changes to include csharp support for openvino * Fix flake error * Fix Co-authored-by: sfatimar <64512376+sfatimar@users.noreply.github.com> Co-authored-by: saharfraza <sfatima.3001@gmail.com> Co-authored-by: sfatimar <sahar.fatima@intel/com>
This commit is contained in:
parent
24d9f4e0c3
commit
c878ecbbe0
4 changed files with 55 additions and 3 deletions
|
|
@ -16,6 +16,7 @@ CMake creates a target to this project
|
|||
<NugetExe Condition= " '$(NugetExe)' == '' ">nuget</NugetExe>
|
||||
<TargetArchitecture Condition=" '$(TargetArchitecture)' == '' ">x64</TargetArchitecture>
|
||||
<IsReleaseBuild Condition=" '$(IsReleaseBuild)' == '' ">false</IsReleaseBuild>
|
||||
<IsLinuxBuild Condition=" '$(IsLinuxBuild)' == '' ">false</IsLinuxBuild>
|
||||
|
||||
<!--internal build related properties-->
|
||||
<OnnxRuntimeSourceDirectory Condition="'$(OnnxRuntimeSourceDirectory)'==''">..</OnnxRuntimeSourceDirectory>
|
||||
|
|
@ -111,7 +112,7 @@ CMake creates a target to this project
|
|||
Properties="NoBuild=true;Platform=AnyCPU;PackageVersion=$(PackageVersion);OrtPackageId=$(OrtPackageId)"/>
|
||||
|
||||
<Message Importance="High" Text="Generating nuspec for the native Nuget package ..." />
|
||||
<Exec ContinueOnError="False" Command="python ..\tools\nuget\generate_nuspec_for_native_nuget.py --package_version $(PackageVersion) --package_name $(OrtPackageId) --target_architecture $(TargetArchitecture) --build_config $(Configuration) --native_build_path $(NativeBuildOutputDirAbs) --packages_path $(OnnxRuntimePackagesDirectoryAbs) --ort_build_path $(OnnxRuntimeBuildDirectoryAbs) --sources_path $(OnnxRuntimeSourceDirectoryAbs) --commit_id $(GitCommitHash) --is_release_build $(IsReleaseBuild)" ConsoleToMSBuild="true">
|
||||
<Exec ContinueOnError="False" Command="python ..\tools\nuget\generate_nuspec_for_native_nuget.py --package_version $(PackageVersion) --package_name $(OrtPackageId) --target_architecture $(TargetArchitecture) --build_config $(Configuration) --native_build_path $(NativeBuildOutputDirAbs) --packages_path $(OnnxRuntimePackagesDirectoryAbs) --ort_build_path $(OnnxRuntimeBuildDirectoryAbs) --sources_path $(OnnxRuntimeSourceDirectoryAbs) --commit_id $(GitCommitHash) --is_release_build $(IsReleaseBuild) --is_linux_build $(IsLinuxBuild)" ConsoleToMSBuild="true">
|
||||
<Output TaskParameter="ConsoleOutput" PropertyName="GenerateNuspecOutput" />
|
||||
</Exec>
|
||||
|
||||
|
|
|
|||
|
|
@ -136,4 +136,39 @@ Below topologies from ONNX open model zoo are fully supported on OpenVINO Execut
|
|||
| --- | --- | --- | --- | --- |
|
||||
| tiny_yolov2 | Yes | Yes | Yes | Yes* |
|
||||
|
||||
*FPGA only runs in HETERO mode wherein the layers that are not supported on FPGA fall back to OpenVINO CPU.
|
||||
*FPGA only runs in HETERO mode wherein the layers that are not supported on FPGA fall back to OpenVINO CPU.
|
||||
|
||||
## CSharp API
|
||||
|
||||
To use csharp api for openvino execution provider create a custom nuget package. Two nuget packages will be created
|
||||
Microsoft.ML.OnnxRuntime.Managed and Microsoft.ML.OnnxRuntime.Openvino.
|
||||
|
||||
1. Windows
|
||||
|
||||
Build a custom nuget package for windows.
|
||||
```
|
||||
.\build.bat --config Debug --build --use_openvino $Device --build_csharp
|
||||
msbuild csharp\OnnxRuntime.CSharp.proj /p:OrtPackageId=Microsoft.ML.OnnxRuntime.Openvino /p:Configuration=Debug /t:CreatePackage
|
||||
```
|
||||
The msbuild log will show the paths of the nuget packages created.
|
||||
|
||||
2. Linux
|
||||
|
||||
We currently do not have a process to build directly in Linux. But we can
|
||||
copy shared library <ORT linux repo>/build/Linux/<config>/libonnxruntime.so
|
||||
to onnxruntime source repository in windows and execute the same commands
|
||||
above to get custom nuget package for linux. Two nuget packages will be
|
||||
created Microsoft.ML.OnnxRuntime.Managed and Microsoft.ML.OnnxRuntime.Openvino.
|
||||
|
||||
On Linux Machine
|
||||
```
|
||||
./build.sh --config Debug --build_shared_lib --use_openvino $Device
|
||||
```
|
||||
|
||||
On Windows Machine
|
||||
```
|
||||
cp libonnxruntime.so onnxruntime/
|
||||
.\build.bat --config Debug --build --use_openvino $Device --build_csharp
|
||||
msbuild csharp\OnnxRuntime.CSharp.proj /p:OrtPackageId=Microsoft.ML.OnnxRuntime.Openvino /p:Configuration=Debug /t:CreatePackage
|
||||
```
|
||||
The msbuild log will show the path of the nuget packages created.
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ struct OpenVINOProviderFactory : IExecutionProviderFactory {
|
|||
std::unique_ptr<IExecutionProvider> CreateProvider() override;
|
||||
|
||||
private:
|
||||
const char* device_;
|
||||
std::string device_;
|
||||
};
|
||||
|
||||
std::unique_ptr<IExecutionProvider> OpenVINOProviderFactory::CreateProvider() {
|
||||
|
|
|
|||
|
|
@ -22,6 +22,9 @@ def parse_arguments():
|
|||
parser.add_argument("--commit_id", required=True, help="The last commit id included in this package.")
|
||||
parser.add_argument("--is_release_build", required=False, default=None, type=str,
|
||||
help="Flag indicating if the build is a release build. Accepted values: true/false.")
|
||||
parser.add_argument("--is_linux_build", required=False, default='false', type=str,
|
||||
help="Flag indicating if we are building a Nuget for Linux. This will look for " +
|
||||
"`libonnxruntime.so`. Accepted values: true/false.")
|
||||
|
||||
return parser.parse_args()
|
||||
|
||||
|
|
@ -160,6 +163,7 @@ def generate_files(list, args):
|
|||
is_cpu_package = args.package_name == 'Microsoft.ML.OnnxRuntime'
|
||||
is_mklml_package = args.package_name == 'Microsoft.ML.OnnxRuntime.MKLML'
|
||||
is_cuda_gpu_package = args.package_name == 'Microsoft.ML.OnnxRuntime.Gpu'
|
||||
is_openvino_package = args.package_name == 'Microsoft.ML.OnnxRuntime.Openvino'
|
||||
is_dml_package = args.package_name == 'Microsoft.ML.OnnxRuntime.DirectML'
|
||||
is_windowsai_package = args.package_name == 'Microsoft.AI.MachineLearning'
|
||||
|
||||
|
|
@ -167,6 +171,7 @@ def generate_files(list, args):
|
|||
includes_winml = is_windowsai_package
|
||||
includes_directml = (is_dml_package or is_windowsai_package) and (args.target_architecture == 'x64'
|
||||
or args.target_architecture == 'x86')
|
||||
includes_openvino = is_openvino_package
|
||||
|
||||
# Process headers
|
||||
files_list.append('<file src=' + '"' + os.path.join(args.sources_path,
|
||||
|
|
@ -183,6 +188,12 @@ def generate_files(list, args):
|
|||
'include\\onnxruntime\\core\\providers\\cuda\\cuda_provider_factory.h') +
|
||||
'" target="build\\native\\include" />')
|
||||
|
||||
if includes_openvino:
|
||||
files_list.append('<file src=' + '"' +
|
||||
os.path.join(args.sources_path,
|
||||
'include\\onnxruntime\\core\\providers\\openvino\\openvino_provider_factory.h') +
|
||||
'" target="build\\native\\include" />')
|
||||
|
||||
if includes_directml:
|
||||
files_list.append('<file src=' + '"' +
|
||||
os.path.join(args.sources_path,
|
||||
|
|
@ -216,6 +227,11 @@ def generate_files(list, args):
|
|||
'" target="lib\\netstandard2.0\\Microsoft.AI.MachineLearning.Interop.pdb" />')
|
||||
|
||||
# Process runtimes
|
||||
# Process linux
|
||||
if args.is_linux_build.lower() == 'true':
|
||||
files_list.append('<file src=' + '"' + os.path.join(args.sources_path, 'libonnxruntime.so') +
|
||||
'" target="runtimes\\linux-' + args.target_architecture + '\\native" />')
|
||||
|
||||
# Process onnxruntime import lib, dll, and pdb
|
||||
files_list.append('<file src=' + '"' + os.path.join(args.native_build_path, 'onnxruntime.lib') +
|
||||
'" target="runtimes\\win-' + args.target_architecture + '\\native" />')
|
||||
|
|
|
|||
Loading…
Reference in a new issue