These are steps to reproduce/address failures in TF/TFLite integration tests. These instructions are most stable on Linux, though they may work with a few tweaks on Windows and macOS.
All steps here assume starting from the IREE root directory.
First create a Python virtual environment to install packages into:
python -m venv iree-tf.venv source iree-tf.venv/bin/activate # Install test requirements python -m pip install -r ./integrations/tensorflow/test/requirements.txt
Install IREE's tools and Python bindings or build them from source
Install distributed packages
# Install packages from nightly releases # This should work for most cases, as the importers change infrequently python -m pip install \ iree-compiler iree-runtime iree-tools-tf iree-tools-tflite \ --find-links https://openxla.github.io/iree/pip-release-links.html
OR build from source
# Build Python bindings from source cmake -G Ninja -B ../iree-build/ -DIREE_BUILD_PYTHON_BINDINGS=ON . cmake --build ../iree-build/ # Add IREE built-from-source Python packages to PYTHONPATH source .env # Install IREE TF/TFLite Python packages python -m pip install integrations/tensorflow/python_projects/iree_tf python -m pip install integrations/tensorflow/python_projects/iree_tflite
Run the python test command line
The command can be obtained from the run file. For example, if iree_tfl_tests/llvmcpu_posenet_i8.run
failed,
cd integrations/tensorflow/test/ cat iree_tfl_tests/llvmcpu_posenet_i8.run # REQUIRES: llvmcpu # RUN: %PYTHON -m iree_tfl_tests.posenet_i8_test --target_backend=llvmcpu --artifacts_dir=%t cd python/ python -m iree_tfl_tests.posenet_i8_test --target_backend=llvmcpu --artifacts_dir=/tmp/posenet_i8_failure
Note that the command can only be run under integrations/tensorflow/test/python
directory.
Extract intermediate files and use with native tools
The test will create an iree_input.mlir
in the temp directory specified. Those can then be fed into iree-compile
(built locally to reproduce the error)
iree-compile \ --iree-hal-target-backends=llvm-cpu \ --iree-input-type=mhlo \ iree_input.mlir