Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 3 additions & 28 deletions cmake/onnxruntime_providers_iree.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -46,37 +46,12 @@ set_source_files_properties(
"-Wno-unused-parameter -Wno-shorten-64-to-32"
)

# TODO: Dev package support in IREE is new so we are being a bit pedantic about config.
# This could be relaxes significantly.
set(ONNXRUNTIME_IREE_HOME "" CACHE STRING "Path to the IREE development package")
if(NOT ONNXRUNTIME_IREE_HOME)
message(SEND_ERROR "Expected -DONNXRUNTIME_IREE_HOME to be set to the development package directory (see README)")
endif()
set(IREECompiler_DIR "${ONNXRUNTIME_IREE_HOME}/lib/cmake/IREE")
set(IREERuntime_DIR "${ONNXRUNTIME_IREE_HOME}/lib/cmake/IREE")

if(NOT EXISTS "${IREECompiler_DIR}/IREECompilerConfig.cmake")
message(WARNING "Did not find IREECompilerConfig.cmake under ${IREECompiler_DIR}. Check -DONNXRUNTIME_IREE_HOME.")
endif()
if(NOT EXISTS "${IREERuntime_DIR}/IREERuntimeConfig.cmake")
message(WARNING "Did not find IREERuntimeConfig.cmake under ${IREECompiler_DIR}. Check -DONNXRUNTIME_IREE_HOME.")
endif()

# Note that these will fail if IREECompilerConfig.cmake and IREERuntime.cmake are not on the search path.
# There are multiple ways to ensure this, but typically (as will be called out in the error message):
# -DCMAKE_PREFIX_PATH=/abs/path/to/iree-build/lib/cmake/IREE
find_package(IREECompiler REQUIRED)
find_package(IREERuntime REQUIRED)

# Compiler deps. See README.md for temporary steps on how to make a dev package.
# TODO: Depend on real dev packages for iree-compiler and iree-runtime.
# TODO: Also figure out why the shared library libIREECompiler.so dep needs to be public.
# TODO: Once the dev package CMake integration is set up, depend via normal CMake libraries.
# TODO: Copy the IREECompiler runtime library to the appropriate place as part of installation.
# target_include_directories(
# onnxruntime_providers_iree PRIVATE
# ${ONNXRUNTIME_IREE_HOME}/include
# )
# target_link_directories(onnxruntime_providers_iree PUBLIC
# ${ONNXRUNTIME_IREE_HOME}/lib
# )
target_link_libraries(onnxruntime_providers_iree PUBLIC
iree_compiler_API_SharedImpl
iree_runtime_unified
Expand Down
30 changes: 15 additions & 15 deletions onnxruntime/core/providers/iree/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,36 +27,28 @@ With the above, this EP should be built out to relative completion and be suitab

## Building

### IREE Dev Tree

We are using IREE as a CMake dep, introduced upstream in https://github.com/openxla/iree/pull/16008. This is
having some kinks worked out but should work. Currently, there is a conflict on `cpuinfo`, so IREE must be built
with `-DIREE_ENABLE_CPUINFO=OFF`.

The IREE dep is currently configured via the `-DONNXRUNTIME_IREE_HOME=` CMake variable. It must be set to
the path of a locally built IREE build directory or an install directory (i.e. by fetching built packages from the
releases page). Dev is currently taking place mostly against local build dirs.

Under the covers, this is just setting `IREECompiler_DIR` + `IREERuntime_DIR` and then doing a
`find_package(IREECompiler)` + `find_package(IREERuntime)`. See `onnxruntime_providers_iree.cmake`.

## Dev Builds

The following produces a reasonable development setup on Linux:

```
CC=clang CXX=clang++ LDFLAGS="-fuse-ld=lld" \
./build.sh --config=RelWithDebInfo --cmake_generator=Ninja \
--use_iree --cmake_extra_defines "ONNXRUNTIME_IREE_HOME=/path/to/iree/build/or/install/tree" \
--use_iree --cmake_extra_defines "CMAKE_PREFIX_PATH=/abs/path/to/iree-build/lib/cmake/IREE" \
--use_cache --use_full_protobuf \
--enable_symbolic_shape_infer_tests \
--update --build
```

IMPORTANT: Current builds of IREE bundle cpuinfo, which is incompatible with onnxruntime. This renders a stock
IREE build or installed/downloaded package unusable until unbundled. For the moment, IREE must be built with
`-DIREE_ENABLE_CPUINFO=OFF` as a workaround.

Explanations:

* `--cmake_generator` because it is 2024
* `--cmake_extra_defines`: Injects the IREE dev package directory. This should be plumbed through eventually as
* `--cmake_extra_defines`: Enables `find_package(IREECompiler)` + `find_package(IREERuntime)` to find the IREE
development targets.
`--iree_home` to correspond with the others
* `--use_cache` enable ccache
* `--use_full_protobuf` enables protobuf metadata to make debug printing nicer
Expand All @@ -66,6 +58,14 @@ Explanations:
Once the build has been initially done, you can work in the `build/Linux/RelWithDebInfo` directory if that is more
comfortable.

## Build from released IREE

IMPORTANT: This will currently not work with stock IREE builds because of the cpuinfo issue listed above.

* Download an appropriate `iree-dist*` tarball for your platform from https://github.com/openxla/iree/releases.
* Extract.
* Set `CMAKE_PREFIX_PATH=/extract/path/lib/cmake/IREE` as above.

## Manual Testing

While the ORT test runner has some automatic abilities to run symbolic shape inference on `.onnx` files prior to
Expand Down