├── .github ├── FUNDING.yml ├── ISSUE_TEMPLATE │ ├── bug_report.md │ └── feature_request.md ├── stale.yml └── workflows │ ├── build-onnxruntime-extensions.yaml │ └── publish-packages.yml ├── .gitignore ├── README.md ├── com.github.asus4.onnxruntime-extensions ├── Editor.meta ├── Editor │ ├── OrtPostProcessBuild.cs │ ├── OrtPostProcessBuild.cs.meta │ ├── com.github.asus4.onnxruntime-extensions.Editor.asmdef │ └── com.github.asus4.onnxruntime-extensions.Editor.asmdef.meta ├── LICENSE ├── LICENSE.meta ├── Plugins.meta ├── Plugins │ ├── Android.meta │ ├── Android │ │ └── onnxruntime-extensions.aar.meta │ ├── Linux.meta │ ├── Linux │ │ ├── arm64.meta │ │ ├── arm64 │ │ │ └── libortextensions.so.meta │ │ ├── x64.meta │ │ └── x64 │ │ │ └── libortextensions.so.meta │ ├── Windows.meta │ ├── Windows │ │ ├── arm64.meta │ │ ├── arm64 │ │ │ └── ortextensions.dll.meta │ │ ├── x64.meta │ │ └── x64 │ │ │ └── ortextensions.dll.meta │ ├── macOS.meta │ └── macOS │ │ ├── arm64.meta │ │ ├── arm64 │ │ └── libortextensions.dylib.meta │ │ ├── x64.meta │ │ └── x64 │ │ └── libortextensions.dylib.meta ├── README.md ├── README.md.meta ├── ThirdPartyNotices.txt ├── ThirdPartyNotices.txt.meta ├── package.json └── package.json.meta ├── com.github.asus4.onnxruntime-genai ├── Editor.meta ├── Editor │ ├── OrtPostProcessBuild.cs │ ├── OrtPostProcessBuild.cs.meta │ ├── com.github.asus4.onnxruntime-genai.Editor.asmdef │ └── com.github.asus4.onnxruntime-genai.Editor.asmdef.meta ├── LICENSE ├── LICENSE.meta ├── Plugins.meta ├── Plugins │ ├── Android.meta │ ├── Android │ │ └── onnxruntime-genai.aar.meta │ ├── Linux.meta │ ├── Linux │ │ ├── x64.meta │ │ └── x64 │ │ │ └── libonnxruntime-genai.so.meta │ ├── Windows.meta │ ├── Windows │ │ ├── arm64.meta │ │ ├── arm64 │ │ │ └── onnxruntime-genai.dll.meta │ │ ├── x64.meta │ │ └── x64 │ │ │ └── onnxruntime-genai.dll.meta │ ├── macOS.meta │ └── macOS │ │ ├── arm64.meta │ │ ├── arm64 │ │ └── libonnxruntime-genai.dylib.meta │ │ ├── x64.meta │ │ └── x64 │ │ └── libonnxruntime-genai.dylib.meta ├── README.md ├── README.md.meta ├── Runtime.meta ├── Runtime │ ├── Adapters.cs │ ├── Adapters.cs.meta │ ├── Audios.cs │ ├── Audios.cs.meta │ ├── Config.cs │ ├── Config.cs.meta │ ├── Exceptions.cs │ ├── Exceptions.cs.meta │ ├── Generator.cs │ ├── Generator.cs.meta │ ├── GeneratorParams.cs │ ├── GeneratorParams.cs.meta │ ├── Images.cs │ ├── Images.cs.meta │ ├── Model.cs │ ├── Model.cs.meta │ ├── MultiModalProcessor.cs │ ├── MultiModalProcessor.cs.meta │ ├── NativeMethods.cs │ ├── NativeMethods.cs.meta │ ├── OnnxRuntimeGenAIChatClient.cs │ ├── OnnxRuntimeGenAIChatClient.cs.meta │ ├── OnnxRuntimeGenAIChatClientOptions.cs │ ├── OnnxRuntimeGenAIChatClientOptions.cs.meta │ ├── Result.cs │ ├── Result.cs.meta │ ├── Sequences.cs │ ├── Sequences.cs.meta │ ├── Tensor.cs │ ├── Tensor.cs.meta │ ├── Tokenizer.cs │ ├── Tokenizer.cs.meta │ ├── TokenizerStream.cs │ ├── TokenizerStream.cs.meta │ ├── Utils.cs │ ├── Utils.cs.meta │ ├── com.github.asus4.onnxruntime-genai.asmdef │ ├── com.github.asus4.onnxruntime-genai.asmdef.meta │ ├── onnxruntime-genai.snk │ └── onnxruntime-genai.snk.meta ├── ThirdPartyNotices.txt ├── ThirdPartyNotices.txt.meta ├── package.json └── package.json.meta ├── com.github.asus4.onnxruntime.linux-x64-gpu ├── LICENSE ├── LICENSE.meta ├── Plugins.meta ├── Plugins │ ├── Linux.meta │ └── Linux │ │ ├── x64.meta │ │ └── x64 │ │ ├── libonnxruntime_providers_cuda.so.meta │ │ ├── libonnxruntime_providers_shared.so.meta │ │ └── libonnxruntime_providers_tensorrt.so.meta ├── README.md ├── README.md.meta ├── package.json └── package.json.meta ├── com.github.asus4.onnxruntime.unity ├── Editor.meta ├── Editor │ ├── OrtImporter.cs │ ├── OrtImporter.cs.meta │ ├── com.github.asus4.onnxruntime.unity.Editor.asmdef │ └── com.github.asus4.onnxruntime.unity.Editor.asmdef.meta ├── LICENSE ├── LICENSE.meta ├── README.md ├── README.md.meta ├── Resources.meta ├── Resources │ ├── com.github.asus4.onnxruntime.unity.meta │ └── com.github.asus4.onnxruntime.unity │ │ ├── TextureToTensor.compute │ │ └── TextureToTensor.compute.meta ├── Runtime.meta ├── Runtime │ ├── AssemblyInfo.cs │ ├── AssemblyInfo.cs.meta │ ├── Detection.cs │ ├── Detection.cs.meta │ ├── ExecutionProviderOptions.cs │ ├── ExecutionProviderOptions.cs.meta │ ├── Extensions.meta │ ├── Extensions │ │ ├── AwaitableExtensions.cs │ │ ├── AwaitableExtensions.cs.meta │ │ ├── GraphicsBufferExtension.cs │ │ ├── GraphicsBufferExtension.cs.meta │ │ ├── InferenceSessionExtension.cs │ │ ├── InferenceSessionExtension.cs.meta │ │ ├── MathUtil.cs │ │ ├── MathUtil.cs.meta │ │ ├── RectExtension.cs │ │ └── RectExtension.cs.meta │ ├── FilePopupAttribute.cs │ ├── FilePopupAttribute.cs.meta │ ├── ImageInference.cs │ ├── ImageInference.cs.meta │ ├── ImageInferenceOptions.cs │ ├── ImageInferenceOptions.cs.meta │ ├── OrtAsset.cs │ ├── OrtAsset.cs.meta │ ├── OrtUnityEnv.cs │ ├── OrtUnityEnv.cs.meta │ ├── RemoteFile.cs │ ├── RemoteFile.cs.meta │ ├── TextureToTensor.cs │ ├── TextureToTensor.cs.meta │ ├── com.github.asus4.onnxruntime.unity.asmdef │ └── com.github.asus4.onnxruntime.unity.asmdef.meta ├── Tests.meta ├── Tests │ ├── MathUtilsTest.cs │ ├── MathUtilsTest.cs.meta │ ├── OrtUnityEnvTest.cs │ ├── OrtUnityEnvTest.cs.meta │ ├── com.github.asus4.onnxruntime.unity.tests.asmdef │ └── com.github.asus4.onnxruntime.unity.tests.asmdef.meta ├── package.json └── package.json.meta ├── com.github.asus4.onnxruntime.win-x64-gpu ├── LICENSE ├── LICENSE.meta ├── Plugins.meta ├── Plugins │ ├── Windows.meta │ └── Windows │ │ ├── x64.meta │ │ └── x64 │ │ ├── onnxruntime_providers_cuda.dll.meta │ │ ├── onnxruntime_providers_shared.dll.meta │ │ └── onnxruntime_providers_tensorrt.dll.meta ├── README.md ├── README.md.meta ├── package.json └── package.json.meta ├── com.github.asus4.onnxruntime ├── Editor.meta ├── Editor │ ├── OrtPostProcessBuild.cs │ ├── OrtPostProcessBuild.cs.meta │ ├── com.github.asus4.onnxruntime.Editor.asmdef │ └── com.github.asus4.onnxruntime.Editor.asmdef.meta ├── LICENSE ├── LICENSE.meta ├── Plugins.meta ├── Plugins │ ├── Android.meta │ ├── Android │ │ └── onnxruntime.aar.meta │ ├── Linux.meta │ ├── Linux │ │ ├── x64.meta │ │ └── x64 │ │ │ └── libonnxruntime.so.meta │ ├── Windows.meta │ ├── Windows │ │ ├── arm64.meta │ │ ├── arm64 │ │ │ └── onnxruntime.dll.meta │ │ ├── x64.meta │ │ ├── x64 │ │ │ └── onnxruntime.dll.meta │ │ ├── x86.meta │ │ └── x86 │ │ │ └── onnxruntime.dll.meta │ ├── macOS.meta │ └── macOS │ │ ├── arm64.meta │ │ ├── arm64 │ │ └── libonnxruntime.dylib.meta │ │ ├── x64.meta │ │ └── x64 │ │ └── libonnxruntime.dylib.meta ├── README.md ├── README.md.meta ├── Runtime.meta ├── Runtime │ ├── AssemblyInfo.shared.cs │ ├── AssemblyInfo.shared.cs.meta │ ├── DisposableNamedOnnxValue.shared.cs │ ├── DisposableNamedOnnxValue.shared.cs.meta │ ├── Exceptions.shared.cs │ ├── Exceptions.shared.cs.meta │ ├── FixedBufferOnnxValue.shared.cs │ ├── FixedBufferOnnxValue.shared.cs.meta │ ├── InferenceSession.shared.cs │ ├── InferenceSession.shared.cs.meta │ ├── ManagedProjections.shared.cs │ ├── ManagedProjections.shared.cs.meta │ ├── NamedOnnxValue.shared.cs │ ├── NamedOnnxValue.shared.cs.meta │ ├── NativeApiStatus.shared.cs │ ├── NativeApiStatus.shared.cs.meta │ ├── NativeMethods.shared.cs │ ├── NativeMethods.shared.cs.meta │ ├── NativeOnnxValueHelper.shared.cs │ ├── NativeOnnxValueHelper.shared.cs.meta │ ├── OrtAllocator.shared.cs │ ├── OrtAllocator.shared.cs.meta │ ├── OrtEnv.shared.cs │ ├── OrtEnv.shared.cs.meta │ ├── OrtFloat16.shared.cs │ ├── OrtFloat16.shared.cs.meta │ ├── OrtIoBinding.shared.cs │ ├── OrtIoBinding.shared.cs.meta │ ├── OrtLoggingLevel.shared.cs │ ├── OrtLoggingLevel.shared.cs.meta │ ├── OrtLoraAdapter.shared.cs │ ├── OrtLoraAdapter.shared.cs.meta │ ├── OrtThreadingOptions.shared.cs │ ├── OrtThreadingOptions.shared.cs.meta │ ├── OrtTypeInfo.shared.cs │ ├── OrtTypeInfo.shared.cs.meta │ ├── OrtValue.shared.cs │ ├── OrtValue.shared.cs.meta │ ├── OrtValueTensor.shared.cs │ ├── OrtValueTensor.shared.cs.meta │ ├── PrepackedWeightsContainer.shared.cs │ ├── PrepackedWeightsContainer.shared.cs.meta │ ├── ProviderOptions.shared.cs │ ├── ProviderOptions.shared.cs.meta │ ├── RunOptions.shared.cs │ ├── RunOptions.shared.cs.meta │ ├── SessionOptions.shared.cs │ ├── SessionOptions.shared.cs.meta │ ├── SessionOptionsContainer.shared.cs │ ├── SessionOptionsContainer.shared.cs.meta │ ├── ShapeUtils.shared.cs │ ├── ShapeUtils.shared.cs.meta │ ├── Tensors.meta │ ├── Tensors │ │ ├── ArrayTensorExtensions.shared.cs │ │ ├── ArrayTensorExtensions.shared.cs.meta │ │ ├── ArrayUtilities.shared.cs │ │ ├── ArrayUtilities.shared.cs.meta │ │ ├── DenseTensor.shared.cs │ │ ├── DenseTensor.shared.cs.meta │ │ ├── Tensor.shared.cs │ │ └── Tensor.shared.cs.meta │ ├── Training.meta │ ├── Training │ │ ├── CheckpointState.shared.cs │ │ ├── CheckpointState.shared.cs.meta │ │ ├── NativeTrainingMethods.shared.cs │ │ ├── NativeTrainingMethods.shared.cs.meta │ │ ├── TrainingSession.shared.cs │ │ └── TrainingSession.shared.cs.meta │ ├── com.github.asus4.onnxruntime.asmdef │ └── com.github.asus4.onnxruntime.asmdef.meta ├── ThirdPartyNotices.txt ├── ThirdPartyNotices.txt.meta ├── package.json └── package.json.meta └── scripts ├── UnityDefines.cs ├── download-onnx-extensions-libs.sh ├── download-onnx-genai-libs.sh ├── download-onnx-libs.sh └── modify-defines.sh /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | # These are supported funding model platforms 2 | 3 | github: asus4 4 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a report to help us improve 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Environment (please complete the following information):** 11 | - OS/OS Version: [e.g. iOS 11.0/Andoroid 8.1/macOS 10.15.6] 12 | - Source Version: [e.g. master/v2.2.0] 13 | - Unity Version: [e.g. Unity 2019.4.5.f1] 14 | 15 | **Describe the bug** 16 | A clear and concise description of what the bug is. 17 | 18 | **To Reproduce** 19 | Steps to reproduce the behavior: 20 | 1. Go to '...' 21 | 2. Click on '....' 22 | 3. Scroll down to '....' 23 | 4. See error 24 | 25 | **Expected behavior** 26 | A clear and concise description of what you expected to happen. 27 | 28 | **Screenshots** 29 | If applicable, add screenshots to help explain your problem. 30 | 31 | **Additional context** 32 | Add any other context about the problem and error logs here. 33 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: Suggest an idea for this project 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Is your feature request related to a problem? Please describe.** 11 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] 12 | 13 | **Describe the solution you'd like** 14 | A clear and concise description of what you want to happen. 15 | 16 | **Describe alternatives you've considered** 17 | A clear and concise description of any alternative solutions or features you've considered. 18 | 19 | **Additional context** 20 | Add any other context or screenshots about the feature request here. 21 | -------------------------------------------------------------------------------- /.github/stale.yml: -------------------------------------------------------------------------------- 1 | # Number of days of inactivity before an issue becomes stale 2 | daysUntilStale: 60 3 | # Number of days of inactivity before a stale issue is closed 4 | daysUntilClose: 7 5 | # Issues with these labels will never be considered stale 6 | exemptLabels: 7 | - pinned 8 | - security 9 | # Label to use when marking an issue as stale 10 | staleLabel: wontfix 11 | # Comment to post when marking an issue as stale. Set to `false` to disable 12 | markComment: > 13 | This issue has been automatically marked as stale because it has not had 14 | recent activity. It will be closed if no further activity occurs. Thank you 15 | for your contributions. 16 | # Comment to post when closing a stale issue. Set to `false` to disable 17 | closeComment: false 18 | -------------------------------------------------------------------------------- /.github/workflows/build-onnxruntime-extensions.yaml: -------------------------------------------------------------------------------- 1 | # Build multi-platform ONNX Runtime Extensions 2 | # 3 | # Based on onnxruntime-minimal-builder: MIT License 4 | # https://github.com/stakemura/onnxruntime-minimal-builder/blob/main/LICENSE 5 | name: Build ONNX Runtime Extensions 6 | on: 7 | workflow_dispatch: 8 | inputs: 9 | version: 10 | description: "Tag or Branch name (e.g., v0.9.0 or main)" 11 | required: false 12 | env: 13 | VERSION: ${{ github.event.inputs.version || 'main' }} 14 | ORT_VERSION: 1.17.1 15 | 16 | jobs: 17 | # Build for each platform. See example build script at 18 | # .pipelines/templates/build-package-for-{PLATFORM}.yml 19 | build: 20 | strategy: 21 | matrix: 22 | include: 23 | - artifact-name: linux-x64 24 | run-os: ubuntu-latest 25 | build-script: ./build_lib.sh --build_dir out/ --config RelWithDebInfo --parallel --cmake_extra_defines OCOS_ONNXRUNTIME_VERSION="$ORT_VERSION" 26 | artifact-path: out/RelWithDebInfo/lib/libortextensions.so 27 | - artifact-name: win-x64 28 | run-os: windows-latest 29 | build-script: cmd /c .\build_lib.bat --x64 --build_dir out --config RelWithDebInfo --parallel --cmake_generator "Visual Studio 17 2022" --cmake_extra_defines OCOS_ONNXRUNTIME_VERSION="$ORT_VERSION" 30 | artifact-path: out\RelWithDebInfo\bin\RelWithDebInfo\ortextensions.dll 31 | - artifact-name: macos-universal 32 | run-os: macos-latest 33 | build-script: ./build_lib.sh --build_dir out/ --config RelWithDebInfo --parallel --cmake_extra_defines CMAKE_OSX_ARCHITECTURES="arm64;x86_64" OCOS_ONNXRUNTIME_VERSION="$ORT_VERSION" 34 | artifact-path: out/RelWithDebInfo/lib/libortextensions.dylib 35 | runs-on: ${{ matrix.run-os }} 36 | steps: 37 | - uses: actions/checkout@v4 38 | with: 39 | repository: microsoft/onnxruntime-extensions 40 | ref: ${{ env.VERSION }} 41 | - name: Dump matrix context 42 | env: 43 | MATRIX_CONTEXT: ${{ toJSON(matrix) }} 44 | run: echo "$MATRIX_CONTEXT" > matrix.json 45 | - name: Cache build result 46 | id: cache-build-result 47 | uses: actions/cache@v4 48 | with: 49 | path: out/ 50 | key: ${{ matrix.artifact-name }}-${{ env.VERSION }}-${{ env.ORT_VERSION }}-${{ hashFiles('matrix.json') }} 51 | - name: Build ONNX Runtime Extensions 52 | if: steps.cache-build-result.outputs.cache-hit != 'true' 53 | run: | 54 | ${{ matrix.build-script }} 55 | - name: Upload build result 56 | uses: actions/upload-artifact@v4 57 | with: 58 | name: onnxruntime-extensions-${{ matrix.artifact-name }}-${{ env.VERSION }} 59 | path: ${{ matrix.artifact-path }} 60 | retention-days: 7 61 | -------------------------------------------------------------------------------- /.github/workflows/publish-packages.yml: -------------------------------------------------------------------------------- 1 | name: Publish UPM packages 2 | on: 3 | release: 4 | types: [published] 5 | workflow_dispatch: 6 | permissions: 7 | contents: write 8 | env: 9 | ORT_VERSION: 1.21.0 10 | ORT_EXTENSIONS_VERSION: 0.14.0 11 | ORT_GENAI_VERSION: 0.7.0 12 | # Dry-run on workflow_dispatch 13 | NPM_OPTS: ${{ github.event_name == 'workflow_dispatch' && '--dry-run' || '' }} 14 | jobs: 15 | npm-publish: 16 | runs-on: ubuntu-latest 17 | steps: 18 | - uses: actions/checkout@v4 19 | - uses: actions/setup-node@v4 20 | with: 21 | registry-url: 'https://registry.npmjs.org' 22 | - name: Cache .tmp folder 23 | uses: actions/cache@v4 24 | id: tmp-cache 25 | with: 26 | path: .tmp 27 | key: tmp-ort${{ env.ORT_VERSION }}-ext${{ env.ORT_EXTENSIONS_VERSION }}-${{ hashFiles('scripts/*') }} 28 | - name: Download ONNX libraries 29 | run: | 30 | ./scripts/download-onnx-libs.sh ${{ env.ORT_VERSION }} 31 | ./scripts/download-onnx-extensions-libs.sh ${{ env.ORT_EXTENSIONS_VERSION }} 32 | ./scripts/download-onnx-genai-libs.sh ${{ env.ORT_GENAI_VERSION }} 33 | - name: Publish all NPM packages 34 | run: | 35 | publish_npm() { 36 | cd $1 37 | cp ../README.md . 38 | npm publish ${{ env.NPM_OPTS }} 39 | cd - > /dev/null 40 | } 41 | publish_npm com.github.asus4.onnxruntime 42 | publish_npm com.github.asus4.onnxruntime.unity 43 | publish_npm com.github.asus4.onnxruntime-extensions 44 | publish_npm com.github.asus4.onnxruntime-genai 45 | # publish_npm com.github.asus4.onnxruntime.linux-x64-gpu 46 | # publish_npm com.github.asus4.onnxruntime.win-x64-gpu 47 | env: 48 | NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} 49 | # Upload packages to GitHub release page 50 | - name: Zip folders for GitHub release 51 | if: startsWith(github.ref, 'refs/tags/') 52 | run: | 53 | zip -r com.github.asus4.onnxruntime-${{ github.ref_name }}.zip com.github.asus4.onnxruntime 54 | zip -r com.github.asus4.onnxruntime.unity-${{ github.ref_name }}.zip com.github.asus4.onnxruntime.unity 55 | zip -r com.github.asus4.onnxruntime-extensions-${{ github.ref_name }}.zip com.github.asus4.onnxruntime-extensions 56 | zip -r com.github.asus4.onnxruntime-genai-${{ github.ref_name }}.zip com.github.asus4.onnxruntime-genai 57 | zip -r com.github.asus4.onnxruntime.linux-x64-gpu-${{ github.ref_name }}.zip com.github.asus4.onnxruntime.linux-x64-gpu 58 | zip -r com.github.asus4.onnxruntime.win-x64-gpu-${{ github.ref_name }}.zip com.github.asus4.onnxruntime.win-x64-gpu 59 | - name: Upload release assets 60 | uses: softprops/action-gh-release@v2 61 | if: startsWith(github.ref, 'refs/tags/') 62 | with: 63 | files: | 64 | com.github.asus4.onnxruntime-${{ github.ref_name }}.zip 65 | com.github.asus4.onnxruntime.unity-${{ github.ref_name }}.zip 66 | com.github.asus4.onnxruntime-extensions-${{ github.ref_name }}.zip 67 | com.github.asus4.onnxruntime-genai-${{ github.ref_name }}.zip 68 | com.github.asus4.onnxruntime.linux-x64-gpu-${{ github.ref_name }}.zip 69 | com.github.asus4.onnxruntime.win-x64-gpu-${{ github.ref_name }}.zip 70 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Ignore native libraries 2 | *.aar 3 | *.dylib 4 | *.dll 5 | *.framework 6 | *.so 7 | *.xcframework 8 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # ONNX Runtime Plugin for Unity 2 | 3 | [![upm](https://img.shields.io/npm/v/com.github.asus4.onnxruntime?label=upm)](https://www.npmjs.com/package/com.github.asus4.onnxruntime) 4 | 5 | Pre-built ONNX Runtime libraries for Unity. 6 | 7 | ## [See Examples](https://github.com/asus4/onnxruntime-unity-examples) 8 | 9 | [https://github.com/asus4/onnxruntime-unity-examples](https://github.com/asus4/onnxruntime-unity-examples) 10 | 11 | **Yolox-Nano** 12 | 13 | 14 | 15 | **NanoSAM** 16 | 17 | 18 | 19 | **Yolo11 Seg** 20 | 21 | 22 | 23 | ## Tested environment 24 | 25 | - Unity: 6000.0.43f1 (LTS) 26 | - ONNX Runtime: [1.21.0](https://github.com/microsoft/onnxruntime/releases/tag/v1.21.0) 27 | - ONNX Runtime Extensions: [0.14.0](https://github.com/microsoft/onnxruntime-extensions/releases/tag/v0.14.0) 28 | 29 | ### Execution Providers & Extensions 30 | 31 | #### [Execution Providers](https://onnxruntime.ai/docs/execution-providers/) 32 | 33 | Execution Providers are hardware acceleration libraries for each platform. See [official docs](https://onnxruntime.ai/docs/execution-providers/) for more details. 34 | 35 | | Platform | CPU | CoreML | NNAPI | CUDA | TensorRT | DirectML | XNNPACK | 36 | | --- | --- | --- | --- | --- | --- | --- | --- | 37 | | macOS | :white_check_mark: | :white_check_mark: | | | | | | 38 | | iOS | :white_check_mark: | :white_check_mark: | | | | | :construction: | 39 | | Android | :white_check_mark: | | :white_check_mark: | | | | :construction: | 40 | | Windows | :white_check_mark: | | | :construction: | :construction: | :white_check_mark: | | 41 | | Linux | :white_check_mark: | | | :construction: | :construction: | | | 42 | 43 | #### [ONNX Runtime Extensions](https://github.com/microsoft/onnxruntime-extensions) 44 | 45 | ONNX Runtime Extensions are a set of pre/post-processing. 46 | 47 | | Platform | Extensions | 48 | | --- | --- | 49 | | macOS | :construction: | 50 | | iOS | :construction: | 51 | | Android | :construction: | 52 | | Windows | :construction: | 53 | | Linux | :construction: | 54 | 55 | :white_check_mark: : Supported in Unity Core library 56 | :construction: : Experimental Preview 57 | 58 | ## How to Install 59 | 60 | Pre-built libraries are available on [NPM](https://www.npmjs.com/package/com.github.asus4.onnxruntime). Add the following `scopedRegistries` and `dependencies` in `Packages/manifest.json`. 61 | 62 | ```json 63 | "scopedRegistries": [ 64 | { 65 | "name": "NPM", 66 | "url": "https://registry.npmjs.com", 67 | "scopes": [ 68 | "com.github.asus4" 69 | ] 70 | } 71 | ] 72 | "dependencies": { 73 | "com.github.asus4.onnxruntime": "0.4.0", 74 | "com.github.asus4.onnxruntime.unity": "0.4.0", 75 | "com.github.asus4.onnxruntime.win-x64-gpu": "0.4.0", 76 | "com.github.asus4.onnxruntime-extensions": "0.4.0", 77 | ... other dependencies 78 | } 79 | ``` 80 | 81 | ### What is included in each package 82 | 83 | - `com.github.asus4.onnxruntime` : Core library 84 | - CPU provider for all platforms 85 | - GPU provider for iOS, Android, macOS and Windows(only DirectML) 86 | - `com.github.asus4.onnxruntime.unity` : (Optional) Utilities for Unity 87 | - `com.github.asus4.onnxruntime.win-x64-gpu` : (Optional) GPU provider for Windows 88 | - `com.github.asus4.onnxruntime.linux-x64-gpu` : (Optional) GPU provider for Linux 89 | - `com.github.asus4.onnxruntime-extensions` : (Optional) ONNX Runtime Extensions 90 | -------------------------------------------------------------------------------- /com.github.asus4.onnxruntime-extensions/Editor.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ebac674ad35484e75b88bdd6272d0ae3 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /com.github.asus4.onnxruntime-extensions/Editor/OrtPostProcessBuild.cs: -------------------------------------------------------------------------------- 1 | using UnityEditor; 2 | using UnityEditor.Build; 3 | using UnityEditor.Build.Reporting; 4 | 5 | #if UNITY_IOS 6 | using UnityEditor.iOS.Xcode; 7 | #endif // UNITY_IOS 8 | 9 | namespace Microsoft.ML.OnnxRuntime.Extensions.Editor 10 | { 11 | using CorePostProcessBuild = Microsoft.ML.OnnxRuntime.Editor.OrtPostProcessBuild; 12 | 13 | /// 14 | /// Custom post-process build for ONNX Runtime Extensions 15 | /// 16 | public class OrtPostProcessBuild : IPostprocessBuildWithReport 17 | { 18 | private const string PACKAGE_PATH = "Packages/com.github.asus4.onnxruntime-extensions"; 19 | private const string FRAMEWORK_SRC = "Plugins/iOS~/onnxruntime_extensions.xcframework"; 20 | private const string FRAMEWORK_DST = "Libraries/onnxruntime_extensions.xcframework"; 21 | 22 | public int callbackOrder => 0; 23 | 24 | public void OnPostprocessBuild(BuildReport report) 25 | { 26 | switch (report.summary.platform) 27 | { 28 | case BuildTarget.iOS: 29 | #if UNITY_IOS 30 | CorePostProcessBuild.CopyOrtXCFramework(report, 31 | PACKAGE_PATH, 32 | FRAMEWORK_SRC, 33 | FRAMEWORK_DST); 34 | AddIOSDependentFrameworks(report); 35 | #endif // UNITY_IOS 36 | break; 37 | } 38 | } 39 | 40 | #if UNITY_IOS 41 | 42 | static void AddFrameworkIfNotExist(PBXProject proj, string targetGuid, string frameworkName, bool weak) 43 | { 44 | if (proj.ContainsFramework(targetGuid, frameworkName)) 45 | { 46 | return; 47 | } 48 | proj.AddFrameworkToProject(targetGuid, frameworkName, weak); 49 | } 50 | 51 | static void AddIOSDependentFrameworks(BuildReport report) 52 | { 53 | string pbxProjectPath = PBXProject.GetPBXProjectPath(report.summary.outputPath); 54 | PBXProject pbxProject = new(); 55 | pbxProject.ReadFromFile(pbxProjectPath); 56 | 57 | string frameworkGuid = pbxProject.GetUnityFrameworkTargetGuid(); 58 | 59 | AddFrameworkIfNotExist(pbxProject, frameworkGuid, "ImageIO.framework", false); 60 | AddFrameworkIfNotExist(pbxProject, frameworkGuid, "MobileCoreServices.framework", false); 61 | 62 | pbxProject.WriteToFile(pbxProjectPath); 63 | } 64 | #endif // UNITY_IOS 65 | 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /com.github.asus4.onnxruntime-extensions/Editor/OrtPostProcessBuild.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 8a4e96195228540f3bf83cb8063b741a 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /com.github.asus4.onnxruntime-extensions/Editor/com.github.asus4.onnxruntime-extensions.Editor.asmdef: -------------------------------------------------------------------------------- 1 | { 2 | "name": "com.github.asus4.onnxruntime-extensions.Editor", 3 | "rootNamespace": "", 4 | "references": [ 5 | "GUID:0c2a693589505475cb8d7d2c2778d73c" 6 | ], 7 | "includePlatforms": [ 8 | "Editor" 9 | ], 10 | "excludePlatforms": [], 11 | "allowUnsafeCode": false, 12 | "overrideReferences": false, 13 | "precompiledReferences": [], 14 | "autoReferenced": true, 15 | "defineConstraints": [], 16 | "versionDefines": [], 17 | "noEngineReferences": false 18 | } -------------------------------------------------------------------------------- /com.github.asus4.onnxruntime-extensions/Editor/com.github.asus4.onnxruntime-extensions.Editor.asmdef.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d7a21397510974e9e97c9f1209d07679 3 | AssemblyDefinitionImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /com.github.asus4.onnxruntime-extensions/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) Microsoft Corporation. 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE 22 | -------------------------------------------------------------------------------- /com.github.asus4.onnxruntime-extensions/LICENSE.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 131c74ca4b2ec47639d663d79b430ec2 3 | DefaultImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /com.github.asus4.onnxruntime-extensions/Plugins.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 8cbbdb590f472448089b5163fcceff3c 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /com.github.asus4.onnxruntime-extensions/Plugins/Android.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4b71741a71a7f48e2a5fec507fd13198 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /com.github.asus4.onnxruntime-extensions/Plugins/Android/onnxruntime-extensions.aar.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 97f5fa21678a4486c89d9eb0140741bf 3 | PluginImporter: 4 | externalObjects: {} 5 | serializedVersion: 3 6 | iconMap: {} 7 | executionOrder: {} 8 | defineConstraints: [] 9 | isPreloaded: 0 10 | isOverridable: 1 11 | isExplicitlyReferenced: 0 12 | validateReferences: 1 13 | platformData: 14 | Android: 15 | enabled: 1 16 | settings: 17 | AndroidLibraryDependee: UnityLibrary 18 | AndroidSharedLibraryType: Executable 19 | CPU: ARMv7 20 | Any: 21 | enabled: 0 22 | settings: 23 | Exclude Android: 0 24 | Exclude Editor: 1 25 | Exclude Linux64: 1 26 | Exclude OSXUniversal: 1 27 | Exclude Win: 1 28 | Exclude Win64: 1 29 | Exclude iOS: 1 30 | Editor: 31 | enabled: 0 32 | settings: 33 | CPU: AnyCPU 34 | DefaultValueInitialized: true 35 | OS: AnyOS 36 | Linux64: 37 | enabled: 0 38 | settings: 39 | CPU: x86_64 40 | OSXUniversal: 41 | enabled: 0 42 | settings: 43 | CPU: None 44 | Win: 45 | enabled: 0 46 | settings: 47 | CPU: x86 48 | Win64: 49 | enabled: 0 50 | settings: 51 | CPU: None 52 | iOS: 53 | enabled: 0 54 | settings: 55 | AddToEmbeddedBinaries: false 56 | CPU: AnyCPU 57 | CompileFlags: 58 | FrameworkDependencies: 59 | userData: 60 | assetBundleName: 61 | assetBundleVariant: 62 | -------------------------------------------------------------------------------- /com.github.asus4.onnxruntime-extensions/Plugins/Linux.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 6c44c56785d884c8a9b5ecdb47a0de33 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /com.github.asus4.onnxruntime-extensions/Plugins/Linux/arm64.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 1952f44f06e9f4b9b8e5e89248090c59 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /com.github.asus4.onnxruntime-extensions/Plugins/Linux/arm64/libortextensions.so.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 3971a95c45e984ac8843a5781291f603 3 | PluginImporter: 4 | externalObjects: {} 5 | serializedVersion: 3 6 | iconMap: {} 7 | executionOrder: {} 8 | defineConstraints: [] 9 | isPreloaded: 0 10 | isOverridable: 1 11 | isExplicitlyReferenced: 0 12 | validateReferences: 1 13 | platformData: 14 | Android: 15 | enabled: 0 16 | settings: 17 | AndroidLibraryDependee: UnityLibrary 18 | AndroidSharedLibraryType: Executable 19 | CPU: ARM64 20 | Is16KbAligned: true 21 | Any: 22 | enabled: 0 23 | settings: 24 | Exclude Android: 1 25 | Exclude Editor: 0 26 | Exclude Linux64: 0 27 | Exclude OSXUniversal: 1 28 | Exclude Win: 0 29 | Exclude Win64: 0 30 | Exclude iOS: 1 31 | Editor: 32 | enabled: 1 33 | settings: 34 | CPU: AnyCPU 35 | DefaultValueInitialized: true 36 | OS: Linux 37 | Linux64: 38 | enabled: 1 39 | settings: 40 | CPU: x86_64 41 | OSXUniversal: 42 | enabled: 0 43 | settings: 44 | CPU: None 45 | Win: 46 | enabled: 1 47 | settings: 48 | CPU: x86 49 | Win64: 50 | enabled: 1 51 | settings: 52 | CPU: None 53 | iOS: 54 | enabled: 0 55 | settings: 56 | AddToEmbeddedBinaries: false 57 | CPU: AnyCPU 58 | CompileFlags: 59 | FrameworkDependencies: 60 | userData: 61 | assetBundleName: 62 | assetBundleVariant: 63 | -------------------------------------------------------------------------------- /com.github.asus4.onnxruntime-extensions/Plugins/Linux/x64.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 804dca44c626044dab63b0955a6d13f5 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /com.github.asus4.onnxruntime-extensions/Plugins/Linux/x64/libortextensions.so.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 1d64ea97642e949989d0bdeb8a84fd9a 3 | PluginImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | iconMap: {} 7 | executionOrder: {} 8 | defineConstraints: [] 9 | isPreloaded: 0 10 | isOverridable: 1 11 | isExplicitlyReferenced: 0 12 | validateReferences: 1 13 | platformData: 14 | - first: 15 | : Any 16 | second: 17 | enabled: 0 18 | settings: 19 | Exclude Android: 1 20 | Exclude Editor: 0 21 | Exclude Linux64: 0 22 | Exclude OSXUniversal: 1 23 | Exclude Win: 0 24 | Exclude Win64: 0 25 | Exclude iOS: 1 26 | - first: 27 | Android: Android 28 | second: 29 | enabled: 0 30 | settings: 31 | AndroidSharedLibraryType: Executable 32 | CPU: ARMv7 33 | - first: 34 | Any: 35 | second: 36 | enabled: 0 37 | settings: {} 38 | - first: 39 | Editor: Editor 40 | second: 41 | enabled: 1 42 | settings: 43 | CPU: x86_64 44 | DefaultValueInitialized: true 45 | OS: Linux 46 | - first: 47 | Standalone: Linux64 48 | second: 49 | enabled: 1 50 | settings: 51 | CPU: AnyCPU 52 | - first: 53 | Standalone: OSXUniversal 54 | second: 55 | enabled: 0 56 | settings: 57 | CPU: AnyCPU 58 | - first: 59 | Standalone: Win 60 | second: 61 | enabled: 1 62 | settings: 63 | CPU: AnyCPU 64 | - first: 65 | Standalone: Win64 66 | second: 67 | enabled: 1 68 | settings: 69 | CPU: AnyCPU 70 | - first: 71 | iPhone: iOS 72 | second: 73 | enabled: 0 74 | settings: 75 | AddToEmbeddedBinaries: false 76 | CPU: AnyCPU 77 | CompileFlags: 78 | FrameworkDependencies: 79 | userData: 80 | assetBundleName: 81 | assetBundleVariant: 82 | -------------------------------------------------------------------------------- /com.github.asus4.onnxruntime-extensions/Plugins/Windows.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b33e4d25d4963428a8595a1769b30a95 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /com.github.asus4.onnxruntime-extensions/Plugins/Windows/arm64.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 341d451358a3247d6ab68b1d957b4f6c 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /com.github.asus4.onnxruntime-extensions/Plugins/Windows/arm64/ortextensions.dll.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 84a2dfa9bd7af4157bcdae55af4cd395 3 | PluginImporter: 4 | externalObjects: {} 5 | serializedVersion: 3 6 | iconMap: {} 7 | executionOrder: {} 8 | defineConstraints: [] 9 | isPreloaded: 0 10 | isOverridable: 1 11 | isExplicitlyReferenced: 0 12 | validateReferences: 1 13 | platformData: 14 | Android: 15 | enabled: 0 16 | settings: 17 | AndroidLibraryDependee: UnityLibrary 18 | AndroidSharedLibraryType: Executable 19 | CPU: ARMv7 20 | Any: 21 | enabled: 0 22 | settings: 23 | Exclude Android: 1 24 | Exclude Editor: 0 25 | Exclude Linux64: 1 26 | Exclude OSXUniversal: 1 27 | Exclude Win: 1 28 | Exclude Win64: 0 29 | Exclude iOS: 1 30 | Editor: 31 | enabled: 1 32 | settings: 33 | CPU: ARM64 34 | DefaultValueInitialized: true 35 | OS: Windows 36 | Linux64: 37 | enabled: 0 38 | settings: 39 | CPU: x86_64 40 | OSXUniversal: 41 | enabled: 0 42 | settings: 43 | CPU: None 44 | Win: 45 | enabled: 0 46 | settings: 47 | CPU: None 48 | Win64: 49 | enabled: 1 50 | settings: 51 | CPU: ARM64 52 | WindowsStoreApps: 53 | enabled: 0 54 | settings: 55 | CPU: ARM64 56 | iOS: 57 | enabled: 0 58 | settings: 59 | AddToEmbeddedBinaries: false 60 | CPU: AnyCPU 61 | CompileFlags: 62 | FrameworkDependencies: 63 | userData: 64 | assetBundleName: 65 | assetBundleVariant: 66 | -------------------------------------------------------------------------------- /com.github.asus4.onnxruntime-extensions/Plugins/Windows/x64.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 12568e413154d4afa9beec27186bfc86 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /com.github.asus4.onnxruntime-extensions/Plugins/Windows/x64/ortextensions.dll.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c4e08fa4b76c74ed5a3b1f44b7cbedb6 3 | PluginImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | iconMap: {} 7 | executionOrder: {} 8 | defineConstraints: [] 9 | isPreloaded: 0 10 | isOverridable: 1 11 | isExplicitlyReferenced: 0 12 | validateReferences: 1 13 | platformData: 14 | - first: 15 | : Any 16 | second: 17 | enabled: 0 18 | settings: 19 | Exclude Android: 1 20 | Exclude Editor: 0 21 | Exclude Linux64: 0 22 | Exclude OSXUniversal: 0 23 | Exclude Win: 0 24 | Exclude Win64: 0 25 | Exclude iOS: 1 26 | - first: 27 | Android: Android 28 | second: 29 | enabled: 0 30 | settings: 31 | AndroidSharedLibraryType: Executable 32 | CPU: ARMv7 33 | - first: 34 | Any: 35 | second: 36 | enabled: 0 37 | settings: {} 38 | - first: 39 | Editor: Editor 40 | second: 41 | enabled: 1 42 | settings: 43 | CPU: x86_64 44 | DefaultValueInitialized: true 45 | OS: Windows 46 | - first: 47 | Standalone: Linux64 48 | second: 49 | enabled: 1 50 | settings: 51 | CPU: None 52 | - first: 53 | Standalone: OSXUniversal 54 | second: 55 | enabled: 1 56 | settings: 57 | CPU: None 58 | - first: 59 | Standalone: Win 60 | second: 61 | enabled: 1 62 | settings: 63 | CPU: None 64 | - first: 65 | Standalone: Win64 66 | second: 67 | enabled: 1 68 | settings: 69 | CPU: None 70 | - first: 71 | iPhone: iOS 72 | second: 73 | enabled: 0 74 | settings: 75 | AddToEmbeddedBinaries: false 76 | CPU: AnyCPU 77 | CompileFlags: 78 | FrameworkDependencies: 79 | userData: 80 | assetBundleName: 81 | assetBundleVariant: 82 | -------------------------------------------------------------------------------- /com.github.asus4.onnxruntime-extensions/Plugins/macOS.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 11226771a36d94169903f33847ac962f 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /com.github.asus4.onnxruntime-extensions/Plugins/macOS/arm64.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: fae3c7f4174da46dc84d3b1094812a5f 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /com.github.asus4.onnxruntime-extensions/Plugins/macOS/arm64/libortextensions.dylib.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 48a55e50530a74649bcbd9770aeff059 3 | PluginImporter: 4 | externalObjects: {} 5 | serializedVersion: 3 6 | iconMap: {} 7 | executionOrder: {} 8 | defineConstraints: [] 9 | isPreloaded: 0 10 | isOverridable: 1 11 | isExplicitlyReferenced: 0 12 | validateReferences: 1 13 | platformData: 14 | Android: 15 | enabled: 0 16 | settings: 17 | AndroidLibraryDependee: UnityLibrary 18 | AndroidSharedLibraryType: Executable 19 | CPU: ARMv7 20 | Any: 21 | enabled: 0 22 | settings: 23 | Exclude Android: 1 24 | Exclude Editor: 0 25 | Exclude Linux64: 1 26 | Exclude OSXUniversal: 0 27 | Exclude Win: 1 28 | Exclude Win64: 1 29 | Exclude iOS: 1 30 | Editor: 31 | enabled: 1 32 | settings: 33 | CPU: ARM64 34 | DefaultValueInitialized: true 35 | OS: OSX 36 | Linux64: 37 | enabled: 0 38 | settings: 39 | CPU: x86_64 40 | OSXUniversal: 41 | enabled: 1 42 | settings: 43 | CPU: ARM64 44 | Win: 45 | enabled: 0 46 | settings: 47 | CPU: x86 48 | Win64: 49 | enabled: 0 50 | settings: 51 | CPU: None 52 | iOS: 53 | enabled: 0 54 | settings: 55 | AddToEmbeddedBinaries: false 56 | CPU: AnyCPU 57 | CompileFlags: 58 | FrameworkDependencies: 59 | userData: 60 | assetBundleName: 61 | assetBundleVariant: 62 | -------------------------------------------------------------------------------- /com.github.asus4.onnxruntime-extensions/Plugins/macOS/x64.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 562fea4d67350414db7b9d4df2a21afe 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /com.github.asus4.onnxruntime-extensions/Plugins/macOS/x64/libortextensions.dylib.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 69d0102e7ed1e414da1c3ab43927960d 3 | PluginImporter: 4 | externalObjects: {} 5 | serializedVersion: 3 6 | iconMap: {} 7 | executionOrder: {} 8 | defineConstraints: [] 9 | isPreloaded: 0 10 | isOverridable: 1 11 | isExplicitlyReferenced: 0 12 | validateReferences: 1 13 | platformData: 14 | Android: 15 | enabled: 0 16 | settings: 17 | AndroidLibraryDependee: UnityLibrary 18 | AndroidSharedLibraryType: Executable 19 | CPU: ARMv7 20 | Any: 21 | enabled: 0 22 | settings: 23 | Exclude Android: 1 24 | Exclude Editor: 0 25 | Exclude Linux64: 1 26 | Exclude OSXUniversal: 0 27 | Exclude Win: 1 28 | Exclude Win64: 1 29 | Exclude iOS: 1 30 | Editor: 31 | enabled: 1 32 | settings: 33 | CPU: x86_64 34 | DefaultValueInitialized: true 35 | OS: OSX 36 | Linux64: 37 | enabled: 0 38 | settings: 39 | CPU: x86_64 40 | OSXUniversal: 41 | enabled: 1 42 | settings: 43 | CPU: x86_64 44 | Win: 45 | enabled: 0 46 | settings: 47 | CPU: x86 48 | Win64: 49 | enabled: 0 50 | settings: 51 | CPU: None 52 | iOS: 53 | enabled: 0 54 | settings: 55 | AddToEmbeddedBinaries: false 56 | CPU: AnyCPU 57 | CompileFlags: 58 | FrameworkDependencies: 59 | userData: 60 | assetBundleName: 61 | assetBundleVariant: 62 | -------------------------------------------------------------------------------- /com.github.asus4.onnxruntime-extensions/README.md: -------------------------------------------------------------------------------- 1 | # ONNX Runtime Plugin for Unity 2 | -------------------------------------------------------------------------------- /com.github.asus4.onnxruntime-extensions/README.md.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 15eb5ba0a9e154878815faf701437d07 3 | TextScriptImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /com.github.asus4.onnxruntime-extensions/ThirdPartyNotices.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/asus4/onnxruntime-unity/6ce2c8afa8cc60c63593ba409d828b26bf1184fc/com.github.asus4.onnxruntime-extensions/ThirdPartyNotices.txt -------------------------------------------------------------------------------- /com.github.asus4.onnxruntime-extensions/ThirdPartyNotices.txt.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4cf9e87af7a9846fa9a8f28d1c46efa4 3 | TextScriptImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /com.github.asus4.onnxruntime-extensions/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "com.github.asus4.onnxruntime-extensions", 3 | "version": "0.4.0", 4 | "displayName": "ONNX Runtime Extensions", 5 | "description": "ONNX Runtime Extensions for Unity", 6 | "keywords": [ 7 | "unity", 8 | "onnxruntime" 9 | ], 10 | "unity": "2022.3", 11 | "unityRelease": "0f1", 12 | "dependencies": { 13 | "com.github.asus4.onnxruntime": "0.4.0" 14 | }, 15 | "repository": { 16 | "type": "git", 17 | "repository": "https://github.com/asus4/onnxruntime-unity.git" 18 | }, 19 | "documentationUrl": "https://github.com/asus4/onnxruntime-unity", 20 | "changelogUrl": "https://github.com/asus4/onnxruntime-unity/releases", 21 | "licensesUrl": "https://github.com/asus4/onnxruntime-unity/blob/main/com.github.asus4.onnxruntime-extensions/LICENSE", 22 | "author": { 23 | "name": "Koki Ibukuro", 24 | "url": "https://github.com/asus4" 25 | } 26 | } -------------------------------------------------------------------------------- /com.github.asus4.onnxruntime-extensions/package.json.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 2cd64285d6cfb4e2fba57688262c7b48 3 | PackageManifestImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /com.github.asus4.onnxruntime-genai/Editor.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: fb8f0eaab2f374f5199265f0a7465b96 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /com.github.asus4.onnxruntime-genai/Editor/OrtPostProcessBuild.cs: -------------------------------------------------------------------------------- 1 | using UnityEditor; 2 | using UnityEditor.Build; 3 | using UnityEditor.Build.Reporting; 4 | 5 | namespace Microsoft.ML.OnnxRuntime.GenAI.Editor 6 | { 7 | using CorePostProcessBuild = Microsoft.ML.OnnxRuntime.Editor.OrtPostProcessBuild; 8 | 9 | /// 10 | /// Custom post-process build for ONNX Runtime GenAI 11 | /// 12 | public class OrtPostProcessBuild : IPostprocessBuildWithReport 13 | { 14 | private const string PACKAGE_PATH = "Packages/com.github.asus4.onnxruntime-genai"; 15 | private const string FRAMEWORK_SRC = "Plugins/iOS~/onnxruntime-genai.xcframework"; 16 | private const string FRAMEWORK_DST = "Libraries/onnxruntime-genai.xcframework"; 17 | 18 | public int callbackOrder => 0; 19 | 20 | public void OnPostprocessBuild(BuildReport report) 21 | { 22 | switch (report.summary.platform) 23 | { 24 | case BuildTarget.iOS: 25 | CorePostProcessBuild.CopyOrtXCFramework(report, 26 | PACKAGE_PATH, 27 | FRAMEWORK_SRC, 28 | FRAMEWORK_DST); 29 | break; 30 | } 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /com.github.asus4.onnxruntime-genai/Editor/OrtPostProcessBuild.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 6927b7508f22f456fbdb10ee8ae6c814 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /com.github.asus4.onnxruntime-genai/Editor/com.github.asus4.onnxruntime-genai.Editor.asmdef: -------------------------------------------------------------------------------- 1 | { 2 | "name": "com.github.asus4.onnxruntime-genai.Editor", 3 | "rootNamespace": "", 4 | "references": [ 5 | "GUID:0c2a693589505475cb8d7d2c2778d73c" 6 | ], 7 | "includePlatforms": [ 8 | "Editor" 9 | ], 10 | "excludePlatforms": [], 11 | "allowUnsafeCode": false, 12 | "overrideReferences": false, 13 | "precompiledReferences": [], 14 | "autoReferenced": true, 15 | "defineConstraints": [], 16 | "versionDefines": [], 17 | "noEngineReferences": false 18 | } -------------------------------------------------------------------------------- /com.github.asus4.onnxruntime-genai/Editor/com.github.asus4.onnxruntime-genai.Editor.asmdef.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 0d59e87729c65406499d520431148840 3 | AssemblyDefinitionImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /com.github.asus4.onnxruntime-genai/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) Microsoft Corporation. 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE 22 | -------------------------------------------------------------------------------- /com.github.asus4.onnxruntime-genai/LICENSE.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 1c6d9b26b7dd046ffa106465fd2d1fe9 3 | DefaultImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /com.github.asus4.onnxruntime-genai/Plugins.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 5dfbbc11e8b76430ca27b2689a17ce5b 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /com.github.asus4.onnxruntime-genai/Plugins/Android.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 3593c549f5fcd42e68e54d296f1aa792 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /com.github.asus4.onnxruntime-genai/Plugins/Android/onnxruntime-genai.aar.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 49e24f0f37b6d4bfd86039d802163b8f 3 | PluginImporter: 4 | externalObjects: {} 5 | serializedVersion: 3 6 | iconMap: {} 7 | executionOrder: {} 8 | defineConstraints: [] 9 | isPreloaded: 0 10 | isOverridable: 1 11 | isExplicitlyReferenced: 0 12 | validateReferences: 1 13 | platformData: 14 | Android: 15 | enabled: 1 16 | settings: 17 | AndroidLibraryDependee: UnityLibrary 18 | AndroidSharedLibraryType: Executable 19 | CPU: ARMv7 20 | Any: 21 | enabled: 0 22 | settings: 23 | Exclude Android: 0 24 | Exclude Editor: 1 25 | Exclude Linux64: 1 26 | Exclude OSXUniversal: 1 27 | Exclude Win: 1 28 | Exclude Win64: 1 29 | Exclude iOS: 1 30 | Editor: 31 | enabled: 0 32 | settings: 33 | CPU: AnyCPU 34 | DefaultValueInitialized: true 35 | OS: AnyOS 36 | Linux64: 37 | enabled: 0 38 | settings: 39 | CPU: x86_64 40 | OSXUniversal: 41 | enabled: 0 42 | settings: 43 | CPU: None 44 | Win: 45 | enabled: 0 46 | settings: 47 | CPU: x86 48 | Win64: 49 | enabled: 0 50 | settings: 51 | CPU: None 52 | iOS: 53 | enabled: 0 54 | settings: 55 | AddToEmbeddedBinaries: false 56 | CPU: AnyCPU 57 | CompileFlags: 58 | FrameworkDependencies: 59 | userData: 60 | assetBundleName: 61 | assetBundleVariant: 62 | -------------------------------------------------------------------------------- /com.github.asus4.onnxruntime-genai/Plugins/Linux.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 904327e8dbf2c42a081271d0f4fa3821 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /com.github.asus4.onnxruntime-genai/Plugins/Linux/x64.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: dffeb0578bec541beb34004016588746 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /com.github.asus4.onnxruntime-genai/Plugins/Linux/x64/libonnxruntime-genai.so.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 394c71182cdca4ed5bb8a043f45f802c 3 | PluginImporter: 4 | externalObjects: {} 5 | serializedVersion: 3 6 | iconMap: {} 7 | executionOrder: {} 8 | defineConstraints: [] 9 | isPreloaded: 0 10 | isOverridable: 1 11 | isExplicitlyReferenced: 0 12 | validateReferences: 1 13 | platformData: 14 | Android: 15 | enabled: 0 16 | settings: 17 | AndroidLibraryDependee: UnityLibrary 18 | AndroidSharedLibraryType: Executable 19 | CPU: X86_64 20 | Is16KbAligned: false 21 | Any: 22 | enabled: 0 23 | settings: 24 | Exclude Android: 1 25 | Exclude Editor: 0 26 | Exclude Linux64: 0 27 | Exclude OSXUniversal: 1 28 | Exclude Win: 0 29 | Exclude Win64: 0 30 | Exclude iOS: 1 31 | Editor: 32 | enabled: 1 33 | settings: 34 | CPU: x86_64 35 | DefaultValueInitialized: true 36 | OS: Linux 37 | Linux64: 38 | enabled: 1 39 | settings: 40 | CPU: x86_64 41 | OSXUniversal: 42 | enabled: 0 43 | settings: 44 | CPU: None 45 | Win: 46 | enabled: 1 47 | settings: 48 | CPU: None 49 | Win64: 50 | enabled: 1 51 | settings: 52 | CPU: None 53 | iOS: 54 | enabled: 0 55 | settings: 56 | AddToEmbeddedBinaries: false 57 | CPU: AnyCPU 58 | CompileFlags: 59 | FrameworkDependencies: 60 | userData: 61 | assetBundleName: 62 | assetBundleVariant: 63 | -------------------------------------------------------------------------------- /com.github.asus4.onnxruntime-genai/Plugins/Windows.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 3ed991b3d485940f8867c345daf59b66 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /com.github.asus4.onnxruntime-genai/Plugins/Windows/arm64.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f951aa2544cd5447eb94dce678a84e94 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /com.github.asus4.onnxruntime-genai/Plugins/Windows/arm64/onnxruntime-genai.dll.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: cdd7a90847c7d4637915dc227c79b139 3 | PluginImporter: 4 | externalObjects: {} 5 | serializedVersion: 3 6 | iconMap: {} 7 | executionOrder: {} 8 | defineConstraints: [] 9 | isPreloaded: 0 10 | isOverridable: 1 11 | isExplicitlyReferenced: 0 12 | validateReferences: 1 13 | platformData: 14 | Android: 15 | enabled: 0 16 | settings: 17 | AndroidLibraryDependee: UnityLibrary 18 | AndroidSharedLibraryType: Executable 19 | CPU: ARMv7 20 | Any: 21 | enabled: 0 22 | settings: 23 | Exclude Android: 1 24 | Exclude Editor: 0 25 | Exclude Linux64: 1 26 | Exclude OSXUniversal: 1 27 | Exclude Win: 1 28 | Exclude Win64: 0 29 | Exclude iOS: 1 30 | Editor: 31 | enabled: 1 32 | settings: 33 | CPU: ARM64 34 | DefaultValueInitialized: true 35 | OS: Windows 36 | Linux64: 37 | enabled: 0 38 | settings: 39 | CPU: x86_64 40 | OSXUniversal: 41 | enabled: 0 42 | settings: 43 | CPU: None 44 | Win: 45 | enabled: 0 46 | settings: 47 | CPU: None 48 | Win64: 49 | enabled: 1 50 | settings: 51 | CPU: ARM64 52 | WindowsStoreApps: 53 | enabled: 0 54 | settings: 55 | CPU: ARM64 56 | iOS: 57 | enabled: 0 58 | settings: 59 | AddToEmbeddedBinaries: false 60 | CPU: AnyCPU 61 | CompileFlags: 62 | FrameworkDependencies: 63 | userData: 64 | assetBundleName: 65 | assetBundleVariant: 66 | -------------------------------------------------------------------------------- /com.github.asus4.onnxruntime-genai/Plugins/Windows/x64.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 0c27dbf37047544588af21bacc2e155d 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /com.github.asus4.onnxruntime-genai/Plugins/Windows/x64/onnxruntime-genai.dll.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 9ac9020b5dad64255a25627e9ec5d0d6 3 | PluginImporter: 4 | externalObjects: {} 5 | serializedVersion: 3 6 | iconMap: {} 7 | executionOrder: {} 8 | defineConstraints: [] 9 | isPreloaded: 0 10 | isOverridable: 1 11 | isExplicitlyReferenced: 0 12 | validateReferences: 1 13 | platformData: 14 | Android: 15 | enabled: 0 16 | settings: 17 | AndroidLibraryDependee: UnityLibrary 18 | AndroidSharedLibraryType: Executable 19 | CPU: ARMv7 20 | Any: 21 | enabled: 0 22 | settings: 23 | Exclude Android: 1 24 | Exclude Editor: 0 25 | Exclude Linux64: 1 26 | Exclude OSXUniversal: 1 27 | Exclude Win: 1 28 | Exclude Win64: 0 29 | Exclude iOS: 1 30 | Editor: 31 | enabled: 1 32 | settings: 33 | CPU: x86_64 34 | DefaultValueInitialized: true 35 | OS: Windows 36 | Linux64: 37 | enabled: 0 38 | settings: 39 | CPU: x86_64 40 | OSXUniversal: 41 | enabled: 0 42 | settings: 43 | CPU: None 44 | Win: 45 | enabled: 0 46 | settings: 47 | CPU: None 48 | Win64: 49 | enabled: 1 50 | settings: 51 | CPU: x86_64 52 | WindowsStoreApps: 53 | enabled: 0 54 | settings: 55 | CPU: x64 56 | iOS: 57 | enabled: 0 58 | settings: 59 | AddToEmbeddedBinaries: false 60 | CPU: AnyCPU 61 | CompileFlags: 62 | FrameworkDependencies: 63 | userData: 64 | assetBundleName: 65 | assetBundleVariant: 66 | -------------------------------------------------------------------------------- /com.github.asus4.onnxruntime-genai/Plugins/macOS.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 9df744a3eb872415fa7ecd385a4d3ce0 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /com.github.asus4.onnxruntime-genai/Plugins/macOS/arm64.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f15fbb685d1cc47429e7b45914bd3d63 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /com.github.asus4.onnxruntime-genai/Plugins/macOS/arm64/libonnxruntime-genai.dylib.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 16ed70f22abeb413a893a941fdabf966 3 | PluginImporter: 4 | externalObjects: {} 5 | serializedVersion: 3 6 | iconMap: {} 7 | executionOrder: {} 8 | defineConstraints: [] 9 | isPreloaded: 0 10 | isOverridable: 1 11 | isExplicitlyReferenced: 0 12 | validateReferences: 1 13 | platformData: 14 | Android: 15 | enabled: 0 16 | settings: 17 | AndroidLibraryDependee: UnityLibrary 18 | AndroidSharedLibraryType: Executable 19 | CPU: ARMv7 20 | Any: 21 | enabled: 0 22 | settings: 23 | Exclude Android: 1 24 | Exclude Editor: 0 25 | Exclude Linux64: 1 26 | Exclude OSXUniversal: 0 27 | Exclude Win: 1 28 | Exclude Win64: 1 29 | Exclude iOS: 1 30 | Editor: 31 | enabled: 1 32 | settings: 33 | CPU: ARM64 34 | DefaultValueInitialized: true 35 | OS: OSX 36 | Linux64: 37 | enabled: 0 38 | settings: 39 | CPU: x86_64 40 | OSXUniversal: 41 | enabled: 1 42 | settings: 43 | CPU: ARM64 44 | Win: 45 | enabled: 0 46 | settings: 47 | CPU: x86 48 | Win64: 49 | enabled: 0 50 | settings: 51 | CPU: None 52 | iOS: 53 | enabled: 0 54 | settings: 55 | AddToEmbeddedBinaries: false 56 | CPU: AnyCPU 57 | CompileFlags: 58 | FrameworkDependencies: 59 | userData: 60 | assetBundleName: 61 | assetBundleVariant: 62 | -------------------------------------------------------------------------------- /com.github.asus4.onnxruntime-genai/Plugins/macOS/x64.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 6e1e22aaabce24324af5ea397ea55ff9 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /com.github.asus4.onnxruntime-genai/Plugins/macOS/x64/libonnxruntime-genai.dylib.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b723f0236877b48c790304d355392945 3 | PluginImporter: 4 | externalObjects: {} 5 | serializedVersion: 3 6 | iconMap: {} 7 | executionOrder: {} 8 | defineConstraints: [] 9 | isPreloaded: 0 10 | isOverridable: 1 11 | isExplicitlyReferenced: 0 12 | validateReferences: 1 13 | platformData: 14 | Android: 15 | enabled: 0 16 | settings: 17 | AndroidLibraryDependee: UnityLibrary 18 | AndroidSharedLibraryType: Executable 19 | CPU: ARMv7 20 | Any: 21 | enabled: 0 22 | settings: 23 | Exclude Android: 1 24 | Exclude Editor: 0 25 | Exclude Linux64: 1 26 | Exclude OSXUniversal: 0 27 | Exclude Win: 1 28 | Exclude Win64: 1 29 | Exclude iOS: 1 30 | Editor: 31 | enabled: 1 32 | settings: 33 | CPU: x86_64 34 | DefaultValueInitialized: true 35 | OS: OSX 36 | Linux64: 37 | enabled: 0 38 | settings: 39 | CPU: x86_64 40 | OSXUniversal: 41 | enabled: 1 42 | settings: 43 | CPU: x86_64 44 | Win: 45 | enabled: 0 46 | settings: 47 | CPU: x86 48 | Win64: 49 | enabled: 0 50 | settings: 51 | CPU: None 52 | iOS: 53 | enabled: 0 54 | settings: 55 | AddToEmbeddedBinaries: false 56 | CPU: AnyCPU 57 | CompileFlags: 58 | FrameworkDependencies: 59 | userData: 60 | assetBundleName: 61 | assetBundleVariant: 62 | -------------------------------------------------------------------------------- /com.github.asus4.onnxruntime-genai/README.md: -------------------------------------------------------------------------------- 1 | # ONNX Runtime Plugin for Unity 2 | -------------------------------------------------------------------------------- /com.github.asus4.onnxruntime-genai/README.md.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ca421c0aaac7b421aa917a296ac29502 3 | TextScriptImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /com.github.asus4.onnxruntime-genai/Runtime.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 43036227d107c412fb7ec2a03659d767 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /com.github.asus4.onnxruntime-genai/Runtime/Adapters.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | using System; 5 | using System.Runtime.InteropServices; 6 | 7 | namespace Microsoft.ML.OnnxRuntimeGenAI 8 | { 9 | /// 10 | /// A container of adapters. 11 | /// 12 | public class Adapters : SafeHandle 13 | { 14 | /// 15 | /// Creates a container for adapters 16 | /// used to load, unload and hold them. 17 | /// Throws on error. 18 | /// 19 | /// Reference to a loaded model 20 | /// new Adapters object 21 | public Adapters(Model model) : base(IntPtr.Zero, true) 22 | { 23 | Result.VerifySuccess(NativeMethods.OgaCreateAdapters(model.Handle, out handle)); 24 | } 25 | 26 | /// 27 | /// Method that loads adapter data and assigns it a nmae that 28 | /// it can be referred to. Throws on error. 29 | /// 30 | /// file path to load 31 | /// adapter name 32 | public void LoadAdapter(string adapterPath, string adapterName) 33 | { 34 | Result.VerifySuccess(NativeMethods.OgaLoadAdapter(handle, 35 | StringUtils.ToUtf8(adapterPath), StringUtils.ToUtf8(adapterName))); 36 | } 37 | 38 | /// 39 | /// Unload the adatper that was loaded by the LoadAdapter method. 40 | /// Throws on error. 41 | /// 42 | /// 43 | public void UnloadAdapter(string adapterName) 44 | { 45 | Result.VerifySuccess(NativeMethods.OgaUnloadAdapter(handle, StringUtils.ToUtf8(adapterName))); 46 | } 47 | 48 | internal IntPtr Handle { get { return handle; } } 49 | 50 | /// 51 | /// Implement SafeHandle override 52 | /// 53 | public override bool IsInvalid => handle == IntPtr.Zero; 54 | 55 | protected override bool ReleaseHandle() 56 | { 57 | NativeMethods.OgaDestroyAdapters(handle); 58 | handle = IntPtr.Zero; 59 | return true; 60 | } 61 | } 62 | } -------------------------------------------------------------------------------- /com.github.asus4.onnxruntime-genai/Runtime/Adapters.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 3150148a71dc942a0ba4fbd590923d5c -------------------------------------------------------------------------------- /com.github.asus4.onnxruntime-genai/Runtime/Audios.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | using System; 5 | using System.Runtime.InteropServices; 6 | 7 | namespace Microsoft.ML.OnnxRuntimeGenAI 8 | { 9 | public class Audios : IDisposable 10 | { 11 | private IntPtr _audiosHandle; 12 | private bool _disposed = false; 13 | 14 | private Audios(IntPtr audiosHandle) 15 | { 16 | _audiosHandle = audiosHandle; 17 | } 18 | 19 | internal IntPtr Handle { get { return _audiosHandle; } } 20 | 21 | public static Audios Load(string[] audioPaths) 22 | { 23 | Result.VerifySuccess(NativeMethods.OgaCreateStringArray(out IntPtr stringArray)); 24 | foreach (string audioPath in audioPaths) 25 | { 26 | Result.VerifySuccess(NativeMethods.OgaStringArrayAddString(stringArray, StringUtils.ToUtf8(audioPath))); 27 | } 28 | Result.VerifySuccess(NativeMethods.OgaLoadAudios(stringArray, out IntPtr audiosHandle)); 29 | NativeMethods.OgaDestroyStringArray(stringArray); 30 | return new Audios(audiosHandle); 31 | } 32 | 33 | public void Dispose() 34 | { 35 | Dispose(true); 36 | GC.SuppressFinalize(this); 37 | } 38 | 39 | protected virtual void Dispose(bool disposing) 40 | { 41 | if (_disposed) 42 | { 43 | return; 44 | } 45 | NativeMethods.OgaDestroyAudios(_audiosHandle); 46 | _audiosHandle = IntPtr.Zero; 47 | _disposed = true; 48 | } 49 | } 50 | } -------------------------------------------------------------------------------- /com.github.asus4.onnxruntime-genai/Runtime/Audios.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b1e223c06aea849169f5eafe7f5992bf -------------------------------------------------------------------------------- /com.github.asus4.onnxruntime-genai/Runtime/Config.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | using System; 5 | 6 | namespace Microsoft.ML.OnnxRuntimeGenAI 7 | { 8 | public class Config : IDisposable 9 | { 10 | private IntPtr _configHandle; 11 | private bool _disposed = false; 12 | public Config(string modelPath) 13 | { 14 | Result.VerifySuccess(NativeMethods.OgaCreateConfig(StringUtils.ToUtf8(modelPath), out _configHandle)); 15 | } 16 | 17 | internal IntPtr Handle { get { return _configHandle; } } 18 | public void ClearProviders() 19 | { 20 | Result.VerifySuccess(NativeMethods.OgaConfigClearProviders(_configHandle)); 21 | } 22 | 23 | public void AppendProvider(string provider) 24 | { 25 | Result.VerifySuccess(NativeMethods.OgaConfigAppendProvider(_configHandle, StringUtils.ToUtf8(provider))); 26 | } 27 | 28 | public void SetProviderOption(string provider, string option, string value) 29 | { 30 | Result.VerifySuccess(NativeMethods.OgaConfigSetProviderOption(_configHandle, StringUtils.ToUtf8(provider), StringUtils.ToUtf8(option), StringUtils.ToUtf8(value))); 31 | } 32 | 33 | ~Config() 34 | { 35 | Dispose(false); 36 | } 37 | 38 | public void Dispose() 39 | { 40 | Dispose(true); 41 | GC.SuppressFinalize(this); 42 | } 43 | 44 | protected virtual void Dispose(bool disposing) 45 | { 46 | if (_disposed) 47 | { 48 | return; 49 | } 50 | NativeMethods.OgaDestroyConfig(_configHandle); 51 | _configHandle = IntPtr.Zero; 52 | _disposed = true; 53 | } 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /com.github.asus4.onnxruntime-genai/Runtime/Config.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b9be07acc6cd44f28bd43300cad123a4 -------------------------------------------------------------------------------- /com.github.asus4.onnxruntime-genai/Runtime/Exceptions.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | using System; 5 | 6 | namespace Microsoft.ML.OnnxRuntimeGenAI 7 | { 8 | public class OnnxRuntimeGenAIException: Exception 9 | { 10 | internal OnnxRuntimeGenAIException(string message) 11 | :base(message) 12 | { 13 | } 14 | } 15 | 16 | 17 | } 18 | -------------------------------------------------------------------------------- /com.github.asus4.onnxruntime-genai/Runtime/Exceptions.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d52cc21ccb9f642fa802cf4a46b854a3 -------------------------------------------------------------------------------- /com.github.asus4.onnxruntime-genai/Runtime/Generator.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 1cabac406f7604d70b87f644ff71e912 -------------------------------------------------------------------------------- /com.github.asus4.onnxruntime-genai/Runtime/GeneratorParams.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | using System; 5 | using System.Collections.Generic; 6 | using System.Linq; 7 | using System.Runtime.InteropServices; 8 | 9 | namespace Microsoft.ML.OnnxRuntimeGenAI 10 | { 11 | public class GeneratorParams : IDisposable 12 | { 13 | private IntPtr _generatorParamsHandle; 14 | private bool _disposed = false; 15 | public GeneratorParams(Model model) 16 | { 17 | Result.VerifySuccess(NativeMethods.OgaCreateGeneratorParams(model.Handle, out _generatorParamsHandle)); 18 | } 19 | 20 | internal IntPtr Handle { get { return _generatorParamsHandle; } } 21 | 22 | public void SetSearchOption(string searchOption, double value) 23 | { 24 | Result.VerifySuccess(NativeMethods.OgaGeneratorParamsSetSearchNumber(_generatorParamsHandle, StringUtils.ToUtf8(searchOption), value)); 25 | } 26 | 27 | public void SetSearchOption(string searchOption, bool value) 28 | { 29 | Result.VerifySuccess(NativeMethods.OgaGeneratorParamsSetSearchBool(_generatorParamsHandle, StringUtils.ToUtf8(searchOption), value)); 30 | } 31 | 32 | public void TryGraphCaptureWithMaxBatchSize(int maxBatchSize) 33 | { 34 | Console.WriteLine("TryGraphCaptureWithMaxBatchSize is deprecated and will be removed in a future release."); 35 | } 36 | 37 | public void SetModelInput(string name, Tensor value) 38 | { 39 | Result.VerifySuccess(NativeMethods.OgaGeneratorParamsSetModelInput(_generatorParamsHandle, StringUtils.ToUtf8(name), value.Handle)); 40 | } 41 | 42 | public void SetInputs(NamedTensors namedTensors) 43 | { 44 | Result.VerifySuccess(NativeMethods.OgaGeneratorParamsSetInputs(_generatorParamsHandle, namedTensors.Handle)); 45 | } 46 | 47 | ~GeneratorParams() 48 | { 49 | Dispose(false); 50 | } 51 | 52 | public void Dispose() 53 | { 54 | Dispose(true); 55 | GC.SuppressFinalize(this); 56 | } 57 | 58 | protected virtual void Dispose(bool disposing) 59 | { 60 | if (_disposed) 61 | { 62 | return; 63 | } 64 | NativeMethods.OgaDestroyGeneratorParams(_generatorParamsHandle); 65 | _generatorParamsHandle = IntPtr.Zero; 66 | _disposed = true; 67 | } 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /com.github.asus4.onnxruntime-genai/Runtime/GeneratorParams.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 3f560f5aa22e2410c82d9897a4cd09f1 -------------------------------------------------------------------------------- /com.github.asus4.onnxruntime-genai/Runtime/Images.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | using System; 5 | using System.Runtime.InteropServices; 6 | 7 | namespace Microsoft.ML.OnnxRuntimeGenAI 8 | { 9 | public class Images : IDisposable 10 | { 11 | private IntPtr _imagesHandle; 12 | private bool _disposed = false; 13 | 14 | private Images(IntPtr imagesHandle) 15 | { 16 | _imagesHandle = imagesHandle; 17 | } 18 | 19 | internal IntPtr Handle { get { return _imagesHandle; } } 20 | 21 | public static Images Load(string[] imagePaths) 22 | { 23 | Result.VerifySuccess(NativeMethods.OgaCreateStringArray(out IntPtr stringArray)); 24 | foreach (string imagePath in imagePaths) 25 | { 26 | Result.VerifySuccess(NativeMethods.OgaStringArrayAddString(stringArray, StringUtils.ToUtf8(imagePath))); 27 | } 28 | Result.VerifySuccess(NativeMethods.OgaLoadImages(stringArray, out IntPtr imagesHandle)); 29 | NativeMethods.OgaDestroyStringArray(stringArray); 30 | return new Images(imagesHandle); 31 | } 32 | 33 | public void Dispose() 34 | { 35 | Dispose(true); 36 | GC.SuppressFinalize(this); 37 | } 38 | 39 | protected virtual void Dispose(bool disposing) 40 | { 41 | if (_disposed) 42 | { 43 | return; 44 | } 45 | NativeMethods.OgaDestroyImages(_imagesHandle); 46 | _imagesHandle = IntPtr.Zero; 47 | _disposed = true; 48 | } 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /com.github.asus4.onnxruntime-genai/Runtime/Images.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a270c3e3ff4404353bad74f39c3e4eec -------------------------------------------------------------------------------- /com.github.asus4.onnxruntime-genai/Runtime/Model.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | using System; 5 | using System.Runtime.InteropServices; 6 | 7 | namespace Microsoft.ML.OnnxRuntimeGenAI 8 | { 9 | public class Model : IDisposable 10 | { 11 | private IntPtr _modelHandle; 12 | private bool _disposed = false; 13 | 14 | public Model(string modelPath) 15 | { 16 | Result.VerifySuccess(NativeMethods.OgaCreateModel(StringUtils.ToUtf8(modelPath), out _modelHandle)); 17 | } 18 | 19 | public Model(Config config) 20 | { 21 | Result.VerifySuccess(NativeMethods.OgaCreateModelFromConfig(config.Handle, out _modelHandle)); 22 | } 23 | 24 | internal IntPtr Handle { get { return _modelHandle; } } 25 | 26 | ~Model() 27 | { 28 | Dispose(false); 29 | } 30 | 31 | public void Dispose() 32 | { 33 | Dispose(true); 34 | GC.SuppressFinalize(this); 35 | } 36 | 37 | protected virtual void Dispose(bool disposing) 38 | { 39 | if (_disposed) 40 | { 41 | return; 42 | } 43 | if (_modelHandle != IntPtr.Zero) 44 | { 45 | NativeMethods.OgaDestroyModel(_modelHandle); 46 | _modelHandle = IntPtr.Zero; 47 | } 48 | _disposed = true; 49 | } 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /com.github.asus4.onnxruntime-genai/Runtime/Model.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 582bf6aebfe2e4f1daee062877a22bfa -------------------------------------------------------------------------------- /com.github.asus4.onnxruntime-genai/Runtime/MultiModalProcessor.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b01b83c2daa6e4799a78cddfff7e83ba -------------------------------------------------------------------------------- /com.github.asus4.onnxruntime-genai/Runtime/NativeMethods.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f3a4c5186881b4597b3dac2bc80fc735 -------------------------------------------------------------------------------- /com.github.asus4.onnxruntime-genai/Runtime/OnnxRuntimeGenAIChatClient.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: bbbd53b272f4b4a52805882fc6f52d77 -------------------------------------------------------------------------------- /com.github.asus4.onnxruntime-genai/Runtime/OnnxRuntimeGenAIChatClientOptions.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 2d75f2ba2397d43fbacf6def4bb4d428 -------------------------------------------------------------------------------- /com.github.asus4.onnxruntime-genai/Runtime/Result.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | using System; 5 | using System.Runtime.CompilerServices; 6 | 7 | namespace Microsoft.ML.OnnxRuntimeGenAI 8 | { 9 | class Result 10 | { 11 | private static string GetErrorMessage(IntPtr nativeResult) 12 | { 13 | 14 | return StringUtils.FromUtf8(NativeMethods.OgaResultGetError(nativeResult)); 15 | } 16 | 17 | [MethodImpl(MethodImplOptions.AggressiveInlining)] 18 | public static void VerifySuccess(IntPtr nativeResult) 19 | { 20 | if (nativeResult != IntPtr.Zero) 21 | { 22 | try 23 | { 24 | string errorMessage = GetErrorMessage(nativeResult); 25 | throw new OnnxRuntimeGenAIException(errorMessage); 26 | } 27 | finally 28 | { 29 | NativeMethods.OgaDestroyResult(nativeResult); 30 | } 31 | } 32 | } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /com.github.asus4.onnxruntime-genai/Runtime/Result.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 14991f0fd9d1f4122b056679f2b6b7be -------------------------------------------------------------------------------- /com.github.asus4.onnxruntime-genai/Runtime/Sequences.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | using System; 5 | 6 | namespace Microsoft.ML.OnnxRuntimeGenAI 7 | { 8 | public class Sequences : IDisposable 9 | { 10 | private IntPtr _sequencesHandle; 11 | private bool _disposed = false; 12 | private ulong _numSequences; 13 | 14 | internal Sequences(IntPtr sequencesHandle) 15 | { 16 | _sequencesHandle = sequencesHandle; 17 | _numSequences = NativeMethods.OgaSequencesCount(_sequencesHandle).ToUInt64(); 18 | } 19 | 20 | internal IntPtr Handle { get { return _sequencesHandle; } } 21 | 22 | public ulong NumSequences { get { return _numSequences; } } 23 | 24 | public void Append(int token, ulong sequenceIndex) 25 | { 26 | if (sequenceIndex >= _numSequences) 27 | { 28 | throw new ArgumentOutOfRangeException(nameof(sequenceIndex)); 29 | } 30 | Result.VerifySuccess(NativeMethods.OgaAppendTokenToSequence(token, _sequencesHandle, (UIntPtr)sequenceIndex)); 31 | } 32 | 33 | public ReadOnlySpan this[ulong sequenceIndex] 34 | { 35 | get 36 | { 37 | if (sequenceIndex >= _numSequences) 38 | { 39 | throw new ArgumentOutOfRangeException(nameof(sequenceIndex)); 40 | } 41 | ulong sequenceLength = NativeMethods.OgaSequencesGetSequenceCount(_sequencesHandle, (UIntPtr)sequenceIndex).ToUInt64(); 42 | IntPtr sequencePtr = NativeMethods.OgaSequencesGetSequenceData(_sequencesHandle, (UIntPtr)sequenceIndex); 43 | unsafe 44 | { 45 | return new ReadOnlySpan(sequencePtr.ToPointer(), (int)sequenceLength); 46 | } 47 | } 48 | } 49 | 50 | ~Sequences() 51 | { 52 | Dispose(false); 53 | } 54 | 55 | public void Dispose() 56 | { 57 | Dispose(true); 58 | GC.SuppressFinalize(this); 59 | } 60 | 61 | protected virtual void Dispose(bool disposing) 62 | { 63 | if (_disposed) 64 | { 65 | return; 66 | } 67 | NativeMethods.OgaDestroySequences(_sequencesHandle); 68 | _sequencesHandle = IntPtr.Zero; 69 | _disposed = true; 70 | } 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /com.github.asus4.onnxruntime-genai/Runtime/Sequences.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 282e4e7c23f7d4cb0a6e0d73ced83942 -------------------------------------------------------------------------------- /com.github.asus4.onnxruntime-genai/Runtime/Tensor.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 54c1c676c82af4f99a67232a69991f09 -------------------------------------------------------------------------------- /com.github.asus4.onnxruntime-genai/Runtime/Tokenizer.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 026c07dbe33e94d2f943bdf67f88bafa -------------------------------------------------------------------------------- /com.github.asus4.onnxruntime-genai/Runtime/TokenizerStream.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | using System; 5 | 6 | namespace Microsoft.ML.OnnxRuntimeGenAI 7 | { 8 | public class TokenizerStream : IDisposable 9 | { 10 | private IntPtr _tokenizerStreamHandle; 11 | private bool _disposed = false; 12 | 13 | internal TokenizerStream(IntPtr tokenizerStreamHandle) 14 | { 15 | _tokenizerStreamHandle = tokenizerStreamHandle; 16 | } 17 | 18 | internal IntPtr Handle { get { return _tokenizerStreamHandle; } } 19 | 20 | public string Decode(int token) 21 | { 22 | IntPtr decodedStr = IntPtr.Zero; 23 | Result.VerifySuccess(NativeMethods.OgaTokenizerStreamDecode(_tokenizerStreamHandle, token, out decodedStr)); 24 | return StringUtils.FromUtf8(decodedStr); 25 | } 26 | 27 | ~TokenizerStream() 28 | { 29 | Dispose(false); 30 | } 31 | 32 | public void Dispose() 33 | { 34 | Dispose(true); 35 | GC.SuppressFinalize(this); 36 | } 37 | 38 | protected virtual void Dispose(bool disposing) 39 | { 40 | if (_disposed) 41 | { 42 | return; 43 | } 44 | NativeMethods.OgaDestroyTokenizerStream(_tokenizerStreamHandle); 45 | _tokenizerStreamHandle = IntPtr.Zero; 46 | _disposed = true; 47 | } 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /com.github.asus4.onnxruntime-genai/Runtime/TokenizerStream.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 69f7aa30b330c47978a5a56a9ca4749c -------------------------------------------------------------------------------- /com.github.asus4.onnxruntime-genai/Runtime/Utils.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | using System; 5 | using System.Text; 6 | 7 | namespace Microsoft.ML.OnnxRuntimeGenAI 8 | { 9 | public class OgaHandle: IDisposable 10 | { 11 | private bool _disposed = false; 12 | 13 | public OgaHandle() 14 | { 15 | } 16 | 17 | ~OgaHandle() 18 | { 19 | Dispose(false); 20 | } 21 | 22 | public void Dispose() 23 | { 24 | Dispose(true); 25 | GC.SuppressFinalize(this); 26 | } 27 | 28 | protected virtual void Dispose(bool disposing) 29 | { 30 | if (_disposed) 31 | { 32 | return; 33 | } 34 | NativeMethods.OgaShutdown(); 35 | _disposed = true; 36 | } 37 | } 38 | 39 | public class Utils 40 | { 41 | public static void SetCurrentGpuDeviceId(int device_id) 42 | { 43 | Result.VerifySuccess(NativeMethods.OgaSetCurrentGpuDeviceId(device_id)); 44 | } 45 | 46 | public static int GetCurrentGpuDeviceId() 47 | { 48 | IntPtr device_id = IntPtr.Zero; 49 | Result.VerifySuccess(NativeMethods.OgaGetCurrentGpuDeviceId(out device_id)); 50 | return (int)device_id.ToInt64(); 51 | } 52 | 53 | public static void SetLogBool(string name, bool value) 54 | { 55 | Result.VerifySuccess(NativeMethods.OgaSetLogBool(StringUtils.ToUtf8(name), value)); 56 | } 57 | 58 | public static void SetLogString(string name, string value) 59 | { 60 | Result.VerifySuccess(NativeMethods.OgaSetLogString(StringUtils.ToUtf8(name), StringUtils.ToUtf8(value))); 61 | } 62 | } 63 | 64 | internal class StringUtils 65 | { 66 | internal static byte[] EmptyByteArray = new byte[] { 0 }; 67 | 68 | internal static byte[] ToUtf8(string str) 69 | { 70 | if (string.IsNullOrEmpty(str)) 71 | return EmptyByteArray; 72 | 73 | int arraySize = UTF8Encoding.UTF8.GetByteCount(str); 74 | byte[] utf8Bytes = new byte[arraySize + 1]; 75 | UTF8Encoding.UTF8.GetBytes(str, 0, str.Length, utf8Bytes, 0); 76 | utf8Bytes[utf8Bytes.Length - 1] = 0; 77 | return utf8Bytes; 78 | } 79 | 80 | internal static string FromUtf8(IntPtr nativeUtf8) 81 | { 82 | unsafe 83 | { 84 | int len = 0; 85 | while (*(byte*)(nativeUtf8 + len) != 0) ++len; 86 | 87 | if (len == 0) 88 | { 89 | return string.Empty; 90 | } 91 | var nativeBytes = (byte*)nativeUtf8; 92 | return Encoding.UTF8.GetString(nativeBytes, len); 93 | } 94 | } 95 | } 96 | } 97 | -------------------------------------------------------------------------------- /com.github.asus4.onnxruntime-genai/Runtime/Utils.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 3bfe6a23734654f3181cc328bbfd7218 -------------------------------------------------------------------------------- /com.github.asus4.onnxruntime-genai/Runtime/com.github.asus4.onnxruntime-genai.asmdef: -------------------------------------------------------------------------------- 1 | { 2 | "name": "com.github.asus4.onnxruntime-genai", 3 | "rootNamespace": "", 4 | "references": [], 5 | "includePlatforms": [], 6 | "excludePlatforms": [], 7 | "allowUnsafeCode": true, 8 | "overrideReferences": false, 9 | "precompiledReferences": [], 10 | "autoReferenced": true, 11 | "defineConstraints": [], 12 | "versionDefines": [], 13 | "noEngineReferences": false 14 | } -------------------------------------------------------------------------------- /com.github.asus4.onnxruntime-genai/Runtime/com.github.asus4.onnxruntime-genai.asmdef.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: cb1bbd555d8984ee596e3185c0f6fa26 3 | AssemblyDefinitionImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /com.github.asus4.onnxruntime-genai/Runtime/onnxruntime-genai.snk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/asus4/onnxruntime-unity/6ce2c8afa8cc60c63593ba409d828b26bf1184fc/com.github.asus4.onnxruntime-genai/Runtime/onnxruntime-genai.snk -------------------------------------------------------------------------------- /com.github.asus4.onnxruntime-genai/Runtime/onnxruntime-genai.snk.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 944d0117d47da46afab6276a8a21d280 3 | DefaultImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /com.github.asus4.onnxruntime-genai/ThirdPartyNotices.txt.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f4dffd6c2b7db4dc8af4a4ddb8286000 3 | TextScriptImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /com.github.asus4.onnxruntime-genai/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "com.github.asus4.onnxruntime-genai", 3 | "version": "0.4.0", 4 | "displayName": "ONNX Runtime GenAI", 5 | "description": "ONNX Runtime Generative AI for Unity", 6 | "keywords": [ 7 | "unity", 8 | "onnxruntime" 9 | ], 10 | "unity": "2022.3", 11 | "unityRelease": "0f1", 12 | "dependencies": { 13 | "com.github.asus4.onnxruntime": "0.4.0" 14 | }, 15 | "repository": { 16 | "type": "git", 17 | "repository": "https://github.com/asus4/onnxruntime-unity.git" 18 | }, 19 | "documentationUrl": "https://github.com/asus4/onnxruntime-unity", 20 | "changelogUrl": "https://github.com/asus4/onnxruntime-unity/releases", 21 | "licensesUrl": "https://github.com/asus4/onnxruntime-unity/blob/main/com.github.asus4.onnxruntime/LICENSE", 22 | "author": { 23 | "name": "Koki Ibukuro", 24 | "url": "https://github.com/asus4" 25 | } 26 | } -------------------------------------------------------------------------------- /com.github.asus4.onnxruntime-genai/package.json.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 7ed8afe3cea424a9180821f8a9079d67 3 | PackageManifestImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /com.github.asus4.onnxruntime.linux-x64-gpu/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) Microsoft Corporation. 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE 22 | -------------------------------------------------------------------------------- /com.github.asus4.onnxruntime.linux-x64-gpu/LICENSE.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 6082df1df583f4a549a324e6f917bb1d 3 | DefaultImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /com.github.asus4.onnxruntime.linux-x64-gpu/Plugins.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c996ac95e22df45c7a545f62fbf5cfbb 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /com.github.asus4.onnxruntime.linux-x64-gpu/Plugins/Linux.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 87b9304fd11de44b4940429ca6fa032d 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /com.github.asus4.onnxruntime.linux-x64-gpu/Plugins/Linux/x64.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 056c03e10916845ddbd91c25f890b8d9 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /com.github.asus4.onnxruntime.linux-x64-gpu/Plugins/Linux/x64/libonnxruntime_providers_cuda.so.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f2eeaeef642834984917129815450613 3 | PluginImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | iconMap: {} 7 | executionOrder: {} 8 | defineConstraints: [] 9 | isPreloaded: 0 10 | isOverridable: 1 11 | isExplicitlyReferenced: 0 12 | validateReferences: 1 13 | platformData: 14 | - first: 15 | : Any 16 | second: 17 | enabled: 0 18 | settings: 19 | Exclude Android: 1 20 | Exclude Editor: 0 21 | Exclude Linux64: 0 22 | Exclude OSXUniversal: 0 23 | Exclude Win: 0 24 | Exclude Win64: 0 25 | Exclude iOS: 1 26 | - first: 27 | Android: Android 28 | second: 29 | enabled: 0 30 | settings: 31 | AndroidSharedLibraryType: Executable 32 | CPU: ARMv7 33 | - first: 34 | Any: 35 | second: 36 | enabled: 0 37 | settings: {} 38 | - first: 39 | Editor: Editor 40 | second: 41 | enabled: 1 42 | settings: 43 | CPU: x86_64 44 | DefaultValueInitialized: true 45 | OS: Linux 46 | - first: 47 | Standalone: Linux64 48 | second: 49 | enabled: 1 50 | settings: 51 | CPU: AnyCPU 52 | - first: 53 | Standalone: OSXUniversal 54 | second: 55 | enabled: 1 56 | settings: 57 | CPU: AnyCPU 58 | - first: 59 | Standalone: Win 60 | second: 61 | enabled: 1 62 | settings: 63 | CPU: AnyCPU 64 | - first: 65 | Standalone: Win64 66 | second: 67 | enabled: 1 68 | settings: 69 | CPU: AnyCPU 70 | - first: 71 | iPhone: iOS 72 | second: 73 | enabled: 0 74 | settings: 75 | AddToEmbeddedBinaries: false 76 | CPU: AnyCPU 77 | CompileFlags: 78 | FrameworkDependencies: 79 | userData: 80 | assetBundleName: 81 | assetBundleVariant: 82 | -------------------------------------------------------------------------------- /com.github.asus4.onnxruntime.linux-x64-gpu/Plugins/Linux/x64/libonnxruntime_providers_shared.so.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 17982bf6ecf4c4984bea8b510a4084e6 3 | PluginImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | iconMap: {} 7 | executionOrder: {} 8 | defineConstraints: [] 9 | isPreloaded: 0 10 | isOverridable: 1 11 | isExplicitlyReferenced: 0 12 | validateReferences: 1 13 | platformData: 14 | - first: 15 | : Any 16 | second: 17 | enabled: 0 18 | settings: 19 | Exclude Android: 1 20 | Exclude Editor: 0 21 | Exclude Linux64: 0 22 | Exclude OSXUniversal: 0 23 | Exclude Win: 0 24 | Exclude Win64: 0 25 | Exclude iOS: 1 26 | - first: 27 | Android: Android 28 | second: 29 | enabled: 0 30 | settings: 31 | AndroidSharedLibraryType: Executable 32 | CPU: ARMv7 33 | - first: 34 | Any: 35 | second: 36 | enabled: 0 37 | settings: {} 38 | - first: 39 | Editor: Editor 40 | second: 41 | enabled: 1 42 | settings: 43 | CPU: x86_64 44 | DefaultValueInitialized: true 45 | OS: Linux 46 | - first: 47 | Standalone: Linux64 48 | second: 49 | enabled: 1 50 | settings: 51 | CPU: AnyCPU 52 | - first: 53 | Standalone: OSXUniversal 54 | second: 55 | enabled: 1 56 | settings: 57 | CPU: AnyCPU 58 | - first: 59 | Standalone: Win 60 | second: 61 | enabled: 1 62 | settings: 63 | CPU: AnyCPU 64 | - first: 65 | Standalone: Win64 66 | second: 67 | enabled: 1 68 | settings: 69 | CPU: AnyCPU 70 | - first: 71 | iPhone: iOS 72 | second: 73 | enabled: 0 74 | settings: 75 | AddToEmbeddedBinaries: false 76 | CPU: AnyCPU 77 | CompileFlags: 78 | FrameworkDependencies: 79 | userData: 80 | assetBundleName: 81 | assetBundleVariant: 82 | -------------------------------------------------------------------------------- /com.github.asus4.onnxruntime.linux-x64-gpu/Plugins/Linux/x64/libonnxruntime_providers_tensorrt.so.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: bb98f7174462b46709cb951f778c32b7 3 | PluginImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | iconMap: {} 7 | executionOrder: {} 8 | defineConstraints: [] 9 | isPreloaded: 0 10 | isOverridable: 1 11 | isExplicitlyReferenced: 0 12 | validateReferences: 1 13 | platformData: 14 | - first: 15 | : Any 16 | second: 17 | enabled: 0 18 | settings: 19 | Exclude Android: 1 20 | Exclude Editor: 0 21 | Exclude Linux64: 0 22 | Exclude OSXUniversal: 0 23 | Exclude Win: 0 24 | Exclude Win64: 0 25 | Exclude iOS: 1 26 | - first: 27 | Android: Android 28 | second: 29 | enabled: 0 30 | settings: 31 | AndroidSharedLibraryType: Executable 32 | CPU: ARMv7 33 | - first: 34 | Any: 35 | second: 36 | enabled: 0 37 | settings: {} 38 | - first: 39 | Editor: Editor 40 | second: 41 | enabled: 1 42 | settings: 43 | CPU: x86_64 44 | DefaultValueInitialized: true 45 | OS: Linux 46 | - first: 47 | Standalone: Linux64 48 | second: 49 | enabled: 1 50 | settings: 51 | CPU: AnyCPU 52 | - first: 53 | Standalone: OSXUniversal 54 | second: 55 | enabled: 1 56 | settings: 57 | CPU: AnyCPU 58 | - first: 59 | Standalone: Win 60 | second: 61 | enabled: 1 62 | settings: 63 | CPU: AnyCPU 64 | - first: 65 | Standalone: Win64 66 | second: 67 | enabled: 1 68 | settings: 69 | CPU: AnyCPU 70 | - first: 71 | iPhone: iOS 72 | second: 73 | enabled: 0 74 | settings: 75 | AddToEmbeddedBinaries: false 76 | CPU: AnyCPU 77 | CompileFlags: 78 | FrameworkDependencies: 79 | userData: 80 | assetBundleName: 81 | assetBundleVariant: 82 | -------------------------------------------------------------------------------- /com.github.asus4.onnxruntime.linux-x64-gpu/README.md: -------------------------------------------------------------------------------- 1 | # ONNX Runtime Plugin for Unity 2 | -------------------------------------------------------------------------------- /com.github.asus4.onnxruntime.linux-x64-gpu/README.md.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4767cd90cd42247b3b6a26150435e62e 3 | TextScriptImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /com.github.asus4.onnxruntime.linux-x64-gpu/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "com.github.asus4.onnxruntime.linux-x64-gpu", 3 | "version": "0.4.0", 4 | "displayName": "ONNX Runtime - Linux x64 GPU", 5 | "description": "ONNX Runtime for Unity - Linux x64 GPU Provider", 6 | "keywords": [ 7 | "unity", 8 | "onnxruntime" 9 | ], 10 | "unity": "2022.3", 11 | "unityRelease": "0f1", 12 | "dependencies": { 13 | "com.github.asus4.onnxruntime": "0.4.0" 14 | }, 15 | "repository": { 16 | "type": "git", 17 | "repository": "https://github.com/asus4/onnxruntime-unity.git" 18 | }, 19 | "documentationUrl": "https://github.com/asus4/onnxruntime-unity", 20 | "changelogUrl": "https://github.com/asus4/onnxruntime-unity/releases", 21 | "licensesUrl": "https://github.com/asus4/onnxruntime-unity/blob/main/onnxruntime.linux-x64-gpu/LICENSE", 22 | "author": { 23 | "name": "Koki Ibukuro", 24 | "url": "https://github.com/asus4" 25 | } 26 | } -------------------------------------------------------------------------------- /com.github.asus4.onnxruntime.linux-x64-gpu/package.json.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: aedd10998f678439b872c407a89d5801 3 | PackageManifestImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /com.github.asus4.onnxruntime.unity/Editor.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 301f712eccb874f0498a792fc8415565 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /com.github.asus4.onnxruntime.unity/Editor/OrtImporter.cs: -------------------------------------------------------------------------------- 1 | using System.IO; 2 | using UnityEngine; 3 | using UnityEditor.AssetImporters; 4 | 5 | namespace Microsoft.ML.OnnxRuntime.Unity.Editor 6 | { 7 | /// 8 | /// Imports *.ort or *.onnx file as OrtAsset 9 | /// 10 | /// Sentis in installed and want to import the onnx model as OrtAsset, 11 | /// Select importer the dropdown of the onnx asset 12 | /// 13 | #if ORT_UNITY_SENTIS_ENABLED 14 | [ScriptedImporter(1, new[] { "ort" }, new[] { "onnx" })] 15 | #else 16 | [ScriptedImporter(1, new[] { "ort", "onnx" })] 17 | #endif // ORT_UNITY_SENTIS_ENABLED 18 | public class OrtImporter : ScriptedImporter 19 | { 20 | public override void OnImportAsset(AssetImportContext ctx) 21 | { 22 | // Load *.ort file as OrtAsset 23 | var asset = ScriptableObject.CreateInstance(); 24 | asset.bytes = File.ReadAllBytes(ctx.assetPath); 25 | 26 | ctx.AddObjectToAsset("ort asset", asset); 27 | ctx.SetMainObject(asset); 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /com.github.asus4.onnxruntime.unity/Editor/OrtImporter.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 346e7eaf4c4224a769b1a62ee7e5bfe0 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /com.github.asus4.onnxruntime.unity/Editor/com.github.asus4.onnxruntime.unity.Editor.asmdef: -------------------------------------------------------------------------------- 1 | { 2 | "name": "com.github.asus4.onnxruntime.unity.Editor", 3 | "rootNamespace": "", 4 | "references": [ 5 | "GUID:effe5775fa53c49a39f54ea0433a395b" 6 | ], 7 | "includePlatforms": [ 8 | "Editor" 9 | ], 10 | "excludePlatforms": [], 11 | "allowUnsafeCode": false, 12 | "overrideReferences": false, 13 | "precompiledReferences": [], 14 | "autoReferenced": true, 15 | "defineConstraints": [], 16 | "versionDefines": [ 17 | { 18 | "name": "com.unity.sentis", 19 | "expression": "", 20 | "define": "ORT_UNITY_SENTIS_ENABLED" 21 | } 22 | ], 23 | "noEngineReferences": false 24 | } -------------------------------------------------------------------------------- /com.github.asus4.onnxruntime.unity/Editor/com.github.asus4.onnxruntime.unity.Editor.asmdef.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 677a846102848427fa0368d4c11dc74a 3 | AssemblyDefinitionImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /com.github.asus4.onnxruntime.unity/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) Koki Ibukuro 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /com.github.asus4.onnxruntime.unity/LICENSE.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 67e17cb4d8f82457a87f35ff8fabd034 3 | DefaultImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /com.github.asus4.onnxruntime.unity/README.md: -------------------------------------------------------------------------------- 1 | # ONNX Runtime Plugin for Unity 2 | -------------------------------------------------------------------------------- /com.github.asus4.onnxruntime.unity/README.md.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 0db70013b500b4350a7f41126e400ae6 3 | TextScriptImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /com.github.asus4.onnxruntime.unity/Resources.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: be69d1dc6da3643d9b9ea487e057a093 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /com.github.asus4.onnxruntime.unity/Resources/com.github.asus4.onnxruntime.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 964eea149041a4236a3275d07572ba60 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /com.github.asus4.onnxruntime.unity/Resources/com.github.asus4.onnxruntime.unity/TextureToTensor.compute: -------------------------------------------------------------------------------- 1 | #pragma kernel TextureToTensor 2 | 3 | Texture2D _InputTex; 4 | RWTexture2D _OutputTex; 5 | RWBuffer _OutputTensor; 6 | 7 | uint2 _OutputSize; 8 | float4x4 _TransformMatrix; 9 | float3 _Mean = float3(0.485, 0.456, 0.406); 10 | float3 _StdDev = float3(0.229, 0.224, 0.225); 11 | 12 | SamplerState linearClampSampler; 13 | 14 | 15 | // Get index of NCHW tensor 16 | uint3 IdxNCHW(uint3 c, uint y, uint x) 17 | { 18 | return c * _OutputSize.x * _OutputSize.y + y * _OutputSize.x + x; 19 | } 20 | 21 | [numthreads(8,8,1)] 22 | void TextureToTensor (uint2 id : SV_DispatchThreadID) 23 | { 24 | if(any(id >= _OutputSize)) 25 | { 26 | return; 27 | } 28 | 29 | float2 uv = (float2)id / float2(_OutputSize - 1.0); 30 | uv = mul(_TransformMatrix, float4(uv, 0, 1)).xy; 31 | 32 | float4 color = any(uv < 0) || any(uv > 1) 33 | ? float4(0, 0, 0, 1) // Set to black the outside 34 | : _InputTex.SampleLevel(linearClampSampler, uv, 0); 35 | 36 | _OutputTex[id] = color; 37 | 38 | // TODO: Add shader keywords to enable/disable normalization 39 | // Normalize 40 | color.rgb = (color.rgb - _Mean) / _StdDev; 41 | 42 | // Flip Y axis 43 | uint3 tid = IdxNCHW(uint3(0, 1, 2), _OutputSize.y - id.y - 1, id.x); 44 | _OutputTensor[tid.x] = color.r; 45 | _OutputTensor[tid.y] = color.g; 46 | _OutputTensor[tid.z] = color.b; 47 | } 48 | -------------------------------------------------------------------------------- /com.github.asus4.onnxruntime.unity/Resources/com.github.asus4.onnxruntime.unity/TextureToTensor.compute.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: dc4def4a4ada34efda6f4e15f7b712cd 3 | ComputeShaderImporter: 4 | externalObjects: {} 5 | currentAPIMask: 65537 6 | preprocessorOverride: 0 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /com.github.asus4.onnxruntime.unity/Runtime.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4545c48ff2aae458498d7e47dbb27968 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /com.github.asus4.onnxruntime.unity/Runtime/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Runtime.CompilerServices; 2 | 3 | [assembly: InternalsVisibleTo("com.github.asus4.onnxruntime.unity.tests")] 4 | -------------------------------------------------------------------------------- /com.github.asus4.onnxruntime.unity/Runtime/AssemblyInfo.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: aae6415e33def41cfab7b244f4d3187a -------------------------------------------------------------------------------- /com.github.asus4.onnxruntime.unity/Runtime/Detection.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using UnityEngine; 3 | using Unity.Collections; 4 | using Unity.Collections.LowLevel.Unsafe; 5 | 6 | namespace Microsoft.ML.OnnxRuntime.Unity 7 | { 8 | /// 9 | /// Interface for Detection Task 10 | /// 11 | /// Detection struct 12 | public interface IDetection : IComparable 13 | where T : unmanaged 14 | { 15 | int Label { get; } 16 | Rect Rect { get; } 17 | } 18 | 19 | public static class DetectionUtil 20 | { 21 | /// 22 | /// Non-Maximum Suppression (Multi-Class) 23 | /// 24 | /// A list of proposals which should be sorted in descending order 25 | /// A result of NMS 26 | /// A threshold of IoU (Intersection over Union) 27 | public unsafe static void NMS( 28 | NativeSlice proposals, 29 | NativeList result, 30 | float iouThreshold) 31 | where T : unmanaged, IDetection 32 | { 33 | int proposalsLength = proposals.Length; 34 | T* proposalsPtr = (T*)proposals.GetUnsafeReadOnlyPtr(); 35 | NMS(proposalsPtr, proposalsLength, result, iouThreshold); 36 | } 37 | 38 | /// 39 | /// Non-Maximum Suppression (Multi-Class) 40 | /// 41 | /// A list of proposals which should be sorted in descending order 42 | /// A result of NMS 43 | /// A threshold of IoU (Intersection over Union) 44 | public unsafe static void NMS( 45 | NativeList proposals, 46 | NativeList result, 47 | float iouThreshold) 48 | where T : unmanaged, IDetection 49 | { 50 | int proposalsLength = proposals.Length; 51 | T* proposalsPtr = proposals.GetUnsafeReadOnlyPtr(); 52 | NMS(proposalsPtr, proposalsLength, result, iouThreshold); 53 | } 54 | 55 | unsafe static void NMS( 56 | T* proposalsPtr, 57 | int proposalsLength, 58 | NativeList result, 59 | float iouThreshold) 60 | where T : unmanaged, IDetection 61 | { 62 | result.Clear(); 63 | 64 | for (int i = 0; i < proposalsLength; i++) 65 | { 66 | T* a = proposalsPtr + i; 67 | bool keep = true; 68 | 69 | for (int j = 0; j < result.Length; j++) 70 | { 71 | T* b = result.GetUnsafeReadOnlyPtr() + j; 72 | 73 | // Ignore different classes 74 | if (b->Label != a->Label) 75 | { 76 | continue; 77 | } 78 | 79 | float iou = a->Rect.IntersectionOverUnion(b->Rect); 80 | if (iou > iouThreshold) 81 | { 82 | keep = false; 83 | break; 84 | } 85 | } 86 | 87 | if (keep) 88 | { 89 | result.Add(*a); 90 | } 91 | } 92 | } 93 | } 94 | } 95 | -------------------------------------------------------------------------------- /com.github.asus4.onnxruntime.unity/Runtime/Detection.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 1320f9db4a9aa4190a6e9f9cdf079b5f -------------------------------------------------------------------------------- /com.github.asus4.onnxruntime.unity/Runtime/ExecutionProviderOptions.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 3679332aa952e42fda6e1c0210ff32e2 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /com.github.asus4.onnxruntime.unity/Runtime/Extensions.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 3fe3f6421a02c4d2eb7a5f41f4278fa2 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /com.github.asus4.onnxruntime.unity/Runtime/Extensions/AwaitableExtensions.cs: -------------------------------------------------------------------------------- 1 | // Requires Awaitable support 2 | #if UNITY_2023_1_OR_NEWER 3 | 4 | using System.Threading.Tasks; 5 | using UnityEngine; 6 | 7 | namespace Microsoft.ML.OnnxRuntime.Unity 8 | { 9 | public static class AwaitableExtensions 10 | { 11 | 12 | public static async Task AsTask(this Awaitable a) 13 | { 14 | await a; 15 | } 16 | 17 | public static async Task AsTask(this Awaitable a) 18 | { 19 | return await a; 20 | } 21 | } 22 | } 23 | 24 | #endif // UNITY_2023_1_OR_NEWER 25 | -------------------------------------------------------------------------------- /com.github.asus4.onnxruntime.unity/Runtime/Extensions/AwaitableExtensions.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e041f1bb14e5d43a8b899d75aec924c7 -------------------------------------------------------------------------------- /com.github.asus4.onnxruntime.unity/Runtime/Extensions/GraphicsBufferExtension.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using UnityEngine; 3 | using Unity.Collections; 4 | using Unity.Collections.LowLevel.Unsafe; 5 | 6 | namespace Microsoft.ML.OnnxRuntime.Unity 7 | { 8 | /// 9 | /// Extension methods for GraphicsBuffer 10 | /// 11 | public static class GraphicsBufferExtension 12 | { 13 | /// 14 | /// Set Span to GraphicsBuffer without copying 15 | /// 16 | /// A GraphicsBuffer 17 | /// The span data to be set 18 | /// The type of data 19 | public unsafe static void SetData(this GraphicsBuffer buffer, ReadOnlySpan span) 20 | where T : unmanaged 21 | { 22 | fixed (void* ptr = span) 23 | { 24 | var arr = NativeArrayUnsafeUtility.ConvertExistingDataToNativeArray( 25 | ptr, span.Length, Allocator.None); 26 | 27 | #if ENABLE_UNITY_COLLECTIONS_CHECKS 28 | var handle = AtomicSafetyHandle.Create(); 29 | NativeArrayUnsafeUtility.SetAtomicSafetyHandle(ref arr, handle); 30 | #endif // ENABLE_UNITY_COLLECTIONS_CHECKS 31 | 32 | buffer.SetData(arr); 33 | 34 | #if ENABLE_UNITY_COLLECTIONS_CHECKS 35 | AtomicSafetyHandle.Release(handle); 36 | #endif // ENABLE_UNITY_COLLECTIONS_CHECKS 37 | } 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /com.github.asus4.onnxruntime.unity/Runtime/Extensions/GraphicsBufferExtension.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: eeb68aa12a6bb40f3b34784e14242731 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /com.github.asus4.onnxruntime.unity/Runtime/Extensions/InferenceSessionExtension.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Diagnostics; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace Microsoft.ML.OnnxRuntime.Unity 7 | { 8 | /// 9 | /// Extensions for InferenceSession 10 | /// 11 | public static class InferenceSessionExtension 12 | { 13 | /// 14 | /// Log input and output information of the model 15 | /// 16 | /// An InferenceSession 17 | [Conditional("DEVELOPMENT_BUILD"), Conditional("UNITY_EDITOR")] 18 | public static void LogIOInfo(this InferenceSession session) 19 | { 20 | var sb = new StringBuilder(); 21 | 22 | sb.AppendLine($"Version: {OrtEnv.Instance().GetVersionString()}"); 23 | 24 | // Input 25 | bool isDynamicInput = session.InputMetadata.Values.Any(meta => meta.ContainsDynamic()); 26 | sb.AppendLine(isDynamicInput ? "Dynamic Input:" : "Input:"); 27 | foreach (var kv in session.InputMetadata) 28 | { 29 | string key = kv.Key; 30 | NodeMetadata meta = kv.Value; 31 | sb.AppendLine($"[{key}] shape: {string.Join(",", meta.Dimensions)}, type: {meta.ElementType} isTensor: {meta.IsTensor}"); 32 | } 33 | sb.AppendLine(); 34 | 35 | // Output 36 | bool isDynamicOutput = session.OutputMetadata.Values.Any(meta => meta.ContainsDynamic()); 37 | sb.AppendLine(isDynamicOutput ? "Dynamic Output:" : "Output:"); 38 | foreach (var meta in session.OutputMetadata) 39 | { 40 | string key = meta.Key; 41 | NodeMetadata metaValue = meta.Value; 42 | sb.AppendLine($"[{key}] shape: {string.Join(",", metaValue.Dimensions)}, type: {metaValue.ElementType} isTensor: {metaValue.IsTensor}"); 43 | } 44 | 45 | UnityEngine.Debug.Log(sb.ToString()); 46 | } 47 | 48 | /// 49 | /// Create OrtValue from NodeMetadata 50 | /// 51 | /// A metadata 52 | /// Allocated OrtValue, should be disposed. 53 | public static OrtValue CreateTensorOrtValue(this NodeMetadata metadata) 54 | { 55 | if (!metadata.IsTensor) 56 | { 57 | throw new ArgumentException("metadata must be tensor"); 58 | } 59 | if (metadata.ContainsDynamic()) 60 | { 61 | throw new ArgumentException("Allocate manually when contains dynamic dimensions"); 62 | } 63 | long[] shape = Array.ConvertAll(metadata.Dimensions, Convert.ToInt64); 64 | var ortValue = OrtValue.CreateAllocatedTensorValue( 65 | OrtAllocator.DefaultInstance, metadata.ElementDataType, shape); 66 | return ortValue; 67 | } 68 | 69 | /// 70 | /// Checks if the NodeMetadata contains dynamic dimensions. 71 | /// 72 | /// The NodeMetadata to check. 73 | /// True if any dimension is dynamic; otherwise, false. 74 | public static bool ContainsDynamic(this NodeMetadata metadata) 75 | { 76 | return metadata.Dimensions.Any(d => d < 0); 77 | } 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /com.github.asus4.onnxruntime.unity/Runtime/Extensions/InferenceSessionExtension.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 0ab408342909547a091397c3079f7057 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /com.github.asus4.onnxruntime.unity/Runtime/Extensions/MathUtil.cs: -------------------------------------------------------------------------------- 1 | using Unity.Mathematics; 2 | 3 | namespace Microsoft.ML.OnnxRuntime.Unity 4 | { 5 | public static class MathUtil 6 | { 7 | public static int2 ResizeToMaxSize(int2 size, int maxSize, int alignmentSize) 8 | { 9 | if (math.all(size <= maxSize)) 10 | { 11 | return size; 12 | } 13 | 14 | float aspectRatio = (float)size.x / size.y; 15 | float2 sizeF = aspectRatio > 1 16 | ? new float2(maxSize, maxSize / aspectRatio) 17 | : new float2(maxSize * aspectRatio, maxSize); 18 | 19 | // Round to a multiple of 'alignmentSize' 20 | return (int2)math.round(sizeF / alignmentSize) * alignmentSize; 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /com.github.asus4.onnxruntime.unity/Runtime/Extensions/MathUtil.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: def1503f7953b4b88923602b7749867e -------------------------------------------------------------------------------- /com.github.asus4.onnxruntime.unity/Runtime/Extensions/RectExtension.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Runtime.CompilerServices; 3 | using UnityEngine; 4 | using UnityEngine.Assertions; 5 | 6 | namespace Microsoft.ML.OnnxRuntime.Unity 7 | { 8 | /// 9 | /// Extension methods for Rect 10 | /// 11 | public static class RectExtension 12 | { 13 | /// 14 | /// Returns the area of the rectangle 15 | /// 16 | /// A Rect 17 | /// A area 18 | [MethodImpl(MethodImplOptions.AggressiveInlining)] 19 | public static float Area(this in Rect rect) 20 | { 21 | return Math.Abs(rect.width * rect.height); 22 | } 23 | 24 | /// 25 | /// Create intersection rectangle of two rectangles 26 | /// 27 | /// A rect 28 | /// Another rect 29 | /// An intersection rect 30 | /// Return true if the rectangles intersect 31 | [MethodImpl(MethodImplOptions.AggressiveInlining)] 32 | public static bool IntersectionRect(this in Rect rect0, in Rect rect1, out Rect intersection) 33 | { 34 | float intersect_xMin = Math.Max(rect0.xMin, rect1.xMin); 35 | float intersect_yMin = Math.Max(rect0.yMin, rect1.yMin); 36 | float intersect_xMax = Math.Min(rect0.xMax, rect1.xMax); 37 | float intersect_yMax = Math.Min(rect0.yMax, rect1.yMax); 38 | 39 | if (intersect_xMin > intersect_xMax || intersect_yMin > intersect_yMax) 40 | { 41 | intersection = Rect.zero; 42 | return false; 43 | } 44 | intersection = new Rect(intersect_xMin, intersect_yMin, intersect_xMax - intersect_xMin, intersect_yMax - intersect_yMin); 45 | return true; 46 | } 47 | 48 | /// 49 | /// Returns the IoU (intersection over union) of two rectangles 50 | /// See also: 51 | /// https://en.wikipedia.org/wiki/Jaccard_index 52 | /// 53 | /// A rect 54 | /// A rect 55 | /// IoU 56 | [MethodImpl(MethodImplOptions.AggressiveInlining)] 57 | public static float IntersectionOverUnion(this in Rect rect0, in Rect rect1) 58 | { 59 | // Don't allow inverted rectangles 60 | Assert.IsTrue(rect0.width >= 0 && rect0.height >= 0); 61 | Assert.IsTrue(rect1.width >= 0 && rect1.height >= 0); 62 | 63 | float area0 = rect0.Area(); 64 | float area1 = rect1.Area(); 65 | if (area0 <= 0 || area1 <= 0) 66 | { 67 | return 0.0f; 68 | } 69 | if (!IntersectionRect(rect0, rect1, out Rect intersection)) 70 | { 71 | return 0.0f; 72 | } 73 | 74 | float intersectArea = intersection.Area(); 75 | return intersectArea / (area0 + area1 - intersectArea); 76 | } 77 | 78 | /// 79 | /// Flip Y axis, useful for converting between CV and Unity space 80 | /// 81 | /// A rect 82 | /// Height of the space 83 | /// A flipped rect 84 | [MethodImpl(MethodImplOptions.AggressiveInlining)] 85 | public static Rect FlipY(this in Rect rect, float height = 1f) 86 | { 87 | return new Rect(rect.x, height - rect.yMax, rect.width, rect.height); 88 | } 89 | } 90 | } 91 | -------------------------------------------------------------------------------- /com.github.asus4.onnxruntime.unity/Runtime/Extensions/RectExtension.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: feed9c2a73f474eedb3233ecaa11f5f1 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /com.github.asus4.onnxruntime.unity/Runtime/FilePopupAttribute.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using System.IO; 4 | using System.Linq; 5 | 6 | using UnityEngine; 7 | #if UNITY_EDITOR 8 | using UnityEditor; 9 | #endif // UNITY_EDITOR 10 | 11 | namespace Microsoft.ML.OnnxRuntime.Unity 12 | { 13 | /// 14 | /// A attribute for "string" that selects relative file path from StreamingAssets folder. 15 | /// 16 | public sealed class FilePopupAttribute : PropertyAttribute 17 | { 18 | public string regex; 19 | 20 | public FilePopupAttribute(string searchPattern) 21 | { 22 | this.regex = searchPattern; 23 | } 24 | } 25 | 26 | #if UNITY_EDITOR 27 | [CustomPropertyDrawer(typeof(FilePopupAttribute))] 28 | public class FilePopupDrawer : PropertyDrawer 29 | { 30 | string[] displayNames = null; 31 | int selectedIndex = -1; 32 | 33 | public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) 34 | { 35 | if (property.propertyType != SerializedPropertyType.String) 36 | { 37 | Debug.LogError($"type: {property.propertyType} is not supported."); 38 | EditorGUI.LabelField(position, label.text, "Use FilePopup with string."); 39 | return; 40 | } 41 | 42 | if (displayNames == null) 43 | { 44 | string regex = (attribute as FilePopupAttribute).regex; 45 | InitDisplayNames(regex); 46 | } 47 | 48 | if (selectedIndex < 0) 49 | { 50 | selectedIndex = FindSelectedIndex(property.stringValue); 51 | } 52 | 53 | EditorGUI.BeginProperty(position, label, property); 54 | 55 | selectedIndex = EditorGUI.Popup(position, label.text, selectedIndex, displayNames); 56 | property.stringValue = displayNames[selectedIndex]; 57 | 58 | EditorGUI.EndProperty(); 59 | } 60 | 61 | void InitDisplayNames(string regex) 62 | { 63 | string[] fullPaths = Directory.GetFiles(Application.streamingAssetsPath, regex, SearchOption.AllDirectories); 64 | 65 | displayNames = fullPaths.Select(f => 66 | { 67 | string path = f.Replace(Application.streamingAssetsPath, "") 68 | .Replace('\\', '/'); 69 | if (path.StartsWith("/")) 70 | { 71 | path = path.Substring(1); 72 | } 73 | return path; 74 | }).ToArray(); 75 | } 76 | 77 | int FindSelectedIndex(string value) 78 | { 79 | for (int i = 0; i < displayNames.Length; i++) 80 | { 81 | if (displayNames[i] == value) 82 | { 83 | return i; 84 | } 85 | } 86 | return 0; 87 | } 88 | } 89 | #endif // UNITY_EDITOR 90 | 91 | } 92 | -------------------------------------------------------------------------------- /com.github.asus4.onnxruntime.unity/Runtime/FilePopupAttribute.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 0095496baa13a408e9f76d9ea376306a 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /com.github.asus4.onnxruntime.unity/Runtime/ImageInference.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 0644ac8d16ba24b778511fbad549f7b6 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /com.github.asus4.onnxruntime.unity/Runtime/ImageInferenceOptions.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using UnityEngine; 3 | 4 | namespace Microsoft.ML.OnnxRuntime.Unity 5 | { 6 | public enum AspectMode 7 | { 8 | /// 9 | /// Resizes the image without keeping the aspect ratio. 10 | /// 11 | None = 0, 12 | /// 13 | /// Resizes the image to contain full area and padded black pixels. 14 | /// 15 | Fit = 1, 16 | /// 17 | /// Trims the image to keep aspect ratio. 18 | /// 19 | Fill = 2, 20 | } 21 | 22 | 23 | 24 | /// 25 | /// An option to create a Image inference 26 | /// 27 | [Serializable] 28 | public class ImageInferenceOptions 29 | { 30 | [Header("Image Preprocessing")] 31 | [Tooltip("How to resize the image")] 32 | public AspectMode aspectMode = AspectMode.Fit; 33 | public Vector3 mean = new(0.485f, 0.456f, 0.406f); 34 | public Vector3 std = new(0.229f, 0.224f, 0.225f); 35 | 36 | public ExecutionProviderOptions executionProvider; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /com.github.asus4.onnxruntime.unity/Runtime/ImageInferenceOptions.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 8399e552d617341eaa74daec8b1857ae 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /com.github.asus4.onnxruntime.unity/Runtime/OrtAsset.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | namespace Microsoft.ML.OnnxRuntime.Unity 4 | { 5 | /// 6 | /// Simple asset to hold *.ort and *.onnx file as byte array 7 | /// 8 | /// *.onnx can be imported only when com.unity.sentis is NOT installed 9 | /// 10 | public class OrtAsset : ScriptableObject 11 | { 12 | [HideInInspector] 13 | public byte[] bytes; 14 | 15 | #if UNITY_EDITOR 16 | private void OnValidate() 17 | { 18 | // Warn when file is LFS pointer 19 | const string LSF_HEADER = "version https://git-lfs.github.com/spec/"; 20 | if (bytes.Length > LSF_HEADER.Length) 21 | { 22 | string header = System.Text.Encoding.UTF8.GetString(bytes, 0, LSF_HEADER.Length); 23 | if (header == LSF_HEADER) 24 | { 25 | Debug.LogError("This is LFS file. Please use 'git lfs pull' to download the actual file.", this); 26 | } 27 | } 28 | } 29 | #endif // UNITY_EDITOR 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /com.github.asus4.onnxruntime.unity/Runtime/OrtAsset.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 75aa82bfc638143a0bcdfa0d43a6480b 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /com.github.asus4.onnxruntime.unity/Runtime/OrtUnityEnv.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.IO; 3 | using System.Runtime.InteropServices; 4 | using UnityEngine; 5 | 6 | namespace Microsoft.ML.OnnxRuntime.Unity 7 | { 8 | /// 9 | /// Provides Unity specific environment variables for ONNX Runtime 10 | /// 11 | public static class OrtUnityEnv 12 | { 13 | // OnnxRuntime-GenAI requires `ORT_LIB_PATH` environment variable to load the dynamic library 14 | // https://github.com/microsoft/onnxruntime-genai/blob/a763c441713ef0623a35240ec90f4311f1da35e8/src/models/onnxruntime_api.h#L230-L235 15 | const string OrtLibPathEnv = "ORT_LIB_PATH"; 16 | 17 | public static void InitializeOrtLibPath() 18 | { 19 | string libPath = GetOrtLibPath(); 20 | if (string.IsNullOrEmpty(libPath)) 21 | { 22 | Debug.Log($"{OrtLibPathEnv}: Not set."); 23 | return; 24 | } 25 | 26 | Environment.SetEnvironmentVariable(OrtLibPathEnv, libPath); 27 | Debug.Log($"{OrtLibPathEnv}: {libPath}"); 28 | } 29 | 30 | internal static string GetOrtLibPath() 31 | { 32 | string archPrefix = RuntimeInformation.ProcessArchitecture switch 33 | { 34 | Architecture.X86 => "x86", 35 | Architecture.X64 => "x64", 36 | Architecture.Arm => "arm", 37 | Architecture.Arm64 => "arm64", 38 | _ => throw new NotSupportedException($"Unknown architecture: {RuntimeInformation.ProcessArchitecture}") 39 | }; 40 | 41 | string PluginPath = Path.GetFullPath("Packages/com.github.asus4.onnxruntime/Plugins"); 42 | return Application.platform switch 43 | { 44 | RuntimePlatform.OSXEditor => Path.Combine(PluginPath, "macOS", archPrefix, "libonnxruntime.dylib"), 45 | RuntimePlatform.OSXPlayer => throw new NotImplementedException(), 46 | RuntimePlatform.LinuxEditor => Path.Combine(PluginPath, "Linux", archPrefix, "libonnxruntime.so"), 47 | RuntimePlatform.LinuxPlayer => throw new NotImplementedException(), 48 | // No need to set ORT_LIB_PATH for other platforms 49 | _ => string.Empty 50 | }; 51 | } 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /com.github.asus4.onnxruntime.unity/Runtime/OrtUnityEnv.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 28cf502d177644ff182c194ef23f1bea -------------------------------------------------------------------------------- /com.github.asus4.onnxruntime.unity/Runtime/RemoteFile.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 645b6de2d9abe4188a8b63dd6fa7e841 -------------------------------------------------------------------------------- /com.github.asus4.onnxruntime.unity/Runtime/TextureToTensor.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a511feca3f9814a44ad0da88ebf8a6b3 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /com.github.asus4.onnxruntime.unity/Runtime/com.github.asus4.onnxruntime.unity.asmdef: -------------------------------------------------------------------------------- 1 | { 2 | "name": "com.github.asus4.onnxruntime.unity", 3 | "rootNamespace": "", 4 | "references": [ 5 | "GUID:8600c83db57f44fe2aa05f4cf22420bf", 6 | "GUID:e0cd26848372d4e5c891c569017e11f1", 7 | "GUID:d8b63aba1907145bea998dd612889d6b" 8 | ], 9 | "includePlatforms": [], 10 | "excludePlatforms": [], 11 | "allowUnsafeCode": true, 12 | "overrideReferences": false, 13 | "precompiledReferences": [], 14 | "autoReferenced": true, 15 | "defineConstraints": [], 16 | "versionDefines": [], 17 | "noEngineReferences": false 18 | } -------------------------------------------------------------------------------- /com.github.asus4.onnxruntime.unity/Runtime/com.github.asus4.onnxruntime.unity.asmdef.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: effe5775fa53c49a39f54ea0433a395b 3 | AssemblyDefinitionImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /com.github.asus4.onnxruntime.unity/Tests.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d6522fb3187a34575a6b04c1ce905912 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /com.github.asus4.onnxruntime.unity/Tests/MathUtilsTest.cs: -------------------------------------------------------------------------------- 1 | using NUnit.Framework; 2 | using Unity.Mathematics; 3 | 4 | namespace Microsoft.ML.OnnxRuntime.Unity.Tests 5 | { 6 | public class MathUtilsTest 7 | { 8 | [TestCase(1000, 560, 1920, 1080, 1000, 8)] // landscape 9 | [TestCase(560, 1000, 1080, 1920, 1000, 8)] // portrait 10 | public void TestResizeToMaxSize(int expectedX, int expectedY, int inputX, int inputY, int maxSize, int alignmentSize) 11 | { 12 | var expected = new int2(expectedX, expectedY); 13 | var input = new int2(inputX, inputY); 14 | var actual = MathUtil.ResizeToMaxSize(input, maxSize, alignmentSize); 15 | Assert.AreEqual(expected.x, actual.x); 16 | Assert.AreEqual(expected.y, actual.y); 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /com.github.asus4.onnxruntime.unity/Tests/MathUtilsTest.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 9e2cd9a77b0da4aa79eacd90180ff8de -------------------------------------------------------------------------------- /com.github.asus4.onnxruntime.unity/Tests/OrtUnityEnvTest.cs: -------------------------------------------------------------------------------- 1 | using System.IO; 2 | using NUnit.Framework; 3 | 4 | namespace Microsoft.ML.OnnxRuntime.Unity.Tests 5 | { 6 | public class OrtUnityEnvTest 7 | { 8 | [Test] 9 | public void GetOrtLibPathExists() 10 | { 11 | string libPath = OrtUnityEnv.GetOrtLibPath(); 12 | Assert.IsTrue(File.Exists(libPath), $"{libPath} does not exist"); 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /com.github.asus4.onnxruntime.unity/Tests/OrtUnityEnvTest.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 1b1ee91e4cd764e59b8b00858b7fa814 -------------------------------------------------------------------------------- /com.github.asus4.onnxruntime.unity/Tests/com.github.asus4.onnxruntime.unity.tests.asmdef: -------------------------------------------------------------------------------- 1 | { 2 | "name": "com.github.asus4.onnxruntime.unity.tests", 3 | "rootNamespace": "Microsoft.ML.OnnxRuntime.Unity.Tests", 4 | "references": [ 5 | "GUID:effe5775fa53c49a39f54ea0433a395b", 6 | "GUID:d8b63aba1907145bea998dd612889d6b" 7 | ], 8 | "includePlatforms": [ 9 | "Editor" 10 | ], 11 | "excludePlatforms": [], 12 | "allowUnsafeCode": false, 13 | "overrideReferences": false, 14 | "precompiledReferences": [ 15 | "nunit.framework.dll", 16 | "Newtonsoft.Json.dll" 17 | ], 18 | "autoReferenced": false, 19 | "defineConstraints": [], 20 | "versionDefines": [], 21 | "noEngineReferences": false 22 | } -------------------------------------------------------------------------------- /com.github.asus4.onnxruntime.unity/Tests/com.github.asus4.onnxruntime.unity.tests.asmdef.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 80a838cdb3e134225b61f65f345d4275 3 | AssemblyDefinitionImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /com.github.asus4.onnxruntime.unity/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "com.github.asus4.onnxruntime.unity", 3 | "version": "0.4.0", 4 | "displayName": "ONNX Runtime Unity Utilities", 5 | "description": "ONNX Runtime Utilities for Unity", 6 | "keywords": [ 7 | "unity", 8 | "onnxruntime" 9 | ], 10 | "unity": "2022.3", 11 | "unityRelease": "0f1", 12 | "dependencies": { 13 | "com.github.asus4.onnxruntime": "0.4.0" 14 | }, 15 | "repository": { 16 | "type": "git", 17 | "repository": "https://github.com/asus4/onnxruntime-unity.git" 18 | }, 19 | "documentationUrl": "https://github.com/asus4/onnxruntime-unity", 20 | "changelogUrl": "https://github.com/asus4/onnxruntime-unity/releases", 21 | "licensesUrl": "https://github.com/asus4/onnxruntime-unity/blob/main/com.github.asus4.onnxruntime.unity/LICENSE", 22 | "author": { 23 | "name": "Koki Ibukuro", 24 | "url": "https://github.com/asus4" 25 | } 26 | } -------------------------------------------------------------------------------- /com.github.asus4.onnxruntime.unity/package.json.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a4f0ea547429e46f8bbdd3e58abf14bf 3 | PackageManifestImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /com.github.asus4.onnxruntime.win-x64-gpu/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) Microsoft Corporation. 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE 22 | -------------------------------------------------------------------------------- /com.github.asus4.onnxruntime.win-x64-gpu/LICENSE.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 84be003c42c32486fb62318efe2ec03d 3 | DefaultImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /com.github.asus4.onnxruntime.win-x64-gpu/Plugins.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 978a6b27e76bb414389f3b6ce646a5a8 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /com.github.asus4.onnxruntime.win-x64-gpu/Plugins/Windows.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 460bfd7931eba449b8184089a4899f77 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /com.github.asus4.onnxruntime.win-x64-gpu/Plugins/Windows/x64.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 8e72c6e2ac9b3495aad14c5de160b076 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /com.github.asus4.onnxruntime.win-x64-gpu/Plugins/Windows/x64/onnxruntime_providers_cuda.dll.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e4d8ff3193790474f84ee53f113fedb7 3 | PluginImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | iconMap: {} 7 | executionOrder: {} 8 | defineConstraints: [] 9 | isPreloaded: 0 10 | isOverridable: 1 11 | isExplicitlyReferenced: 0 12 | validateReferences: 1 13 | platformData: 14 | - first: 15 | : Any 16 | second: 17 | enabled: 0 18 | settings: 19 | Exclude Android: 1 20 | Exclude Editor: 0 21 | Exclude Linux64: 0 22 | Exclude OSXUniversal: 0 23 | Exclude Win: 1 24 | Exclude Win64: 0 25 | Exclude iOS: 1 26 | - first: 27 | Android: Android 28 | second: 29 | enabled: 0 30 | settings: 31 | AndroidSharedLibraryType: Executable 32 | CPU: ARMv7 33 | - first: 34 | Any: 35 | second: 36 | enabled: 0 37 | settings: {} 38 | - first: 39 | Editor: Editor 40 | second: 41 | enabled: 1 42 | settings: 43 | CPU: x86_64 44 | DefaultValueInitialized: true 45 | OS: Windows 46 | - first: 47 | Standalone: Linux64 48 | second: 49 | enabled: 1 50 | settings: 51 | CPU: AnyCPU 52 | - first: 53 | Standalone: OSXUniversal 54 | second: 55 | enabled: 1 56 | settings: 57 | CPU: AnyCPU 58 | - first: 59 | Standalone: Win 60 | second: 61 | enabled: 0 62 | settings: 63 | CPU: AnyCPU 64 | - first: 65 | Standalone: Win64 66 | second: 67 | enabled: 1 68 | settings: 69 | CPU: AnyCPU 70 | - first: 71 | iPhone: iOS 72 | second: 73 | enabled: 0 74 | settings: 75 | AddToEmbeddedBinaries: false 76 | CPU: AnyCPU 77 | CompileFlags: 78 | FrameworkDependencies: 79 | userData: 80 | assetBundleName: 81 | assetBundleVariant: 82 | -------------------------------------------------------------------------------- /com.github.asus4.onnxruntime.win-x64-gpu/Plugins/Windows/x64/onnxruntime_providers_shared.dll.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 45c3e06d012b84662afd9641de22d8fa 3 | PluginImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | iconMap: {} 7 | executionOrder: {} 8 | defineConstraints: [] 9 | isPreloaded: 0 10 | isOverridable: 1 11 | isExplicitlyReferenced: 0 12 | validateReferences: 1 13 | platformData: 14 | - first: 15 | : Any 16 | second: 17 | enabled: 0 18 | settings: 19 | Exclude Android: 1 20 | Exclude Editor: 0 21 | Exclude Linux64: 0 22 | Exclude OSXUniversal: 0 23 | Exclude Win: 1 24 | Exclude Win64: 0 25 | Exclude iOS: 1 26 | - first: 27 | Android: Android 28 | second: 29 | enabled: 0 30 | settings: 31 | AndroidSharedLibraryType: Executable 32 | CPU: ARMv7 33 | - first: 34 | Any: 35 | second: 36 | enabled: 0 37 | settings: {} 38 | - first: 39 | Editor: Editor 40 | second: 41 | enabled: 1 42 | settings: 43 | CPU: x86_64 44 | DefaultValueInitialized: true 45 | OS: Windows 46 | - first: 47 | Standalone: Linux64 48 | second: 49 | enabled: 1 50 | settings: 51 | CPU: AnyCPU 52 | - first: 53 | Standalone: OSXUniversal 54 | second: 55 | enabled: 1 56 | settings: 57 | CPU: AnyCPU 58 | - first: 59 | Standalone: Win 60 | second: 61 | enabled: 0 62 | settings: 63 | CPU: AnyCPU 64 | - first: 65 | Standalone: Win64 66 | second: 67 | enabled: 1 68 | settings: 69 | CPU: AnyCPU 70 | - first: 71 | iPhone: iOS 72 | second: 73 | enabled: 0 74 | settings: 75 | AddToEmbeddedBinaries: false 76 | CPU: AnyCPU 77 | CompileFlags: 78 | FrameworkDependencies: 79 | userData: 80 | assetBundleName: 81 | assetBundleVariant: 82 | -------------------------------------------------------------------------------- /com.github.asus4.onnxruntime.win-x64-gpu/Plugins/Windows/x64/onnxruntime_providers_tensorrt.dll.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 1bcfaed937a4343abbf36f6bb158e6bc 3 | PluginImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | iconMap: {} 7 | executionOrder: {} 8 | defineConstraints: [] 9 | isPreloaded: 0 10 | isOverridable: 1 11 | isExplicitlyReferenced: 0 12 | validateReferences: 1 13 | platformData: 14 | - first: 15 | : Any 16 | second: 17 | enabled: 0 18 | settings: 19 | Exclude Android: 1 20 | Exclude Editor: 0 21 | Exclude Linux64: 0 22 | Exclude OSXUniversal: 0 23 | Exclude Win: 1 24 | Exclude Win64: 0 25 | Exclude iOS: 1 26 | - first: 27 | Android: Android 28 | second: 29 | enabled: 0 30 | settings: 31 | AndroidSharedLibraryType: Executable 32 | CPU: ARMv7 33 | - first: 34 | Any: 35 | second: 36 | enabled: 0 37 | settings: {} 38 | - first: 39 | Editor: Editor 40 | second: 41 | enabled: 1 42 | settings: 43 | CPU: x86_64 44 | DefaultValueInitialized: true 45 | OS: Windows 46 | - first: 47 | Standalone: Linux64 48 | second: 49 | enabled: 1 50 | settings: 51 | CPU: AnyCPU 52 | - first: 53 | Standalone: OSXUniversal 54 | second: 55 | enabled: 1 56 | settings: 57 | CPU: AnyCPU 58 | - first: 59 | Standalone: Win 60 | second: 61 | enabled: 0 62 | settings: 63 | CPU: AnyCPU 64 | - first: 65 | Standalone: Win64 66 | second: 67 | enabled: 1 68 | settings: 69 | CPU: AnyCPU 70 | - first: 71 | iPhone: iOS 72 | second: 73 | enabled: 0 74 | settings: 75 | AddToEmbeddedBinaries: false 76 | CPU: AnyCPU 77 | CompileFlags: 78 | FrameworkDependencies: 79 | userData: 80 | assetBundleName: 81 | assetBundleVariant: 82 | -------------------------------------------------------------------------------- /com.github.asus4.onnxruntime.win-x64-gpu/README.md: -------------------------------------------------------------------------------- 1 | # ONNX Runtime Plugin for Unity 2 | -------------------------------------------------------------------------------- /com.github.asus4.onnxruntime.win-x64-gpu/README.md.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 2ac475c0ff88d4f68979b6268824338a 3 | TextScriptImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /com.github.asus4.onnxruntime.win-x64-gpu/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "com.github.asus4.onnxruntime.win-x64-gpu", 3 | "version": "0.4.0", 4 | "displayName": "ONNX Runtime - Windows x64 GPU", 5 | "description": "ONNX Runtime for Unity - Windows x64 GPU Provider", 6 | "keywords": [ 7 | "unity", 8 | "onnxruntime" 9 | ], 10 | "unity": "2022.3", 11 | "unityRelease": "0f1", 12 | "dependencies": { 13 | "com.github.asus4.onnxruntime": "0.4.0" 14 | }, 15 | "repository": { 16 | "type": "git", 17 | "repository": "https://github.com/asus4/onnxruntime-unity.git" 18 | }, 19 | "documentationUrl": "https://github.com/asus4/onnxruntime-unity", 20 | "changelogUrl": "https://github.com/asus4/onnxruntime-unity/releases", 21 | "licensesUrl": "https://github.com/asus4/onnxruntime-unity/blob/main/onnxruntime.win-x64-gpu/LICENSE", 22 | "author": { 23 | "name": "Koki Ibukuro", 24 | "url": "https://github.com/asus4" 25 | } 26 | } -------------------------------------------------------------------------------- /com.github.asus4.onnxruntime.win-x64-gpu/package.json.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 7659f29c6e724412d89c5fb2d48688d3 3 | PackageManifestImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /com.github.asus4.onnxruntime/Editor.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 0a14dd0bc96f84c139228fb7dfa5c824 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /com.github.asus4.onnxruntime/Editor/OrtPostProcessBuild.cs: -------------------------------------------------------------------------------- 1 | using System.IO; 2 | using UnityEngine; 3 | using UnityEngine.Assertions; 4 | using UnityEditor; 5 | using UnityEditor.Build; 6 | using UnityEditor.Build.Reporting; 7 | 8 | #if UNITY_IOS 9 | using UnityEditor.iOS.Xcode; 10 | using UnityEditor.iOS.Xcode.Extensions; 11 | #endif // UNITY_IOS 12 | 13 | namespace Microsoft.ML.OnnxRuntime.Editor 14 | { 15 | /// 16 | /// Custom post-process build for ONNX Runtime 17 | /// 18 | public class OrtPostProcessBuild : IPostprocessBuildWithReport 19 | { 20 | const string PACKAGE_PATH = "Packages/com.github.asus4.onnxruntime"; 21 | const string FRAMEWORK_SRC = "Plugins/iOS~/onnxruntime.xcframework"; 22 | const string FRAMEWORK_DST = "Libraries/onnxruntime.xcframework"; 23 | 24 | public int callbackOrder => 0; 25 | 26 | public void OnPostprocessBuild(BuildReport report) 27 | { 28 | switch (report.summary.platform) 29 | { 30 | case BuildTarget.iOS: 31 | CopyOrtXCFramework(report, 32 | PACKAGE_PATH, 33 | FRAMEWORK_SRC, 34 | FRAMEWORK_DST); 35 | break; 36 | } 37 | } 38 | 39 | /// 40 | /// A common method that copies and sets options for ONNX Runtime XCFramework in iOS 41 | /// 42 | /// A build report 43 | /// A package path starting from "Packages/com.domain.package" 44 | /// A source XCFramework path 45 | /// A destination XCFramework path 46 | public static void CopyOrtXCFramework( 47 | BuildReport report, 48 | string packagePath, 49 | string frameworkSrcPath, 50 | string frameworkDstPath) 51 | { 52 | #if UNITY_IOS 53 | string pbxProjectPath = PBXProject.GetPBXProjectPath(report.summary.outputPath); 54 | PBXProject pbxProject = new(); 55 | pbxProject.ReadFromFile(pbxProjectPath); 56 | 57 | // Copy XCFramework to the Xcode project folder 58 | string frameworkSrcAbsPath = Path.Combine(packagePath, frameworkSrcPath); 59 | string frameworkDstAbsPath = Path.Combine(report.summary.outputPath, frameworkDstPath); 60 | CopyDirectory(frameworkSrcAbsPath, frameworkDstAbsPath); 61 | 62 | // Then add to Xcode project 63 | string frameworkGuid = pbxProject.AddFile(frameworkDstAbsPath, frameworkDstPath, PBXSourceTree.Source); 64 | string unityTargetGuid = pbxProject.GetUnityFrameworkTargetGuid(); 65 | string targetBuildPhaseGuid = pbxProject.AddFrameworksBuildPhase(unityTargetGuid); 66 | pbxProject.AddFileToBuildSection(unityTargetGuid, targetBuildPhaseGuid, frameworkGuid); 67 | 68 | #if ORT_GENAI_ENABLED 69 | // NOTE: Required only when GenAI package is installed 70 | // GenAI loads the dynamic library in runtime. need to embed in the main target 71 | string mainTargetGuid = pbxProject.GetUnityMainTargetGuid(); 72 | pbxProject.AddFileToEmbedFrameworks(mainTargetGuid, frameworkGuid); 73 | #endif // ORT_GENAI_ENABLED 74 | 75 | pbxProject.WriteToFile(pbxProjectPath); 76 | #endif // UNITY_IOS 77 | } 78 | 79 | static void CopyDirectory(string source, string dest) 80 | { 81 | if (Directory.Exists(dest) && !FileUtil.DeleteFileOrDirectory(dest)) 82 | { 83 | throw new IOException($"Failed to delete directory '{dest}'."); 84 | } 85 | FileUtil.CopyFileOrDirectoryFollowSymlinks(source, dest); 86 | } 87 | } 88 | } 89 | -------------------------------------------------------------------------------- /com.github.asus4.onnxruntime/Editor/OrtPostProcessBuild.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e487cab40ce8f4fce81e6f71b6185d49 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /com.github.asus4.onnxruntime/Editor/com.github.asus4.onnxruntime.Editor.asmdef: -------------------------------------------------------------------------------- 1 | { 2 | "name": "com.github.asus4.onnxruntime.Editor", 3 | "rootNamespace": "", 4 | "references": [], 5 | "includePlatforms": [ 6 | "Editor" 7 | ], 8 | "excludePlatforms": [], 9 | "allowUnsafeCode": false, 10 | "overrideReferences": false, 11 | "precompiledReferences": [], 12 | "autoReferenced": true, 13 | "defineConstraints": [], 14 | "versionDefines": [ 15 | { 16 | "name": "com.github.asus4.onnxruntime-genai", 17 | "expression": "0.4.0", 18 | "define": "ORT_GENAI_ENABLED" 19 | } 20 | ], 21 | "noEngineReferences": false 22 | } -------------------------------------------------------------------------------- /com.github.asus4.onnxruntime/Editor/com.github.asus4.onnxruntime.Editor.asmdef.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 0c2a693589505475cb8d7d2c2778d73c 3 | AssemblyDefinitionImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /com.github.asus4.onnxruntime/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) Microsoft Corporation 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /com.github.asus4.onnxruntime/LICENSE.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 95f70f5c4aff244d1975845f5eace900 3 | DefaultImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /com.github.asus4.onnxruntime/Plugins.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a54ee2e44bb7a46cfb7cbcadcd25cfde 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /com.github.asus4.onnxruntime/Plugins/Android.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 72046e439c64d419db5fbd3ce4800566 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /com.github.asus4.onnxruntime/Plugins/Android/onnxruntime.aar.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 87f598eb2fd64491c9917d2255b00a1b 3 | PluginImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | iconMap: {} 7 | executionOrder: {} 8 | defineConstraints: [] 9 | isPreloaded: 1 10 | isOverridable: 1 11 | isExplicitlyReferenced: 0 12 | validateReferences: 1 13 | platformData: 14 | - first: 15 | : Any 16 | second: 17 | enabled: 0 18 | settings: 19 | Exclude Android: 0 20 | Exclude Editor: 1 21 | Exclude Linux64: 1 22 | Exclude OSXUniversal: 1 23 | Exclude Win: 1 24 | Exclude Win64: 1 25 | Exclude iOS: 1 26 | - first: 27 | Android: Android 28 | second: 29 | enabled: 1 30 | settings: 31 | AndroidSharedLibraryType: Executable 32 | CPU: ARMv7 33 | - first: 34 | Any: 35 | second: 36 | enabled: 0 37 | settings: {} 38 | - first: 39 | Editor: Editor 40 | second: 41 | enabled: 0 42 | settings: 43 | CPU: AnyCPU 44 | DefaultValueInitialized: true 45 | OS: AnyOS 46 | - first: 47 | Standalone: Linux64 48 | second: 49 | enabled: 0 50 | settings: 51 | CPU: AnyCPU 52 | - first: 53 | Standalone: OSXUniversal 54 | second: 55 | enabled: 0 56 | settings: 57 | CPU: AnyCPU 58 | - first: 59 | Standalone: Win 60 | second: 61 | enabled: 0 62 | settings: 63 | CPU: AnyCPU 64 | - first: 65 | Standalone: Win64 66 | second: 67 | enabled: 0 68 | settings: 69 | CPU: AnyCPU 70 | - first: 71 | iPhone: iOS 72 | second: 73 | enabled: 0 74 | settings: 75 | AddToEmbeddedBinaries: false 76 | CPU: AnyCPU 77 | CompileFlags: 78 | FrameworkDependencies: 79 | userData: 80 | assetBundleName: 81 | assetBundleVariant: 82 | -------------------------------------------------------------------------------- /com.github.asus4.onnxruntime/Plugins/Linux.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: dbd44da5c6c0e4b80b52fccdb5203789 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /com.github.asus4.onnxruntime/Plugins/Linux/x64.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c5d8c64046b444d73841eb16582662e7 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /com.github.asus4.onnxruntime/Plugins/Linux/x64/libonnxruntime.so.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b27b30e4e87554214b41504abd9a3755 3 | PluginImporter: 4 | externalObjects: {} 5 | serializedVersion: 3 6 | iconMap: {} 7 | executionOrder: {} 8 | defineConstraints: [] 9 | isPreloaded: 0 10 | isOverridable: 1 11 | isExplicitlyReferenced: 0 12 | validateReferences: 1 13 | platformData: 14 | Android: 15 | enabled: 0 16 | settings: 17 | AndroidLibraryDependee: UnityLibrary 18 | AndroidSharedLibraryType: Executable 19 | CPU: ARMv7 20 | Any: 21 | enabled: 0 22 | settings: 23 | Exclude Android: 1 24 | Exclude Editor: 0 25 | Exclude Linux64: 0 26 | Exclude OSXUniversal: 1 27 | Exclude Win: 0 28 | Exclude Win64: 0 29 | Exclude iOS: 1 30 | Editor: 31 | enabled: 1 32 | settings: 33 | CPU: x86_64 34 | DefaultValueInitialized: true 35 | OS: Linux 36 | Linux64: 37 | enabled: 1 38 | settings: 39 | CPU: AnyCPU 40 | OSXUniversal: 41 | enabled: 0 42 | settings: 43 | CPU: None 44 | Win: 45 | enabled: 1 46 | settings: 47 | CPU: AnyCPU 48 | Win64: 49 | enabled: 1 50 | settings: 51 | CPU: AnyCPU 52 | iOS: 53 | enabled: 0 54 | settings: 55 | AddToEmbeddedBinaries: false 56 | CPU: AnyCPU 57 | CompileFlags: 58 | FrameworkDependencies: 59 | userData: 60 | assetBundleName: 61 | assetBundleVariant: 62 | -------------------------------------------------------------------------------- /com.github.asus4.onnxruntime/Plugins/Windows.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 37684b2fa24884bd0997e89174d99413 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /com.github.asus4.onnxruntime/Plugins/Windows/arm64.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 6894ed7dde13749a697ae4fd202bb867 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /com.github.asus4.onnxruntime/Plugins/Windows/arm64/onnxruntime.dll.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 02ed5287ee9c84ec48102a291c5c41f6 3 | PluginImporter: 4 | externalObjects: {} 5 | serializedVersion: 3 6 | iconMap: {} 7 | executionOrder: {} 8 | defineConstraints: [] 9 | isPreloaded: 0 10 | isOverridable: 1 11 | isExplicitlyReferenced: 0 12 | validateReferences: 1 13 | platformData: 14 | Android: 15 | enabled: 0 16 | settings: 17 | AndroidLibraryDependee: UnityLibrary 18 | AndroidSharedLibraryType: Executable 19 | CPU: ARMv7 20 | Any: 21 | enabled: 0 22 | settings: 23 | Exclude Android: 1 24 | Exclude Editor: 0 25 | Exclude Linux64: 1 26 | Exclude OSXUniversal: 1 27 | Exclude Win: 1 28 | Exclude Win64: 0 29 | Exclude iOS: 1 30 | Editor: 31 | enabled: 1 32 | settings: 33 | CPU: ARM64 34 | DefaultValueInitialized: true 35 | OS: Windows 36 | Linux64: 37 | enabled: 0 38 | settings: 39 | CPU: x86_64 40 | OSXUniversal: 41 | enabled: 0 42 | settings: 43 | CPU: None 44 | Win: 45 | enabled: 0 46 | settings: 47 | CPU: None 48 | Win64: 49 | enabled: 1 50 | settings: 51 | CPU: ARM64 52 | WindowsStoreApps: 53 | enabled: 0 54 | settings: 55 | CPU: ARM64 56 | iOS: 57 | enabled: 0 58 | settings: 59 | AddToEmbeddedBinaries: false 60 | CPU: AnyCPU 61 | CompileFlags: 62 | FrameworkDependencies: 63 | userData: 64 | assetBundleName: 65 | assetBundleVariant: 66 | -------------------------------------------------------------------------------- /com.github.asus4.onnxruntime/Plugins/Windows/x64.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f5b47b1d04c594cb491a2770e3095c27 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /com.github.asus4.onnxruntime/Plugins/Windows/x64/onnxruntime.dll.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ed845f30a62cb48a992c3d6e00fb3b0f 3 | PluginImporter: 4 | externalObjects: {} 5 | serializedVersion: 3 6 | iconMap: {} 7 | executionOrder: {} 8 | defineConstraints: [] 9 | isPreloaded: 0 10 | isOverridable: 1 11 | isExplicitlyReferenced: 0 12 | validateReferences: 1 13 | platformData: 14 | Android: 15 | enabled: 0 16 | settings: 17 | AndroidLibraryDependee: UnityLibrary 18 | AndroidSharedLibraryType: Executable 19 | CPU: ARMv7 20 | Any: 21 | enabled: 0 22 | settings: 23 | Exclude Android: 1 24 | Exclude Editor: 0 25 | Exclude Linux64: 0 26 | Exclude OSXUniversal: 0 27 | Exclude Win: 1 28 | Exclude Win64: 0 29 | Exclude iOS: 1 30 | Editor: 31 | enabled: 1 32 | settings: 33 | CPU: x86_64 34 | DefaultValueInitialized: true 35 | OS: Windows 36 | Linux64: 37 | enabled: 1 38 | settings: 39 | CPU: AnyCPU 40 | OSXUniversal: 41 | enabled: 1 42 | settings: 43 | CPU: AnyCPU 44 | Win: 45 | enabled: 0 46 | settings: 47 | CPU: AnyCPU 48 | Win64: 49 | enabled: 1 50 | settings: 51 | CPU: x86_64 52 | iOS: 53 | enabled: 0 54 | settings: 55 | AddToEmbeddedBinaries: false 56 | CPU: AnyCPU 57 | CompileFlags: 58 | FrameworkDependencies: 59 | userData: 60 | assetBundleName: 61 | assetBundleVariant: 62 | -------------------------------------------------------------------------------- /com.github.asus4.onnxruntime/Plugins/Windows/x86.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 5f66a266f2df6465ca7711cf9e46d661 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /com.github.asus4.onnxruntime/Plugins/Windows/x86/onnxruntime.dll.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 65e7873525c954c9b9096de9496a9654 3 | PluginImporter: 4 | externalObjects: {} 5 | serializedVersion: 3 6 | iconMap: {} 7 | executionOrder: {} 8 | defineConstraints: [] 9 | isPreloaded: 0 10 | isOverridable: 1 11 | isExplicitlyReferenced: 0 12 | validateReferences: 1 13 | platformData: 14 | Android: 15 | enabled: 0 16 | settings: 17 | AndroidLibraryDependee: UnityLibrary 18 | AndroidSharedLibraryType: Executable 19 | CPU: ARMv7 20 | Any: 21 | enabled: 0 22 | settings: 23 | Exclude Android: 1 24 | Exclude Editor: 1 25 | Exclude Linux64: 1 26 | Exclude OSXUniversal: 1 27 | Exclude Win: 0 28 | Exclude Win64: 1 29 | Exclude iOS: 1 30 | Editor: 31 | enabled: 0 32 | settings: 33 | CPU: x86_64 34 | DefaultValueInitialized: true 35 | OS: Windows 36 | Linux64: 37 | enabled: 0 38 | settings: 39 | CPU: x86_64 40 | OSXUniversal: 41 | enabled: 0 42 | settings: 43 | CPU: None 44 | Win: 45 | enabled: 1 46 | settings: 47 | CPU: x86 48 | Win64: 49 | enabled: 0 50 | settings: 51 | CPU: None 52 | WindowsStoreApps: 53 | enabled: 0 54 | settings: 55 | CPU: x86 56 | iOS: 57 | enabled: 0 58 | settings: 59 | AddToEmbeddedBinaries: false 60 | CPU: AnyCPU 61 | CompileFlags: 62 | FrameworkDependencies: 63 | userData: 64 | assetBundleName: 65 | assetBundleVariant: 66 | -------------------------------------------------------------------------------- /com.github.asus4.onnxruntime/Plugins/macOS.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 39d4b9f7742374d8a80fb30392637aa1 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /com.github.asus4.onnxruntime/Plugins/macOS/arm64.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 7f9a00c2679f24a40aa0d7b0b9c88a59 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /com.github.asus4.onnxruntime/Plugins/macOS/arm64/libonnxruntime.dylib.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: bc9b82ac0eaaf452da6dfff039f45b96 3 | PluginImporter: 4 | externalObjects: {} 5 | serializedVersion: 3 6 | iconMap: {} 7 | executionOrder: {} 8 | defineConstraints: [] 9 | isPreloaded: 1 10 | isOverridable: 1 11 | isExplicitlyReferenced: 0 12 | validateReferences: 1 13 | platformData: 14 | Android: 15 | enabled: 0 16 | settings: 17 | AndroidLibraryDependee: UnityLibrary 18 | AndroidSharedLibraryType: Executable 19 | CPU: ARMv7 20 | Any: 21 | enabled: 0 22 | settings: 23 | Exclude Android: 1 24 | Exclude Editor: 0 25 | Exclude Linux64: 1 26 | Exclude OSXUniversal: 0 27 | Exclude Win: 1 28 | Exclude Win64: 1 29 | Exclude iOS: 1 30 | Editor: 31 | enabled: 1 32 | settings: 33 | CPU: ARM64 34 | DefaultValueInitialized: true 35 | OS: OSX 36 | Linux64: 37 | enabled: 0 38 | settings: 39 | CPU: x86_64 40 | OSXUniversal: 41 | enabled: 1 42 | settings: 43 | CPU: ARM64 44 | Win: 45 | enabled: 0 46 | settings: 47 | CPU: x86 48 | Win64: 49 | enabled: 0 50 | settings: 51 | CPU: None 52 | iOS: 53 | enabled: 0 54 | settings: 55 | AddToEmbeddedBinaries: false 56 | CPU: AnyCPU 57 | CompileFlags: 58 | FrameworkDependencies: 59 | userData: 60 | assetBundleName: 61 | assetBundleVariant: 62 | -------------------------------------------------------------------------------- /com.github.asus4.onnxruntime/Plugins/macOS/x64.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 517737511da0e4498b34b189ae4a6d44 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /com.github.asus4.onnxruntime/Plugins/macOS/x64/libonnxruntime.dylib.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 031e15b7a7fca47fd9956b825b614de5 3 | PluginImporter: 4 | externalObjects: {} 5 | serializedVersion: 3 6 | iconMap: {} 7 | executionOrder: {} 8 | defineConstraints: [] 9 | isPreloaded: 1 10 | isOverridable: 1 11 | isExplicitlyReferenced: 0 12 | validateReferences: 1 13 | platformData: 14 | Android: 15 | enabled: 0 16 | settings: 17 | AndroidLibraryDependee: UnityLibrary 18 | AndroidSharedLibraryType: Executable 19 | CPU: ARMv7 20 | Any: 21 | enabled: 0 22 | settings: 23 | Exclude Android: 1 24 | Exclude Editor: 0 25 | Exclude Linux64: 1 26 | Exclude OSXUniversal: 0 27 | Exclude Win: 1 28 | Exclude Win64: 1 29 | Exclude iOS: 1 30 | Editor: 31 | enabled: 1 32 | settings: 33 | CPU: x86_64 34 | DefaultValueInitialized: true 35 | OS: OSX 36 | Linux64: 37 | enabled: 0 38 | settings: 39 | CPU: x86_64 40 | OSXUniversal: 41 | enabled: 1 42 | settings: 43 | CPU: x86_64 44 | Win: 45 | enabled: 0 46 | settings: 47 | CPU: x86 48 | Win64: 49 | enabled: 0 50 | settings: 51 | CPU: None 52 | iOS: 53 | enabled: 0 54 | settings: 55 | AddToEmbeddedBinaries: false 56 | CPU: AnyCPU 57 | CompileFlags: 58 | FrameworkDependencies: 59 | userData: 60 | assetBundleName: 61 | assetBundleVariant: 62 | -------------------------------------------------------------------------------- /com.github.asus4.onnxruntime/README.md: -------------------------------------------------------------------------------- 1 | # ONNX Runtime Plugin for Unity 2 | -------------------------------------------------------------------------------- /com.github.asus4.onnxruntime/README.md.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 9c55cd78003354ec2bf257a3782d909f 3 | TextScriptImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /com.github.asus4.onnxruntime/Runtime.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 1fed210f8a1424fe9916b0dfd1d3440f 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /com.github.asus4.onnxruntime/Runtime/AssemblyInfo.shared.cs: -------------------------------------------------------------------------------- 1 | // Modified for Unity 2 | #if UNITY_ANDROID && !UNITY_EDITOR 3 | #define __ANDROID__ 4 | #define __MOBILE__ 5 | #elif UNITY_IOS && !UNITY_EDITOR 6 | #define __IOS__ 7 | #define __ENABLE_COREML__ 8 | #define __MOBILE__ 9 | #elif UNITY_EDITOR_OSX || UNITY_STANDALONE_OSX 10 | #define __ENABLE_COREML__ 11 | #endif 12 | #if __IOS__ 13 | [assembly: System.Reflection.AssemblyMetadata ("IsTrimmable", "True")] 14 | #elif __ANDROID__ 15 | [assembly: global::System.Reflection.AssemblyMetadata("IsTrimmable", "True")] 16 | #endif 17 | 18 | // Making these assembly's internals visible to the internal Test assembly 19 | [assembly: System.Runtime.CompilerServices.InternalsVisibleTo("Microsoft.ML.OnnxRuntime.Tests.Common, PublicKey=002400000480000094000000060200000024000052534131000400000100010059013e94e4bc70136ca4c35f33acd6b62974536b698f9c7a21cee18d805c7ad860ad9eebfdc47a96ba2f8d03f4cf1c36b9d30787e276c7b9833b5bf2a6eba7e919e6b90083078a352262aed1d842e5f70a3085cbcf4c56ae851b161137920961c23fcc246598d61d258ccc615c927b2441359eea666a99ce1c3c07dca18fb0e1")] 20 | [assembly: System.Runtime.CompilerServices.InternalsVisibleTo("Microsoft.ML.OnnxRuntime.Tests.NetCoreApp, PublicKey=002400000480000094000000060200000024000052534131000400000100010059013e94e4bc70136ca4c35f33acd6b62974536b698f9c7a21cee18d805c7ad860ad9eebfdc47a96ba2f8d03f4cf1c36b9d30787e276c7b9833b5bf2a6eba7e919e6b90083078a352262aed1d842e5f70a3085cbcf4c56ae851b161137920961c23fcc246598d61d258ccc615c927b2441359eea666a99ce1c3c07dca18fb0e1")] 21 | [assembly: System.Runtime.CompilerServices.InternalsVisibleTo("Microsoft.ML.OnnxRuntime.Tests.MAUI, PublicKey=002400000480000094000000060200000024000052534131000400000100010059013e94e4bc70136ca4c35f33acd6b62974536b698f9c7a21cee18d805c7ad860ad9eebfdc47a96ba2f8d03f4cf1c36b9d30787e276c7b9833b5bf2a6eba7e919e6b90083078a352262aed1d842e5f70a3085cbcf4c56ae851b161137920961c23fcc246598d61d258ccc615c927b2441359eea666a99ce1c3c07dca18fb0e1")] 22 | -------------------------------------------------------------------------------- /com.github.asus4.onnxruntime/Runtime/AssemblyInfo.shared.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 5cd55cbe3ec3b49e4bd94d4c7a7d4430 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /com.github.asus4.onnxruntime/Runtime/DisposableNamedOnnxValue.shared.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 58e4e3ee036644dd3aa36a9471a88d7a 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /com.github.asus4.onnxruntime/Runtime/Exceptions.shared.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | using System; 5 | using System.Collections.Generic; 6 | 7 | namespace Microsoft.ML.OnnxRuntime 8 | { 9 | 10 | /// 11 | /// Enum conresponding to native onnxruntime error codes. Must be in sync with the native API 12 | /// 13 | internal enum ErrorCode 14 | { 15 | Ok = 0, 16 | Fail = 1, 17 | InvalidArgument = 2, 18 | NoSuchFile = 3, 19 | NoModel = 4, 20 | EngineError = 5, 21 | RuntimeException = 6, 22 | InvalidProtobuf = 7, 23 | ModelLoaded = 8, 24 | NotImplemented = 9, 25 | InvalidGraph = 10, 26 | ShapeInferenceNotRegistered = 11, 27 | RequirementNotRegistered = 12, 28 | } 29 | 30 | /// 31 | /// The Exception that is thrown for errors related ton OnnxRuntime 32 | /// 33 | public class OnnxRuntimeException: Exception 34 | { 35 | private static Dictionary errorCodeToString = new Dictionary() 36 | { 37 | { ErrorCode.Ok, "Ok" }, 38 | { ErrorCode.Fail, "Fail" }, 39 | { ErrorCode.InvalidArgument, "InvalidArgument"} , 40 | { ErrorCode.NoSuchFile, "NoSuchFile" }, 41 | { ErrorCode.NoModel, "NoModel" }, 42 | { ErrorCode.EngineError, "EngineError" }, 43 | { ErrorCode.RuntimeException, "RuntimeException" }, 44 | { ErrorCode.InvalidProtobuf, "InvalidProtobuf" }, 45 | { ErrorCode.ModelLoaded, "ModelLoaded" }, 46 | { ErrorCode.NotImplemented, "NotImplemented" }, 47 | { ErrorCode.InvalidGraph, "InvalidGraph" }, 48 | { ErrorCode.ShapeInferenceNotRegistered, "ShapeInferenceNotRegistered" }, 49 | { ErrorCode.RequirementNotRegistered, "RequirementNotRegistered" }, 50 | }; 51 | 52 | internal OnnxRuntimeException(ErrorCode errorCode, string message) 53 | :base("[ErrorCode:" + errorCodeToString[errorCode] + "] " + message) 54 | { 55 | } 56 | } 57 | 58 | 59 | } 60 | -------------------------------------------------------------------------------- /com.github.asus4.onnxruntime/Runtime/Exceptions.shared.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d2ce9f2c97a51491c9a0cd6d24aec83b 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /com.github.asus4.onnxruntime/Runtime/FixedBufferOnnxValue.shared.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d9b98ec96f38b42ca8d04b0cf0858b14 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /com.github.asus4.onnxruntime/Runtime/InferenceSession.shared.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4672115e274f04dd59ab5e363452907a 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /com.github.asus4.onnxruntime/Runtime/ManagedProjections.shared.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 8258b6ec1658343928cbe28b9d257ee3 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /com.github.asus4.onnxruntime/Runtime/NamedOnnxValue.shared.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 516f75d3a67bf4b8abc8d23fe0ab228e 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /com.github.asus4.onnxruntime/Runtime/NativeApiStatus.shared.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | using System; 5 | using System.Runtime.CompilerServices; 6 | 7 | namespace Microsoft.ML.OnnxRuntime 8 | { 9 | class NativeApiStatus 10 | { 11 | private static string GetErrorMessage(IntPtr /*(ONNXStatus*)*/status) 12 | { 13 | // nativeString belongs to status, no need for separate release 14 | IntPtr nativeString = NativeMethods.OrtGetErrorMessage(status); 15 | return NativeOnnxValueHelper.StringFromNativeUtf8(nativeString); 16 | } 17 | 18 | /// 19 | /// Checks the native Status if the errocode is OK/Success. Otherwise constructs an appropriate exception and throws. 20 | /// Releases the native status object, as needed. 21 | /// 22 | /// 23 | /// 24 | [MethodImpl(MethodImplOptions.AggressiveInlining)] 25 | public static void VerifySuccess(IntPtr nativeStatus) 26 | { 27 | if (nativeStatus != IntPtr.Zero) 28 | { 29 | try 30 | { 31 | ErrorCode statusCode = NativeMethods.OrtGetErrorCode(nativeStatus); 32 | string errorMessage = GetErrorMessage(nativeStatus); 33 | throw new OnnxRuntimeException(statusCode, errorMessage); 34 | } 35 | finally 36 | { 37 | NativeMethods.OrtReleaseStatus(nativeStatus); 38 | } 39 | } 40 | } 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /com.github.asus4.onnxruntime/Runtime/NativeApiStatus.shared.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 92e5f16c598274bae9583f2af73d2d58 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /com.github.asus4.onnxruntime/Runtime/NativeMethods.shared.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a1127db4002e7400faee53253c15b1a7 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /com.github.asus4.onnxruntime/Runtime/NativeOnnxValueHelper.shared.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 0142feca57981449396431ab10337d07 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /com.github.asus4.onnxruntime/Runtime/OrtAllocator.shared.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: bf4847c2e0111417999f4b2912723b74 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /com.github.asus4.onnxruntime/Runtime/OrtEnv.shared.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 784f3552b8bce44fc969cd3d531758ab 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /com.github.asus4.onnxruntime/Runtime/OrtFloat16.shared.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 9fdd2204f69f94107a8fb04f4e7cb19c 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /com.github.asus4.onnxruntime/Runtime/OrtIoBinding.shared.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 950268695924b4c43b0a458808943b0d 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /com.github.asus4.onnxruntime/Runtime/OrtLoggingLevel.shared.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | namespace Microsoft.ML.OnnxRuntime 5 | { 6 | /// 7 | /// Log severity levels 8 | /// 9 | /// Must in sync with OrtLoggingLevel in onnxruntime_c_api.h 10 | /// 11 | public enum OrtLoggingLevel 12 | { 13 | ORT_LOGGING_LEVEL_VERBOSE = 0, 14 | ORT_LOGGING_LEVEL_INFO = 1, 15 | ORT_LOGGING_LEVEL_WARNING = 2, 16 | ORT_LOGGING_LEVEL_ERROR = 3, 17 | ORT_LOGGING_LEVEL_FATAL = 4, 18 | } 19 | } -------------------------------------------------------------------------------- /com.github.asus4.onnxruntime/Runtime/OrtLoggingLevel.shared.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 0c3ececebdacd451b8317c0f4d6fff1e 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /com.github.asus4.onnxruntime/Runtime/OrtLoraAdapter.shared.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | using System; 4 | using System.Runtime.InteropServices; 5 | 6 | namespace Microsoft.ML.OnnxRuntime 7 | { 8 | /// 9 | /// Represents Lora Adapter in memory 10 | /// 11 | public class OrtLoraAdapter : SafeHandle 12 | { 13 | /// 14 | /// Creates an instance of OrtLoraAdapter from file. 15 | /// The adapter file is memory mapped. If allocator parameter 16 | /// is provided, then lora parameters are copied to the memory 17 | /// allocated by the specified allocator. 18 | /// 19 | /// path to the adapter file 20 | /// optional allocator, can be null, must be a device allocator 21 | /// New instance of LoraAdapter 22 | public static OrtLoraAdapter Create(string adapterPath, OrtAllocator ortAllocator) 23 | { 24 | var platformPath = NativeOnnxValueHelper.GetPlatformSerializedString(adapterPath); 25 | var allocatorHandle = (ortAllocator != null) ? ortAllocator.Pointer : IntPtr.Zero; 26 | NativeApiStatus.VerifySuccess(NativeMethods.CreateLoraAdapter(platformPath, allocatorHandle, 27 | out IntPtr adapterHandle)); 28 | return new OrtLoraAdapter(adapterHandle); 29 | } 30 | 31 | /// 32 | /// Creates an instance of OrtLoraAdapter from an array of bytes. The API 33 | /// makes a copy of the bytes internally. 34 | /// 35 | /// array of bytes containing valid LoraAdapter format 36 | /// optional device allocator or null 37 | /// new instance of LoraAdapter 38 | public static OrtLoraAdapter Create(byte[] bytes, OrtAllocator ortAllocator) 39 | { 40 | var allocatorHandle = (ortAllocator != null) ? ortAllocator.Pointer : IntPtr.Zero; 41 | NativeApiStatus.VerifySuccess(NativeMethods.CreateLoraAdapterFromArray(bytes, 42 | new UIntPtr((uint)bytes.Length), allocatorHandle, out IntPtr adapterHandle)); 43 | return new OrtLoraAdapter(adapterHandle); 44 | } 45 | 46 | internal OrtLoraAdapter(IntPtr adapter) 47 | : base(adapter, true) 48 | { 49 | } 50 | 51 | internal IntPtr Handle 52 | { 53 | get 54 | { 55 | return handle; 56 | } 57 | } 58 | 59 | #region SafeHandle 60 | 61 | /// 62 | /// Overrides SafeHandle.IsInvalid 63 | /// 64 | /// returns true if handle is equal to Zero 65 | public override bool IsInvalid { get { return handle == IntPtr.Zero; } } 66 | 67 | /// 68 | /// Overrides SafeHandle.ReleaseHandle() to properly dispose of 69 | /// the native instance of OrtLoraAdapter 70 | /// 71 | /// always returns true 72 | protected override bool ReleaseHandle() 73 | { 74 | NativeMethods.ReleaseLoraAdapter(handle); 75 | handle = IntPtr.Zero; 76 | return true; 77 | } 78 | 79 | #endregion 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /com.github.asus4.onnxruntime/Runtime/OrtLoraAdapter.shared.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 22d82fefbb37f43b492bbff3a67d1ee5 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /com.github.asus4.onnxruntime/Runtime/OrtThreadingOptions.shared.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c777e051612404e2abb3f697d04e1d70 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /com.github.asus4.onnxruntime/Runtime/OrtTypeInfo.shared.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a9281a879caeb42eeb654b0ecce7000a 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /com.github.asus4.onnxruntime/Runtime/OrtValue.shared.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 12513251b472f4874bae2e2ee5745df1 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /com.github.asus4.onnxruntime/Runtime/OrtValueTensor.shared.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 525591c3e22fa49ba9d483c515e10557 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /com.github.asus4.onnxruntime/Runtime/PrepackedWeightsContainer.shared.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | using System; 5 | using System.Runtime.InteropServices; 6 | 7 | namespace Microsoft.ML.OnnxRuntime 8 | { 9 | 10 | /// 11 | /// This class holds pre-packed weights of shared initializers to be shared across sessions using these initializers 12 | /// and thereby provide memory savings by sharing the same pre-packed versions of these shared initializers 13 | /// 14 | public class PrePackedWeightsContainer : SafeHandle 15 | { 16 | 17 | /// 18 | /// Constructs an empty PrePackedWeightsContainer 19 | /// 20 | public PrePackedWeightsContainer() 21 | : base(IntPtr.Zero, true) 22 | { 23 | NativeApiStatus.VerifySuccess(NativeMethods.OrtCreatePrepackedWeightsContainer(out handle)); 24 | } 25 | 26 | /// 27 | /// Internal accessor to call native methods 28 | /// 29 | internal IntPtr Pointer { get { return handle; } } 30 | 31 | /// 32 | /// Overrides SafeHandle.IsInvalid 33 | /// 34 | /// returns true if handle is equal to Zero 35 | public override bool IsInvalid { get { return handle == IntPtr.Zero; } } 36 | 37 | #region SafeHandle 38 | /// 39 | /// Overrides SafeHandle.ReleaseHandle() to deallocate 40 | /// a chunk of memory using the specified allocator. 41 | /// 42 | /// always returns true 43 | protected override bool ReleaseHandle() 44 | { 45 | NativeMethods.OrtReleasePrepackedWeightsContainer(handle); 46 | handle = IntPtr.Zero; 47 | return true; 48 | } 49 | 50 | #endregion 51 | } 52 | 53 | } 54 | -------------------------------------------------------------------------------- /com.github.asus4.onnxruntime/Runtime/PrepackedWeightsContainer.shared.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 3d8872ee2391c47e8b14700ad3b04d76 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /com.github.asus4.onnxruntime/Runtime/ProviderOptions.shared.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ab2c0584c1fff46f2889e050d0a0e3e7 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /com.github.asus4.onnxruntime/Runtime/RunOptions.shared.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b51895da694d2416da516fc0d309b04c 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /com.github.asus4.onnxruntime/Runtime/SessionOptions.shared.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c50c4c502086f49caa2567b7836708f7 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /com.github.asus4.onnxruntime/Runtime/SessionOptionsContainer.shared.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4e40a5b36e2bb471582338feab27887c 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /com.github.asus4.onnxruntime/Runtime/ShapeUtils.shared.cs: -------------------------------------------------------------------------------- 1 | using System.Diagnostics; 2 | using System; 3 | 4 | namespace Microsoft.ML.OnnxRuntime.Tensors 5 | { 6 | /// 7 | /// This class contains utilities for useful calculations with shape. 8 | /// 9 | public static class ShapeUtils 10 | { 11 | /// 12 | /// Returns a number of elements in the tensor from the given shape 13 | /// 14 | /// 15 | /// size 16 | /// 17 | public static long GetSizeForShape(ReadOnlySpan shape) 18 | { 19 | long product = 1; 20 | foreach (var dim in shape) 21 | { 22 | if (dim < 0) 23 | { 24 | throw new ArgumentOutOfRangeException($"Shape must not have negative elements: {dim}"); 25 | } 26 | checked 27 | { 28 | product *= dim; 29 | } 30 | } 31 | return product; 32 | } 33 | 34 | /// 35 | /// Gets the set of strides that can be used to calculate the offset of n-dimensions in a 1-dimensional layout 36 | /// 37 | /// 38 | /// an array of strides 39 | public static long[] GetStrides(ReadOnlySpan dimensions) 40 | { 41 | long[] strides = new long[dimensions.Length]; 42 | 43 | if (dimensions.Length == 0) 44 | { 45 | return strides; 46 | } 47 | 48 | long stride = 1; 49 | for (int i = strides.Length - 1; i >= 0; i--) 50 | { 51 | strides[i] = stride; 52 | if (dimensions[i] < 0) 53 | { 54 | throw new ArgumentException($"Dimension {i} is negative"); 55 | } 56 | stride *= dimensions[i]; 57 | } 58 | 59 | return strides; 60 | } 61 | 62 | /// 63 | /// Calculates the 1-d index for n-d indices in layout specified by strides. 64 | /// 65 | /// pre-calculated strides 66 | /// Indices. Must have the same length as strides 67 | /// 68 | /// A 1-d index into the tensor buffer 69 | public static long GetIndex(ReadOnlySpan strides, ReadOnlySpan indices, int startFromDimension = 0) 70 | { 71 | Debug.Assert(strides.Length == indices.Length); 72 | 73 | long index = 0; 74 | for (int i = startFromDimension; i < indices.Length; i++) 75 | { 76 | index += strides[i] * indices[i]; 77 | } 78 | 79 | return index; 80 | } 81 | } 82 | } -------------------------------------------------------------------------------- /com.github.asus4.onnxruntime/Runtime/ShapeUtils.shared.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b35d1ee72307d4cb9aab5f4f4ac6d377 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /com.github.asus4.onnxruntime/Runtime/Tensors.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: db988fe3e53704aa58e039b4c31beb09 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /com.github.asus4.onnxruntime/Runtime/Tensors/ArrayTensorExtensions.shared.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 81b1ba475a235404bb99f6b189e28fba 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /com.github.asus4.onnxruntime/Runtime/Tensors/ArrayUtilities.shared.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 6671d7feaf4c04d218b368aeecf03a36 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /com.github.asus4.onnxruntime/Runtime/Tensors/DenseTensor.shared.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 299ce4874fbb5436a93ced290651e4ff 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /com.github.asus4.onnxruntime/Runtime/Tensors/Tensor.shared.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 728bc2feb8f144ee8ab00f82f8f400db 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /com.github.asus4.onnxruntime/Runtime/Training.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 0efc5fcebd36d41a3af6d633da2d16f5 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /com.github.asus4.onnxruntime/Runtime/Training/CheckpointState.shared.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4065f5a1fb9e04a6a9c4e3d978980783 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /com.github.asus4.onnxruntime/Runtime/Training/NativeTrainingMethods.shared.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 7b15c6bad6b3e41c9b9feb075dc4b44a 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /com.github.asus4.onnxruntime/Runtime/Training/TrainingSession.shared.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b17345cc7e371419595e9e94e7aae8bf 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /com.github.asus4.onnxruntime/Runtime/com.github.asus4.onnxruntime.asmdef: -------------------------------------------------------------------------------- 1 | { 2 | "name": "com.github.asus4.onnxruntime", 3 | "rootNamespace": "", 4 | "references": [], 5 | "includePlatforms": [], 6 | "excludePlatforms": [], 7 | "allowUnsafeCode": true, 8 | "overrideReferences": false, 9 | "precompiledReferences": [], 10 | "autoReferenced": true, 11 | "defineConstraints": [], 12 | "versionDefines": [ 13 | { 14 | "name": "com.github.asus4.onnxruntime.win-x64-gpu", 15 | "expression": "0.1.4", 16 | "define": "ORT_GPU_PROVIDER_WIN" 17 | }, 18 | { 19 | "name": "com.github.asus4.onnxruntime-extensions", 20 | "expression": "0.1.4", 21 | "define": "ORT_EXTENSION" 22 | } 23 | ], 24 | "noEngineReferences": true 25 | } -------------------------------------------------------------------------------- /com.github.asus4.onnxruntime/Runtime/com.github.asus4.onnxruntime.asmdef.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 8600c83db57f44fe2aa05f4cf22420bf 3 | AssemblyDefinitionImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /com.github.asus4.onnxruntime/ThirdPartyNotices.txt.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 8416aa12408574ff18cf0421aed0bdbf 3 | TextScriptImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /com.github.asus4.onnxruntime/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "com.github.asus4.onnxruntime", 3 | "version": "0.4.0", 4 | "displayName": "ONNX Runtime", 5 | "description": "ONNX Runtime Plugin for Unity", 6 | "keywords": [ 7 | "unity", 8 | "onnxruntime" 9 | ], 10 | "unity": "2022.3", 11 | "unityRelease": "0f1", 12 | "repository": { 13 | "type": "git", 14 | "repository": "https://github.com/asus4/onnxruntime-unity.git" 15 | }, 16 | "documentationUrl": "https://github.com/asus4/onnxruntime-unity", 17 | "changelogUrl": "https://github.com/asus4/onnxruntime-unity/releases", 18 | "licensesUrl": "https://github.com/asus4/onnxruntime-unity/blob/main/com.github.asus4.onnxruntime/LICENSE", 19 | "author": { 20 | "name": "Koki Ibukuro", 21 | "url": "https://github.com/asus4" 22 | } 23 | } -------------------------------------------------------------------------------- /com.github.asus4.onnxruntime/package.json.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c42f1d0e4b8aa45a3b26d357bfa69618 3 | PackageManifestImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /scripts/UnityDefines.cs: -------------------------------------------------------------------------------- 1 | // Modified for Unity 2 | #if UNITY_ANDROID && !UNITY_EDITOR 3 | #define __ANDROID__ 4 | #define __MOBILE__ 5 | #elif UNITY_IOS && !UNITY_EDITOR 6 | #define __IOS__ 7 | #define __ENABLE_COREML__ 8 | #define __MOBILE__ 9 | #elif UNITY_EDITOR_OSX || UNITY_STANDALONE_OSX 10 | #define __ENABLE_COREML__ 11 | #endif 12 | 13 | -------------------------------------------------------------------------------- /scripts/download-onnx-extensions-libs.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -e -x -u 4 | 5 | # Ensure the tag format is like 1.2.3 6 | if [[ ! $1 =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then 7 | echo "Tag $1 is not in the correct format. It should be like `$0 1.2.3`" 8 | exit 1 9 | fi 10 | 11 | # Define Variables 12 | TAG=$1 13 | PROJECT_DIR="$(cd "$(dirname "$0")/.." && pwd -P)" 14 | PLUGINS_DIR="$PROJECT_DIR/com.github.asus4.onnxruntime-extensions/Plugins" 15 | TMP_DIR="$PROJECT_DIR/.tmp" 16 | mkdir -p $TMP_DIR 17 | 18 | #-------------------------------------- 19 | # Functions 20 | #-------------------------------------- 21 | 22 | function download_nuget() { 23 | PACKAGE_NAME=$1 24 | VERSION=$2 25 | EXTRACT_DIR=$(echo $PACKAGE_NAME-$VERSION) 26 | 27 | # Skip if the directory already exists 28 | if [ -d $TMP_DIR/$EXTRACT_DIR ]; then 29 | echo "$EXTRACT_DIR already exists. Skipping download." 30 | return 31 | fi 32 | 33 | curl -L https://www.nuget.org/api/v2/package/$PACKAGE_NAME/$VERSION -o $TMP_DIR/$PACKAGE_NAME-$VERSION.nupkg 34 | mkdir -p $TMP_DIR/$EXTRACT_DIR 35 | unzip -o $TMP_DIR/$PACKAGE_NAME-$VERSION.nupkg -d $TMP_DIR/$EXTRACT_DIR 36 | } 37 | 38 | #-------------------------------------- 39 | # ONNX Runtime 40 | #-------------------------------------- 41 | 42 | # Download NuGet packages and place in the Unity package 43 | # https://www.nuget.org/api/v2/package/Microsoft.ML.OnnxRuntime.Extensions/{VERSION} 44 | 45 | download_nuget Microsoft.ML.OnnxRuntime.Extensions $TAG 46 | EXTRACT_DIR=$(echo $TMP_DIR/Microsoft.ML.OnnxRuntime.Extensions-$TAG/runtimes) 47 | 48 | # macOS 49 | cp $EXTRACT_DIR/osx.10.14-x64/native/libortextensions.dylib $PLUGINS_DIR/macOS/x64/ 50 | cp $EXTRACT_DIR/osx.10.14-arm64/native/libortextensions.dylib $PLUGINS_DIR/macOS/arm64/ 51 | 52 | # Windows 53 | cp $EXTRACT_DIR/win-arm64/native/ortextensions.dll $PLUGINS_DIR/Windows/arm64/ 54 | cp $EXTRACT_DIR/win-x64/native/ortextensions.dll $PLUGINS_DIR/Windows/x64/ 55 | # cp $EXTRACT_DIR/win-x86/ortextensions.dll $PLUGINS_DIR/Windows/x86/ 56 | 57 | # Linux 58 | cp $EXTRACT_DIR/linux-arm64/native/libortextensions.so $PLUGINS_DIR/Linux/arm64/ 59 | cp $EXTRACT_DIR/linux-x64/native/libortextensions.so $PLUGINS_DIR/Linux/x64/ 60 | 61 | # Android 62 | cp $EXTRACT_DIR/android/native/onnxruntime-extensions.aar $PLUGINS_DIR/Android/ 63 | 64 | # iOS XCFramework 65 | rm -rf $PLUGINS_DIR/iOS~/onnxruntime_extensions.xcframework 66 | unzip -o $EXTRACT_DIR/ios/native/onnxruntime_extensions.xcframework.zip -d $EXTRACT_DIR/ios/native/ 67 | mv $EXTRACT_DIR/ios/native/onnxruntime_extensions.xcframework $PLUGINS_DIR/iOS~/ 68 | 69 | echo "Done." 70 | exit 0 71 | -------------------------------------------------------------------------------- /scripts/download-onnx-genai-libs.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -e -x -u 4 | 5 | # Ensure the tag format is like 1.2.3 6 | if [[ ! $1 =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then 7 | echo "Tag $1 is not in the correct format. It should be like `$0 1.2.3`" 8 | exit 1 9 | fi 10 | 11 | # Define Variables 12 | TAG=$1 13 | PROJCET_DIR="$(cd "$(dirname "$0")/.." && pwd -P)" 14 | PLUGINS_DIR="$PROJCET_DIR/com.github.asus4.onnxruntime-genai/Plugins" 15 | mkdir -p .tmp 16 | TMP_DIR="$PROJCET_DIR/.tmp" 17 | 18 | #-------------------------------------- 19 | # Functions 20 | #-------------------------------------- 21 | 22 | function download_nuget() { 23 | PACKAGE_NAME=$1 24 | VERSION=$2 25 | EXTRACT_DIR=$(echo $PACKAGE_NAME-$VERSION) 26 | 27 | # Skip if the directory already exists 28 | if [ -d $TMP_DIR/$EXTRACT_DIR ]; then 29 | echo "$EXTRACT_DIR already exists. Skipping download." 30 | return 31 | fi 32 | 33 | curl -L https://www.nuget.org/api/v2/package/$PACKAGE_NAME/$VERSION -o $TMP_DIR/$PACKAGE_NAME-$VERSION.nupkg 34 | mkdir -p $TMP_DIR/$EXTRACT_DIR 35 | unzip -o $TMP_DIR/$PACKAGE_NAME-$VERSION.nupkg -d $TMP_DIR/$EXTRACT_DIR 36 | } 37 | 38 | #-------------------------------------- 39 | # ONNX Runtime 40 | #-------------------------------------- 41 | 42 | # Download binaries from NuGet and place in the Unity package 43 | # https://www.nuget.org/api/v2/package/Microsoft.ML.OnnxRuntimeGenAI/{VERSION} 44 | 45 | download_nuget Microsoft.ML.OnnxRuntimeGenAI $TAG 46 | EXTRACT_DIR=$(echo $TMP_DIR/Microsoft.ML.OnnxRuntimeGenAI-$TAG/runtimes) 47 | # exit 0 48 | 49 | # macOS 50 | cp $EXTRACT_DIR/osx-arm64/native/libonnxruntime-genai.dylib $PLUGINS_DIR/macOS/arm64/ 51 | cp $EXTRACT_DIR/osx-x64/native/libonnxruntime-genai.dylib $PLUGINS_DIR/macOS/x64/ 52 | 53 | # Windows 54 | cp $EXTRACT_DIR/win-arm64/native/onnxruntime-genai.dll $PLUGINS_DIR/Windows/arm64/ 55 | cp $EXTRACT_DIR/win-x64/native/onnxruntime-genai.dll $PLUGINS_DIR/Windows/x64/ 56 | 57 | # Linux 58 | # cp $EXTRACT_DIR/linux-arm64/native/libonnxruntime-genai.so $PLUGINS_DIR/Linux/arm64/ 59 | cp $EXTRACT_DIR/linux-x64/native/libonnxruntime-genai.so $PLUGINS_DIR/Linux/x64/ 60 | 61 | # Android 62 | cp $EXTRACT_DIR/android/native/onnxruntime-genai.aar $PLUGINS_DIR/Android/ 63 | 64 | # iOS xcframework 65 | rm -rf $PLUGINS_DIR/iOS~/onnxruntime-genai.xcframework 66 | unzip -o $EXTRACT_DIR/ios/native/onnxruntime-genai.xcframework.zip -d $PLUGINS_DIR/iOS~/ 67 | 68 | echo "Done." 69 | exit 0 70 | -------------------------------------------------------------------------------- /scripts/download-onnx-libs.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -e -x -u 4 | 5 | # Ensure the tag format is like 1.2.3 6 | if [[ ! $1 =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then 7 | echo "Tag $1 is not in the correct format. It should be like `$0 1.2.3`" 8 | exit 1 9 | fi 10 | 11 | # Define Variables 12 | TAG=$1 13 | PROJECT_DIR="$(cd "$(dirname "$0")/.." && pwd -P)" 14 | PLUGINS_DIR="$PROJECT_DIR/com.github.asus4.onnxruntime/Plugins" 15 | TMP_DIR="$PROJECT_DIR/.tmp" 16 | mkdir -p $TMP_DIR 17 | 18 | #-------------------------------------- 19 | # Functions 20 | #-------------------------------------- 21 | 22 | function download_nuget() { 23 | PACKAGE_NAME=$1 24 | VERSION=$2 25 | EXTRACT_DIR=$(echo $PACKAGE_NAME-$VERSION) 26 | 27 | # Skip if the directory already exists 28 | if [ -d $TMP_DIR/$EXTRACT_DIR ]; then 29 | echo "$EXTRACT_DIR already exists. Skipping download." 30 | return 31 | fi 32 | 33 | curl -L https://www.nuget.org/api/v2/package/$PACKAGE_NAME/$VERSION -o $TMP_DIR/$PACKAGE_NAME-$VERSION.nupkg 34 | mkdir -p $TMP_DIR/$EXTRACT_DIR 35 | unzip -o $TMP_DIR/$PACKAGE_NAME-$VERSION.nupkg -d $TMP_DIR/$EXTRACT_DIR 36 | } 37 | 38 | #-------------------------------------- 39 | # ONNX Runtime 40 | #-------------------------------------- 41 | 42 | # Download NuGet packages and place in the Unity package 43 | # https://www.nuget.org/api/v2/package/Microsoft.ML.OnnxRuntime/{VERSION} 44 | 45 | download_nuget Microsoft.ML.OnnxRuntime $TAG 46 | download_nuget Microsoft.ML.OnnxRuntime.DirectML $TAG 47 | download_nuget Microsoft.ML.OnnxRuntime.Gpu.Linux $TAG 48 | download_nuget Microsoft.ML.OnnxRuntime.Gpu.Windows $TAG 49 | 50 | EXTRACT_DIR=$(echo $TMP_DIR/Microsoft.ML.OnnxRuntime-$TAG/runtimes) 51 | 52 | # Android 53 | cp $EXTRACT_DIR/android/native/onnxruntime.aar $PLUGINS_DIR/Android/ 54 | 55 | # iOS XCFramework 56 | rm -rf $PLUGINS_DIR/iOS~/onnxruntime.xcframework 57 | mkdir -p $PLUGINS_DIR/iOS~/onnxruntime.xcframework/ 58 | unzip -o $EXTRACT_DIR/ios/native/onnxruntime.xcframework.zip -d $PLUGINS_DIR/iOS~/ 59 | ls $PLUGINS_DIR/iOS~/onnxruntime.xcframework/ 60 | 61 | # macOS 62 | cp $EXTRACT_DIR/osx-x64/native/libonnxruntime.dylib $PLUGINS_DIR/macOS/x64/ 63 | cp $EXTRACT_DIR/osx-arm64/native/libonnxruntime.dylib $PLUGINS_DIR/macOS/arm64/ 64 | 65 | # Linux 66 | # arm64 is not supported by Unity 67 | # cp $EXTRACT_DIR/linux-arm64/native/libonnxruntime.so $PLUGINS_DIR/Linux/arm64/ 68 | cp $EXTRACT_DIR/linux-x64/native/libonnxruntime.so $PLUGINS_DIR/Linux/x64/ 69 | 70 | # Microsoft.ML.OnnxRuntime.Gpu.Linux 71 | EXTRACT_DIR=$(echo $TMP_DIR/Microsoft.ML.OnnxRuntime.Gpu.Linux-$TAG/runtimes) 72 | cp $EXTRACT_DIR/linux-x64/native/libonnxruntime_*.so $PROJECT_DIR/com.github.asus4.onnxruntime.linux-x64-gpu/Plugins/Linux/x64/ 73 | 74 | # Windows 75 | # Microsoft.ML.OnnxRuntime.DirectML for default OnnxRuntime 76 | EXTRACT_DIR=$(echo $TMP_DIR/Microsoft.ML.OnnxRuntime.DirectML-$TAG/runtimes) 77 | cp $EXTRACT_DIR/win-arm64/native/onnxruntime.dll $PLUGINS_DIR/Windows/arm64/ 78 | cp $EXTRACT_DIR/win-x64/native/onnxruntime.dll $PLUGINS_DIR/Windows/x64/ 79 | cp $EXTRACT_DIR/win-x86/native/onnxruntime.dll $PLUGINS_DIR/Windows/x86/ 80 | 81 | # Microsoft.ML.OnnxRuntime.Gpu.Windows 82 | EXTRACT_DIR=$(echo $TMP_DIR/Microsoft.ML.OnnxRuntime.Gpu.Windows-$TAG/runtimes) 83 | cp $EXTRACT_DIR/win-x64/native/onnxruntime_*.dll $PROJECT_DIR/com.github.asus4.onnxruntime.win-x64-gpu/Plugins/Windows/x64/ 84 | 85 | echo "Done." 86 | exit 0 87 | -------------------------------------------------------------------------------- /scripts/modify-defines.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash -xe 2 | 3 | PROJCET_DIR="$(cd "$(dirname "$0")/.." && pwd -P)" 4 | DEFINES_FILE="$PROJECT_DIR/scripts/UnityDefines.cs" 5 | SRC_ROOT="$PROJECT_DIR/com.github.asus4.onnxruntime/Runtime" 6 | 7 | concat_defines() { 8 | cat "${DEFINES_FILE}" "$1" > "$1.tmp" 9 | mv "$1.tmp" "$1" 10 | } 11 | 12 | concat_defines "${SRC_ROOT}/AssemblyInfo.shared.cs" 13 | concat_defines "${SRC_ROOT}/NativeMethods.shared.cs" 14 | concat_defines "${SRC_ROOT}/SessionOptions.shared.cs" 15 | 16 | echo "Done." 17 | --------------------------------------------------------------------------------