microsoft/onnxruntime-extensions
Publicmirrored fromhttps://github.com/microsoft/onnxruntime-extensionsAvailable
docs/development.md
83lines · modecode
| 1 | # Build and Development |
| 2 | |
| 3 | This project supports Python and can be built from source easily, or a simple cmake build without Python dependency. |
| 4 | |
| 5 | ## Python package |
| 6 | |
| 7 | The package contains all custom operators and some Python scripts to manipulate the ONNX models. |
| 8 | |
| 9 | - Install Visual Studio with C++ development tools on Windows, or gcc(>8.0) for Linux or xcode for macOS, and cmake on |
| 10 | the unix-like platform. |
| 11 | - If running on Windows, ensure that long file names are enabled, both for |
| 12 | the [operating system](https://docs.microsoft.com/en-us/windows/win32/fileio/maximum-file-path-limitation?tabs=cmd) |
| 13 | and for git: `git config --system core.longpaths true` |
| 14 | - Prepare Python env and install the pip packages in the requirements.txt. |
| 15 | - `pip install .` to build and install the package.<br/> OR `pip install -e .` to install the package in the development |
| 16 | mode, which is more friendly for the developer since the Python code change will take effect without having to copy |
| 17 | the files to a different location in the disk.(**hints**: debug=1 in setup.cfg wil make C++ code be debuggable in a |
| 18 | Python process.) |
| 19 | - Add the following argument `--config-settings "ortx-user-option=use-cuda"` in the pip command line to enable **CUDA** |
| 20 | kernels for the package. |
| 21 | - The flags can be used in --config-settings are |
| 22 | - use-cuda: enable CUDA kernel build in Python package. |
| 23 | - no-azure: disable AzureOp kernel build in Python package. |
| 24 | - no-opencv: disable operators based on OpenCV in build. |
| 25 | - cc-debug: Generate debug info for extensions binaries and disable C/C++ compiler optimization. |
| 26 | |
| 27 | For example:`pip install --config-settings "ortx-user-option=use-cuda,cc-debug" `, This command builds CUDA |
| 28 | kernels into the package and installs it, accompanied by the generation of debug information. |
| 29 | |
| 30 | Test: |
| 31 | |
| 32 | - 'pip install -r requirements-dev.txt' to install pip packages for development. |
| 33 | - run `pytest test` in the project root directory. |
| 34 | |
| 35 | For a complete list of verified build configurations see [here](<./ci_matrix.md>) |
| 36 | |
| 37 | ## Java package |
| 38 | |
| 39 | `bash ./build.sh -DOCOS_BUILD_JAVA=ON` to build jar package in out/<OS>/Release folder |
| 40 | |
| 41 | ## Android package |
| 42 | |
| 43 | - pre-requisites: [Android Studio](https://developer.android.com/studio) |
| 44 | |
| 45 | Use `./tools/android/build_aar.py` to build an Android AAR package. |
| 46 | |
| 47 | ## iOS package |
| 48 | |
| 49 | Use `./tools/ios/build_xcframework.py` to build an iOS xcframework package. |
| 50 | |
| 51 | ## NuGet package |
| 52 | |
| 53 | In order to build a local NuGet package for testing, run `nuget.exe pack ./nuget/WinOnlyNuget.nuspec` to build a NuGet |
| 54 | package for Windows. |
| 55 | |
| 56 | Note: you might need to update the src paths in the ./nuget/WinOnlyNuget.nuspec file if the appropriate |
| 57 | ortextensions.dll files do not exist/are not in the given location. |
| 58 | |
| 59 | ## Web-Assembly |
| 60 | |
| 61 | ONNXRuntime-Extensions will be built as a static library and linked with ONNXRuntime due to the lack of a good dynamic |
| 62 | linking mechanism in WASM. Here are two additional |
| 63 | arguments [–-use_extensions and --extensions_overridden_path](https://github.com/microsoft/onnxruntime/blob/860ba8820b72d13a61f0d08b915cd433b738ffdc/tools/ci_build/build.py#L416) |
| 64 | on building onnxruntime to include ONNXRuntime-Extensions footprint in the ONNXRuntime package. |
| 65 | |
| 66 | ## The C++ shared library |
| 67 | |
| 68 | For any alternative scenarios, execute the following commands: |
| 69 | |
| 70 | - On Windows: Run `build.bat`. |
| 71 | - On Unix-based systems: Execute `bash ./build.sh`. |
| 72 | |
| 73 | The generated DLL or library is typically located in the `out/<OS>/<FLAVOR>` directory. To validate the build, utilize |
| 74 | the unit tests available in the `test/test_static_test` and `test/shared_test` directories. |
| 75 | |
| 76 | **VC Runtime static linkage** |
| 77 | If you want to build the binary with VC Runtime static linkage, please add a parameter _-DCMAKE_MSVC_RUNTIME_LIBRARY=" |
| 78 | MultiThreaded$<$<CONFIG:Debug>:Debug>"_ on running build.bat |
| 79 | |
| 80 | ## Copyright guidance |
| 81 | |
| 82 | check this link https://docs.opensource.microsoft.com/releasing/general-guidance/copyright-headers/ for source file |
| 83 | copyright header. |
| 84 | |