### Setup Virtual Environment Source: https://github.com/iree-org/iree/blob/main/docs/api_docs/python/README.md Sets up a Python virtual environment and installs project requirements. Activate the environment before running other commands. ```shell python -m venv .venv source .venv/bin/activate python -m pip install -r requirements.txt ``` -------------------------------- ### Setup and Test Virtual Environment Source: https://github.com/iree-org/iree/blob/main/build_tools/pkgci/README.md Use this script to set up a virtual environment with specific package versions and then test the installation by checking the IREE compiler version. ```bash python3.11 ./setup_venv.py /tmp/.venv --fetch-git-ref=5b0740c97a33ed # Activate the venvs and test it source /tmp/.venv/bin/activate iree-compile --version # IREE (https://iree.dev): # IREE compiler version 3.1.0.dev+5b0740c97a33edce29e753b14b9ff04789afcc53 @ 5b0740c97a33edce29e753b14b9ff04789afcc53 # LLVM version 20.0.0git # Optimized build ``` -------------------------------- ### Setup IREE Documentation Environment Source: https://github.com/iree-org/iree/blob/main/docs/website/README.md Set up a Python virtual environment and install project dependencies for developing the IREE documentation website. ```shell python3 -m venv .venv source .venv/bin/activate pip install -r requirements.txt ``` -------------------------------- ### Setup and Install Packages for a Specific Commit Source: https://github.com/iree-org/iree/blob/main/build_tools/pkgci/bisect/README.md This script sets up a virtual environment and installs the required Python packages for a given commit hash. It downloads wheel files from artifacts if available, otherwise it installs from source. ```bash ++ git rev-parse BISECT_HEAD + REF_HASH=c7213deeb5c7abb0843088815580793b282fdc34 + /home/nod/dev/projects/iree/build_tools/pkgci/setup_venv_for_ref.py c7213deeb5c7abb0843088815580793b282fdc34 --work-dir /home/nod/.iree/bisect ------------------------------------------------------------------ Installing packages for ref: c7213deeb5c7abb0843088815580793b282fdc34 Using base working directory : '/home/nod/.iree/bisect' # ----------------------------------------------------- # Here we download and install packages for that commit # ----------------------------------------------------- Running command to list workflow runs: gh api -H Accept: application/vnd.github+json -H X-GitHub-Api-Version: 2022-11-28 /repos/iree-org/iree/actions/workflows/pkgci.yml/runs?head_sha=c7213deeb5c7abb0843088815580793b282fdc34 Found workflow run: https://github.com/iree-org/iree/actions/runs/11375010806 Found cached .whl files in artifacts dir, skipping download Creating venv at '/home/nod/.iree/bisect/c7213deeb5c7abb0843088815580793b282fdc34/.venv' Running command to install dependencies: /home/nod/.iree/bisect/c7213deeb5c7abb0843088815580793b282fdc34/.venv/bin/python -m pip install --quiet numpy sympy Running command to install package: /home/nod/.iree/bisect/c7213deeb5c7abb0843088815580793b282fdc34/.venv/bin/python -m pip install --quiet /home/nod/.iree/bisect/c7213deeb5c7abb0843088815580793b282fdc34/iree_compiler-0.dev1-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl Running command to install package: /home/nod/.iree/bisect/c7213deeb5c7abb0843088815580793b282fdc34/.venv/bin/python -m pip install --quiet /home/nod/.iree/bisect/c7213deeb5c7abb0843088815580793b282fdc34/iree_runtime-0.dev1-cp311-cp311-manylinux_2_28_x86_64.whl Checking packages with 'pip freeze': iree-compiler @ file:///home/nod/.iree/bisect/c7213deeb5c7abb0843088815580793b282fdc34/iree_compiler-0.dev1-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl#sha256=4078073daae1b706361091389753a4887bfa7d4797ea66dce1d0daaa5bffc58c iree-runtime @ file:///home/nod/.iree/bisect/c7213deeb5c7abb0843088815580793b282fdc34/iree_runtime-0.dev1-cp311-cp311-manylinux_2_28_x86_64.whl#sha256=564779699f560ba1da406c3d7d08fc75ba8b8eb2f6fc6e074e691a34bbb29bdf mpmath==1.3.0 numpy==2.1.3 sympy==1.13.3 ``` -------------------------------- ### Configure, Build, Test, and Run with Bazel Source: https://github.com/iree-org/iree/blob/main/build_tools/bin/README.md A quick start guide for using IREE's Bazel wrapper tools. These commands handle configuration, building, testing, and running targets within an IREE worktree. ```bash # Configure once per worktree iree-bazel-configure # Build iree-bazel-build //tools:iree-compile # Test iree-bazel-test //runtime/src/iree/base:status_test # Run iree-bazel-run //tools:iree-compile -- --help ``` -------------------------------- ### Build and Install IREE on Host Machine Source: https://github.com/iree-org/iree/blob/main/docs/website/docs/building-from-source/android.md Configures and builds IREE for the host machine, installing it to a specified directory. Ensure you have followed the getting started guide before running this. ```shell cmake -GNinja -B ../iree-build/ \ -DCMAKE_INSTALL_PREFIX=../iree-build/install \ -DCMAKE_BUILD_TYPE=RelWithDebInfo \ . cmake --build ../iree-build/ --target install ``` -------------------------------- ### Install IREE Runtime from Release Source: https://github.com/iree-org/iree/blob/main/docs/website/docs/guides/deployment-configurations/cpu.md Installs the IREE runtime with CPU HAL drivers from a release package. Ensure Python is installed and pip is available. ```bash pip install iree-base-runtime ``` -------------------------------- ### Install Bazel Watcher (ibazel) Source: https://github.com/iree-org/iree/blob/main/docs/website/docs/developers/building/bazel.md Install the `ibazel` tool, which is required for watch mode functionality in IREE's Bazel wrappers. This command uses `go install` to fetch and install the latest version. ```shell go install github.com/bazelbuild/bazel-watcher/cmd/ibazel@latest ``` -------------------------------- ### General Setup for Artifacts Directory Source: https://github.com/iree-org/iree/blob/main/samples/dynamic_shapes/tensorflow_dynamic_shapes.ipynb Sets up a temporary directory for storing compilation artifacts. This is a general setup step for the notebook. ```python #@title General setup import os import tempfile ARTIFACTS_DIR = os.path.join(tempfile.gettempdir(), "iree", "colab_artifacts") os.makedirs(ARTIFACTS_DIR, exist_ok=True) print(f"Using artifacts directory '{ARTIFACTS_DIR}'") ``` -------------------------------- ### Install Compiler on Linux Source: https://github.com/iree-org/iree/blob/main/docs/website/docs/developers/building/bazel.md Install Clang compiler and set environment variables for Bazel. ```shell sudo apt install clang export CC=clang export CXX=clang++ ``` -------------------------------- ### Install TensorFlow Source: https://github.com/iree-org/iree/blob/main/docs/website/docs/guides/ml-frameworks/tflite.md Installs TensorFlow. Ensure you use a compatible version as specified. ```shell python -m pip install "tensorflow<=2.18.0" ``` -------------------------------- ### Install Bazelisk on Linux Source: https://github.com/iree-org/iree/blob/main/docs/website/docs/developers/building/bazel.md Install Bazelisk via Go or by downloading the binary directly. This ensures the correct Bazel version is used. ```shell # Via Go (if installed) go install github.com/bazelbuild/bazelisk@latest # go install names the binary 'bazelisk'. Add a symlink so # 'bazel' works (~/go/bin should already be on your PATH). ln -s ~/go/bin/bazelisk ~/go/bin/bazel # Or download binary directly as 'bazel' (recommended by bazelisk docs). curl -Lo ~/.local/bin/bazel \ https://github.com/bazelbuild/bazelisk/releases/latest/download/bazelisk-linux-amd64 chmod +x ~/.local/bin/bazel ``` -------------------------------- ### Install Dependencies on Debian/Ubuntu Source: https://github.com/iree-org/iree/blob/main/docs/website/docs/building-from-source/getting-started.md Installs CMake, Ninja, clang, and lld using apt. Ensure these are available before proceeding with the build. ```shell sudo apt install cmake ninja-build clang lld ``` -------------------------------- ### Build and Run Sample Application Source: https://github.com/iree-org/iree/blob/main/docs/website/docs/building-from-source/getting-started.md Build the project and then execute a standalone sample application like 'hello_world_embedded'. Also shows how to access developer tools like 'iree-compile' and 'iree-run-module'. ```shell # Build cmake --build ../iree-build/ # Run a standalone sample application ../iree-build/runtime/src/iree/runtime/demo/hello_world_embedded # 4xf32=1 1.1 1.2 1.3 # * # 4xf32=10 100 1000 10000 # = # 4xf32=10 110 1200 13000 # Try out the developer tools ls ../iree-build/tools/ ../iree-build/tools/iree-compile --help ../iree-build/tools/iree-run-module --help ``` -------------------------------- ### Configure and Build IREE for Host Source: https://github.com/iree-org/iree/blob/main/docs/website/docs/building-from-source/riscv.md Build and install IREE on your host machine using CMake. Ensure you have followed the getting started steps. ```shell cmake -GNinja -B ../iree-build/ \ -DCMAKE_C_COMPILER=clang \ -DCMAKE_CXX_COMPILER=clang++ \ -DCMAKE_INSTALL_PREFIX=../iree-build/install \ -DCMAKE_BUILD_TYPE=RelWithDebInfo \ . cmake --build ../iree-build/ --target install ``` -------------------------------- ### Build WebGPU Hello World Module Source: https://github.com/iree-org/iree/blob/main/samples/webgpu/hello_world/README.md Build the WebGPU bytecode module for the hello_world sample using Bazel. ```sh build_tools/bin/iree-bazel-build \ //samples/webgpu/hello_world:hello_world_bytecode_module_webgpu ``` -------------------------------- ### Get App Container Path Source: https://github.com/iree-org/iree/blob/main/docs/website/docs/building-from-source/ios.md Retrieve the path to the application container for `iree-run-module` on the simulator. This path is needed to locate installed files, such as the compiled IREE module. ```shell ls $(xcrun simctl get_app_container dev.iree.iree-run-module) ``` -------------------------------- ### Setup LLVM Symbolizer in Manylinux Container Source: https://github.com/iree-org/iree/blob/main/docs/website/docs/developers/debugging/releases.md Install LLVM version 9.0 and create a symbolic link for 'llvm-symbolizer' to aid in debugging stack traces within the manylinux container. ```shell yum install llvm9.0 ln -s /usr/bin/llvm-symbolizer-9.0 /usr/bin/llvm-symbolizer ``` -------------------------------- ### Hello World Explained C API Example Source: https://github.com/iree-org/iree/blob/main/docs/website/docs/reference/bindings/c-api.md A detailed example of the high-level runtime API for a 'hello world' scenario, including extensive comments. This snippet is useful for learning the API with explanations. ```c++ --8<-- "runtime/src/iree/runtime/demo/hello_world_explained.c:7" ``` -------------------------------- ### Build with Bazel Source: https://github.com/iree-org/iree/blob/main/samples/simple_embedding/README.md Use this command to build the sample with Bazel for host execution. ```sh bazel build samples/simple_embedding:all ``` -------------------------------- ### Define MLP Torch LIT Test Suite Source: https://github.com/iree-org/iree/blob/main/samples/custom_dispatch/cpu/mlp_plugin/CMakeLists.txt Configures a LIT test suite for the MLP Torch example. This setup includes the Torch MLIR source, required tools, the custom plugin, and associated data files. ```cmake iree_lit_test_suite( NAME mlp_torch_example SRCS "mlp_torch.mlir" TOOLS FileCheck iree-compile iree-run-module iree_samples_custom_dispatch_cpu_mlp_plugin DATA "mlp_torch_spec.pdl.mlir" LABELS "driver=local-sync" "hostonly" ) ``` -------------------------------- ### Interact with Compiled Module Functions Source: https://github.com/iree-org/iree/blob/main/samples/variables_and_state/variables_and_state.ipynb Accesses and calls functions within a compiled IREE VM module. This example shows how to get a module named 'module' and interact with its functions like get_value, set_value, add_to_value, and reset_value. Note that some functions might be buggy in Python and are commented out. ```python # Our @tf.functions are accessible by name on the module named 'module' counter = ctx.modules.module # These are buggy in Python but should still work from C # TODO(scotttodd): figure out why and fix # print(counter.get_value().to_host()) # counter.set_value(101) # print(counter.get_value().to_host()) # counter.add_to_value(20) # print(counter.get_value().to_host()) # counter.add_to_value(-50) # print(counter.get_value().to_host()) # counter.reset_value() # print(counter.get_value().to_host()) ``` -------------------------------- ### List and Execute Built Tools Source: https://github.com/iree-org/iree/blob/main/docs/website/docs/developers/building/bazel.md After building, you can list the contents of the 'bazel-bin/tools/' directory to see the compiled executables. The example shows how to check the help message for 'iree-compile'. ```shell ls bazel-bin/tools/ ``` ```shell ./bazel-bin/tools/iree-compile --help ``` -------------------------------- ### Create a Proactor Source: https://github.com/iree-org/iree/blob/main/runtime/src/iree/async/README.md Demonstrates how to create a proactor instance using platform-specific or generic platform APIs. Includes options for default settings and system allocator. Cleanup requires quiescing the proactor before releasing it. ```c #include "iree/async/proactor_platform.h" iree_async_proactor_t* proactor = NULL; ikówre_async_proactor_options_t options = iree_async_proactor_options_default(); IREE_RETURN_IF_ERROR(iree_async_proactor_create_platform( options, iree_allocator_system(), &proactor)); // Or create a specific backend: #include "iree/async/platform/io_uring/api.h" IREE_RETURN_IF_ERROR(iree_async_proactor_create_io_uring( options, iree_allocator_system(), &proactor)); #include "iree/async/platform/posix/proactor.h" IREE_RETURN_IF_ERROR(iree_async_proactor_create_posix( options, iree_allocator_system(), &proactor)); // Cleanup (must have quiesced): ikówre_async_proactor_release(proactor); ``` -------------------------------- ### Report Installed Versions Source: https://github.com/iree-org/iree/blob/main/samples/colab/pytorch_aot_advanced.ipynb Reports the installed versions of IREE-Turbine and PyTorch. This is useful for verifying installations and debugging compatibility issues. ```bash #@title Report version information !echo "Installed iree-turbine, $(python -m pip show iree_turbine | grep Version)" !echo -e "\nInstalled IREE, compiler version information:" !iree-compile --version ``` ```python import torch print("\nInstalled PyTorch, version:", torch.__version__) ``` -------------------------------- ### Hello World Terse C API Example Source: https://github.com/iree-org/iree/blob/main/docs/website/docs/reference/bindings/c-api.md A concise example demonstrating the high-level runtime API for a 'hello world' scenario. This snippet is suitable for quick integration and understanding basic usage. ```c++ --8<-- "runtime/src/iree/runtime/demo/hello_world_terse.c:7" ``` -------------------------------- ### Install IREE Compiler from Release Source: https://github.com/iree-org/iree/blob/main/docs/website/docs/guides/deployment-configurations/cpu.md Installs the IREE compiler from a release package. Ensure Python is installed and pip is available. ```bash pip install iree-base-compiler ``` -------------------------------- ### Install RISC-V Toolchain and Emulator Source: https://github.com/iree-org/iree/blob/main/docs/website/docs/building-from-source/riscv.md Execute this script to download prebuilt RISC-V toolchain and QEMU. The default install path is ~/riscv/toolchain/clang/linux/RISCV. ```shell ./build_tools/riscv/riscv_bootstrap.sh ``` -------------------------------- ### Run Example Program with iree-run-module Source: https://github.com/iree-org/iree/blob/main/samples/custom_module/static/README.md Executes the compiled example program using the `iree-run-module` tool, loading the custom module from the specified .vmfb file and targeting the 'main' function. ```sh ../iree-build/tools/iree-run-module \ --module=/tmp/example.vmfb \ --function=main ``` -------------------------------- ### Installing IREE tools for TF tests (nightly) Source: https://github.com/iree-org/iree/blob/main/docs/website/docs/developers/debugging/integration-tests.md Install IREE's tools and Python bindings from nightly pre-releases. This is the recommended approach for most cases as importers change infrequently. ```bash # Install packages from nightly pre-releases # This should work for most cases, as the importers change infrequently python -m pip install --pre \ iree-base-compiler iree-base-runtime iree-tools-tf iree-tools-tflite \ --find-links https://iree.dev/pip-release-links.html ``` -------------------------------- ### Install IREE Turbine Source: https://github.com/iree-org/iree/blob/main/samples/colab/pytorch_huggingface_whisper.ipynb Installs the IREE Turbine Python package from a specific URL. This command also handles the installation of its dependencies, including iree-base-compiler and iree-base-runtime. ```python !python -m pip install --pre iree-turbine -f https://iree.dev/pip-release-links.html ``` -------------------------------- ### Install TensorFlow/TFLite Bindings Source: https://github.com/iree-org/iree/blob/main/docs/website/docs/building-from-source/getting-started.md Install IREE's TensorFlow and TFLite importer requirements and packages. Use `pip install -e` for an editable wheel if needed. ```shell # Install test requirements python -m pip install -r integrations/tensorflow/test/requirements.txt # Install pure Python packages (no build required) # You may use `pip install -e` here to create an editable wheel. python -m pip install integrations/tensorflow/python_projects/iree_tf python -m pip install integrations/tensorflow/python_projects/iree_tflite # Then test the tools: iree-import-tf --help iree-import-tflite --help ``` -------------------------------- ### Running IREE with Executable Plugins Source: https://github.com/iree-org/iree/blob/main/samples/custom_dispatch/cpu/plugin/README.md Command-line example for iree-run-module, specifying device, executable plugins, function to run, and input data. Plugins are resolved in reverse registration order. ```bash iree-run-module \ --device=local-sync \ --executable_plugin=my_plugins.so \ --executable_plugin=other_plugins.so \ --function=mixed_invocation \ --input=8xf32=2 \ --input=8xf32=4 ``` -------------------------------- ### Install Public MLIR-C Headers Source: https://github.com/iree-org/iree/blob/main/compiler/bindings/c/CMakeLists.txt Installs public MLIR-C headers to the CMAKE_INSTALL_INCLUDEDIR. This loop iterates through MLIR include directories and installs the 'mlir-c' subdirectory if found. ```cmake install( DIRECTORY "${_d}/mlir-c" DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} COMPONENT IREEDevLibraries-Compiler EXCLUDE_FROM_ALL ) ``` -------------------------------- ### Generate Agent Markdown Guidance Source: https://github.com/iree-org/iree/blob/main/docs/website/docs/developers/performance/device-replay.md Use these commands to print Markdown guidance from the exact binary in your build tree. This is useful for integrating replay into scripts, CI reproducers, or agent workflows. ```shell iree-run-module --agents_md iree-benchmark-module --agents_md iree-run-replay --agents_md iree-benchmark-replay --agents_md iree-dump-replay --agents_md ``` -------------------------------- ### Compile and Run Sample Source: https://github.com/iree-org/iree/blob/main/samples/compiler_plugins/simple_io_sample/README.md Compile an MLIR file using the plugin and then run the compiled module with the Python runner. ```bash iree-compile --iree-plugin=simple_io_sample test/print.mlir -o /tmp/print.vmfb python run_mock.py /tmp/print.vmfb ``` -------------------------------- ### Verify ROCm Installation on Linux Source: https://github.com/iree-org/iree/blob/main/docs/website/docs/guides/deployment-configurations/gpu-rocm.md Use the `rocminfo` tool to check if a functional ROCm environment is installed on your Linux system. If not found, install the latest ROCm for Linux. ```console $ rocminfo ROCk module is loaded ==================== HSA System Attributes ==================== Runtime Version: 1.13 Runtime Ext Version: 1.4 ... ``` -------------------------------- ### Start New Turbine Development Build (Windows) Source: https://github.com/iree-org/iree/blob/main/build_tools/cmake/presets/README.md Sets up a new development build on Windows, enabling only the features required for Turbine development, including the CPU backend, Torch input, and Python bindings. ```bash cmake --preset new-windows-turbine ``` -------------------------------- ### Install IREE Runtime Python Package Source: https://github.com/iree-org/iree/blob/main/runtime/README.md Directly install the IREE runtime Python package from the source or build directory. It is recommended to use virtual environments for installation. ```bash python -m pip install runtime/ ``` -------------------------------- ### Install Bazelisk on macOS Source: https://github.com/iree-org/iree/blob/main/docs/website/docs/developers/building/bazel.md Install Bazelisk using Homebrew for macOS. ```shell brew install bazelisk ``` -------------------------------- ### Install IREE Runtime Libraries via CMake Source: https://github.com/iree-org/iree/blob/main/runtime/bindings/python/CMakeLists.txt This CMake code evaluates and defers the installation of IREE runtime libraries. It specifies targets, destination directory, and component for installation. ```cmake cmake_language(EVAL CODE " cmake_language(DEFER DIRECTORY \"${IREE_SOURCE_DIR}\"\n CALL install\n TARGETS\n iree-as-module\n iree-cpuinfo\n iree-c-embed-data\n iree-convert-parameters\n iree-create-parameters\n iree-dump-module\n iree-dump-parameters\n iree-dump-replay\n iree-flatcc-cli\n iree-profile\n iree-run-module\n iree-run-replay\n ${_EXTRA_INSTALL_TOOL_TARGETS}\n DESTINATION \"${_INSTALL_DIR}/iree/_runtime_libs\"\n COMPONENT \"${_INSTALL_COMPONENT}\"\n) ") ``` -------------------------------- ### Start New Development Build (Linux) Source: https://github.com/iree-org/iree/blob/main/build_tools/cmake/presets/README.md Use this preset to set up a new development directory with CMake defaults for all project features on a Linux system. This command should be run from the source directory. ```bash cmake --preset new-linux-dev ``` -------------------------------- ### Install iree-turbine Package Source: https://github.com/iree-org/iree/blob/main/samples/dynamic_shapes/pytorch_dynamic_shapes.ipynb Installs the `iree-turbine` package, which is essential for advanced Ahead-Of-Time (AOT) compilation of PyTorch programs with IREE. It also installs necessary dependencies like `iree-base-compiler` and `iree-base-runtime`. ```python #@title Install iree-turbine # Limit cell height. from IPython.display import Javascript display(Javascript('''google.colab.output.setIframeHeight(0, true, {maxHeight: 300})''')) !python -m pip install iree-turbine ``` -------------------------------- ### Install Vulkan-Headers Source: https://github.com/iree-org/iree/blob/main/CMakeLists.txt Adds the Vulkan headers subdirectory and installs the Vulkan-Headers target. ```cmake if(IREE_HAL_DRIVER_VULKAN) add_subdirectory(third_party/vulkan_headers EXCLUDE_FROM_ALL) iree_install_targets( TARGETS Vulkan-Headers COMPONENT IREEBundledLibraries EXPORT_SET Runtime ) endif() ``` -------------------------------- ### Example Command to Run Bisect Source: https://github.com/iree-org/iree/blob/main/build_tools/pkgci/bisect/README.md Initiates the package bisect process with specified good and bad references and a test script. The tool will then automatically test commits between these references. ```bash ./bisect_packages.py \ --good-ref=candidate-20241016.1048 \ --bad-ref=candidate-20241017.1049 \ --test-script=/home/nod/.iree/bisect/issue_18879.sh ``` -------------------------------- ### Install PyTorch 2.3.0 (CPU) Source: https://github.com/iree-org/iree/blob/main/samples/colab/pytorch_aot_simple.ipynb Installs PyTorch version 2.3.0 specifically for CPU usage from a test index URL. This command upgrades the existing PyTorch installation if a newer version is available. ```python #@title Install Pytorch 2.3.0 (for CPU) !python -m pip install --index-url https://download.pytorch.org/whl/test/cpu --upgrade torch==2.3.0 ``` -------------------------------- ### Run Custom Module Sync Example Source: https://github.com/iree-org/iree/blob/main/samples/custom_module/sync/README.md Execute the compiled custom module sync program. This command passes the compiled .vmfb file and the entry point function name as arguments. ```sh ../iree-build/samples/custom_module/sync/custom-module-sync-run \ /tmp/example.vmfb example.main ``` -------------------------------- ### Install TensorFlow Source: https://github.com/iree-org/iree/blob/main/samples/colab/tensorflow_mnist_training.ipynb Installs or upgrades the TensorFlow library. Use this to ensure you have a compatible version. ```python %%capture !python -m pip install --upgrade tensorflow ``` -------------------------------- ### Check clang Installation Source: https://github.com/iree-org/iree/blob/main/samples/custom_dispatch/cpu/embedded/README.md Verify that clang is installed and accessible in your system's PATH. ```bash clang --version ``` -------------------------------- ### View `iree-create-parameters` Help Output Source: https://github.com/iree-org/iree/blob/main/docs/website/docs/guides/parameters.md Display the help message for the `iree-create-parameters` tool to get a detailed list of available options and their descriptions. This is useful for understanding all configuration possibilities. ```console $ iree-create-parameters --help ``` -------------------------------- ### Compile and Run C++ Snippets Source: https://github.com/iree-org/iree/blob/main/docs/website/docs/developers/building/bazel.md Utilize `iree-bazel-try` for quick C++ experiments without requiring explicit BUILD files. This example compiles and runs a simple C++ snippet that checks for an OK status. ```shell # Quick C++ experiment iree-bazel-try -e '#include "iree/base/api.h" int main() { return iree_status_is_ok(iree_ok_status()) ? 0 : 1; }' ``` -------------------------------- ### Install TensorFlow Source: https://github.com/iree-org/iree/blob/main/samples/colab/tensorflow_resnet.ipynb Installs or upgrades the TensorFlow library. This is a prerequisite for using TensorFlow models. ```python #@title Licensed under the Apache License v2.0 with LLVM Exceptions. # See https://llvm.org/LICENSE.txt for license information. # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception ``` ```python %%capture !python -m pip install --upgrade tensorflow ``` -------------------------------- ### Install Bazel on macOS (Alternative) Source: https://github.com/iree-org/iree/blob/main/docs/website/docs/developers/building/bazel.md Install Bazel manually or via Homebrew on macOS. ```shell brew install bazel ``` -------------------------------- ### Basic ccache usage Source: https://github.com/iree-org/iree/blob/main/docs/website/docs/developers/building/cmake-with-ccache.md This is an example of how to prepend compiler invocations with `ccache`. ```shell ccache clang foo.c -c -o foo.o ``` -------------------------------- ### Install Python Build Requirements Source: https://github.com/iree-org/iree/blob/main/docs/website/docs/developers/building/bazel.md Install Python dependencies required for building IREE. ```shell python -m pip install -r runtime/bindings/python/iree/runtime/build_requirements.txt ``` -------------------------------- ### Setup Artifacts Directory Source: https://github.com/iree-org/iree/blob/main/samples/colab/tensorflow_edge_detection.ipynb Creates a directory for storing compilation artifacts. This is used later in the low-level compilation process. ```python #@title Setup Artifacts Directory # Used in the low-level compilation section. ARTIFACTS_DIR = os.path.join(tempfile.gettempdir(), "iree", "colab_artifacts") os.makedirs(ARTIFACTS_DIR, exist_ok=True) ``` -------------------------------- ### Verify Jax Installation Source: https://github.com/iree-org/iree/blob/main/integrations/pjrt/README.md Confirms that your Jax installation is functional by running a simple NumPy operation. ```python python -c "import jax; a = jax.numpy.asarray([1, 2, 3, 4, 5, 6, 7, 8, 9]); print(a + a);" ``` -------------------------------- ### Clone and Build IREE Project Source: https://github.com/iree-org/iree/blob/main/docs/website/docs/developers/building/bazel.md This snippet covers the essential steps to clone the IREE repository, set up the environment, configure Bazel, and build/test the project. ```shell # Clone and setup git clone https://github.com/iree-org/iree.git cd iree git submodule update --init python -m pip install -r runtime/bindings/python/iree/runtime/build_requirements.txt # Add tools to PATH (from repo root) export PATH="$PWD/build_tools/bin:$PATH" # Configure once iree-bazel-configure # Build and test iree-bazel-build //tools:iree-compile iree-bazel-test //... ```