Skip to content

Commit

Permalink
Merge pull request iree-org#7407 from google:main-to-google
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 404407975
  • Loading branch information
iree-copybara-bot committed Oct 20, 2021
2 parents d50bb8d + 9cdbfe1 commit 13c9db4
Show file tree
Hide file tree
Showing 43 changed files with 2,268 additions and 156 deletions.
31 changes: 30 additions & 1 deletion .github/workflows/build_package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ jobs:
- os: ubuntu-18.04
build_package: py-runtime-pkg
experimental: false
- os: ubuntu-18.04
build_package: instrumented-py-runtime-pkg
experimental: true
- os: ubuntu-18.04
build_package: py-xla-compiler-tools-pkg
experimental: false
Expand Down Expand Up @@ -122,7 +125,8 @@ jobs:
run: |
python -m pip install cibuildwheel==1.7.2
- name: Write version info
- name: Write version info (release)
if: "!startsWith(matrix.build_package, 'instrumented-')"
shell: bash
run: |
cat << EOF > ./main_checkout/version_info.json
Expand All @@ -134,6 +138,19 @@ jobs:
EOF
cat ./main_checkout/version_info.json
- name: Write version info (instrumented)
if: "startsWith(matrix.build_package, 'instrumented-')"
shell: bash
run: |
cat << EOF > ./main_checkout/version_info.json
{
"package-suffix": "-instrumented${{ github.event.inputs.package_suffix }}",
"package-version": "${{ github.event.inputs.package_version }}",
"iree-revision": "$(cd ./main_checkout && git rev-parse HEAD)"
}
EOF
cat ./main_checkout/version_info.json
# The main distribution consists of the project being built, installed
# and archived. We have to split it per operating system, and Linux
# is special because we build under a manylinux container which gives
Expand Down Expand Up @@ -167,6 +184,18 @@ jobs:
mkdir -p $package_dir && touch $package_dir/setup.py
python -m cibuildwheel --output-dir bindist $package_dir
- name: Build runtime wheels (instrumented)
if: "matrix.build_package == 'instrumented-py-runtime-pkg'"
shell: bash
run: |
package_dir="./iree-install/python_packages/iree_runtime"
export CIBW_BEFORE_ALL_LINUX="./main_checkout/build_tools/github_actions/install_tracy_cli_deps_manylinux2014.sh"
export CIBW_BEFORE_BUILD="python ./main_checkout/build_tools/github_actions/build_dist.py instrumented-py-runtime-pkg"
# TODO: cibuildwheel sanity checks this, but our setup.py is the
# *output* of the build :( Make source packages.
mkdir -p $package_dir && touch $package_dir/setup.py
python -m cibuildwheel --output-dir bindist $package_dir
# Experimental iree.compiler package.
- name: Build compiler wheels
if: "matrix.build_package == 'py-compiler-pkg'"
Expand Down
17 changes: 12 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ option(IREE_BUILD_TESTS "Builds IREE unit tests." ON)
option(IREE_BUILD_BENCHMARKS "Builds IREE benchmark suites." OFF)
option(IREE_BUILD_DOCS "Builds IREE docs." OFF)
option(IREE_BUILD_SAMPLES "Builds IREE sample projects." ON)
option(IREE_BUILD_TRACY "Builds tracy server tools." OFF)

option(IREE_BUILD_TENSORFLOW_ALL "Builds all TensorFlow compiler frontends." OFF)
option(IREE_BUILD_TENSORFLOW_COMPILER "Builds TensorFlow compiler frontend." OFF)
Expand Down Expand Up @@ -446,10 +447,6 @@ if(IREE_BUILD_COMPILER)
add_subdirectory(build_tools/third_party/mlir-hlo EXCLUDE_FROM_ALL)
endif()

if(IREE_ENABLE_EMITC)
add_subdirectory(build_tools/third_party/mlir-emitc EXCLUDE_FROM_ALL)
endif()

if(IREE_BUILD_TESTS)
enable_testing(iree)
endif()
Expand Down Expand Up @@ -516,8 +513,18 @@ endif()

add_subdirectory(iree/tools)

if(IREE_BUILD_TRACY)
if(NOT LINUX)
message(WARNING "Building Tracy (IREE_BUILD_TRACY) on non-Linux is unsupported and may fail below.")
endif()
add_subdirectory(build_tools/third_party/tracy ${CMAKE_CURRENT_BINARY_DIR}/tracy)
if(NOT TARGET IREETracyCaptureServer)
message(SEND_ERROR "Could not build Tracy. Either unset IREE_BUILD_TRACY or look for missing dependencies above and install them.")
endif()
endif()

# Order constraint: The python bindings install tools targets from iree/tools
# and must come after it.
# and tracy, and must come after it.
if(${IREE_BUILD_PYTHON_BINDINGS})
add_subdirectory(bindings/python)
endif()
Expand Down
21 changes: 21 additions & 0 deletions benchmarks/TensorFlow/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,27 @@ iree_mlir_benchmark_suite(
"--batch_size=32"
)

# GPU, Vulkan, Mali, full-inference
iree_mlir_benchmark_suite(
MODULES
${MOBILEBERT_FP16_MODULE}

BENCHMARK_MODES
"full-inference"
TARGET_BACKEND
"vulkan-spirv"
TARGET_ARCHITECTURE
"GPU-Mali-Valhall"
TRANSLATION_FLAGS
"--iree-input-type=mhlo"
"--iree-flow-demote-f32-to-f16"
"--iree-vulkan-target-triple=valhall-unknown-android11"
"--iree-flow-inline-constants-max-byte-length=16"
"--iree-enable-fusion-with-reduction-ops"
DRIVER
"vulkan"
)

################################################################################
# #
# Speical benchmark configurations #
Expand Down
31 changes: 31 additions & 0 deletions bindings/python/iree/runtime/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,17 @@
# See https://llvm.org/LICENSE.txt for license information.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

set(_python_extra_srcs)
set(_extra_install_tool_targets)
set(_tracy_enabled OFF)

if(TARGET IREETracyCaptureServer)
message(STATUS "Bundline Tracy CLI tools with Python API")
set(_tracy_enabled ON)
list(APPEND _python_extra_srcs "scripts/iree-tracy-capture")
list(APPEND _extra_install_tool_targets "IREETracyCaptureServer")
endif()

################################################################################
# Package
################################################################################
Expand Down Expand Up @@ -43,6 +54,8 @@ iree_py_library(
"tracing.py"
"scripts/iree_benchmark_trace/__main__.py"
"scripts/iree_run_trace/__main__.py"
"scripts/iree_run_module/__main__.py"
${_python_extra_srcs}
PYEXT_DEPS
::PyExtRt
)
Expand All @@ -59,6 +72,20 @@ iree_symlink_tool(
TO_EXE_NAME iree-run-trace
)

iree_symlink_tool(
TARGET runtime
FROM_TOOL_TARGET iree_tools_iree-run-module
TO_EXE_NAME iree-run-module
)

if(_tracy_enabled)
iree_symlink_tool(
TARGET runtime
FROM_TOOL_TARGET IREETracyCaptureServer
TO_EXE_NAME iree-tracy-capture
)
endif()

################################################################################
# Tests
################################################################################
Expand Down Expand Up @@ -102,7 +129,9 @@ iree_py_install_package(
DEPS
bindings_python_iree_runtime_PyExtRt
iree_tools_iree-benchmark-trace
iree_tools_iree-run-module
iree_tools_iree-run-trace
${_extra_install_tool_targets}
ADDL_PACKAGE_FILES
${CMAKE_CURRENT_SOURCE_DIR}/README.md
)
Expand All @@ -116,7 +145,9 @@ install(
install(
TARGETS
iree_tools_iree-benchmark-trace
iree_tools_iree-run-module
iree_tools_iree-run-trace
${_extra_install_tool_targets}
DESTINATION "${PY_INSTALL_MODULE_DIR}"
COMPONENT "${PY_INSTALL_COMPONENT}"
)
20 changes: 20 additions & 0 deletions bindings/python/iree/runtime/scripts/iree_run_module/__main__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Copyright 2021 The IREE Authors
#
# 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

import os
import subprocess
import sys


def main(args=None):
if args is None:
args = sys.argv[1:]
exe = os.path.join(os.path.dirname(__file__), "..", "..", "iree-run-module")
return subprocess.call(args=[exe] + args)


if __name__ == "__main__":
sys.exit(main())
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Copyright 2021 The IREE Authors
#
# 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

import os
import subprocess
import sys


def main(args=None):
if args is None:
args = sys.argv[1:]
exe = os.path.join(os.path.dirname(__file__), "..", "..",
"iree-tracy-capture")
return subprocess.call(args=[exe] + args)


if __name__ == "__main__":
sys.exit(main())
4 changes: 4 additions & 0 deletions bindings/python/iree/runtime/setup.py.in
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,18 @@ setup(
package_data={
"": [
f"*{sysconfig.get_config_var('EXT_SUFFIX')}",
"iree-run-module*",
"iree-run-trace*",
"iree-benchmark-trace*",
"iree-tracy-capture*",
],
},
entry_points={
"console_scripts": [
"iree-run-module = iree.runtime.scripts.iree_run_module.__main__:main",
"iree-run-trace = iree.runtime.scripts.iree_run_trace.__main__:main",
"iree-benchmark-trace = iree.runtime.scripts.iree_benchmark_trace.__main__:main",
"iree-tracy-capture = iree.runtime.scripts.iree_tracy_capture.__main__:main",
],
},
zip_safe=False,
Expand Down
19 changes: 17 additions & 2 deletions build_tools/github_actions/build_dist.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,17 +210,30 @@ def build_py_pure_pkgs():
check=True)


def build_py_runtime_pkg():
def build_py_runtime_pkg(instrumented: bool = False):
"""Builds the iree-install/python_packages/iree_runtime package.
This includes native, python-version dependent code and is designed to
be built multiple times.
Note that an instrumented build may require additional dependencies.
See: install_tracy_cli_deps_manylinux2014.sh for how to set up on that
container.
"""
install_python_requirements()

# Clean up install and build trees.
shutil.rmtree(INSTALL_DIR, ignore_errors=True)
remove_cmake_cache()
extra_cmake_flags = []

# Extra options for instrumentation.
if instrumented:
print("*** Enabling options for instrumented build ***")
extra_cmake_flags.extend([
f"-DIREE_ENABLE_RUNTIME_TRACING=ON",
f"-DIREE_BUILD_TRACY=ON",
])

# CMake configure.
print("*** Configuring ***")
Expand All @@ -234,7 +247,7 @@ def build_py_runtime_pkg():
f"-DIREE_BUILD_PYTHON_BINDINGS=ON",
f"-DIREE_BUILD_SAMPLES=OFF",
f"-DIREE_BUILD_TESTS=OFF",
],
] + extra_cmake_flags,
check=True)

print("*** Building ***")
Expand Down Expand Up @@ -405,6 +418,8 @@ def build_py_tf_compiler_tools_pkg():
build_main_dist()
elif command == "py-runtime-pkg":
build_py_runtime_pkg()
elif command == "instrumented-py-runtime-pkg":
build_py_runtime_pkg(instrumented=True)
elif command == "py-pure-pkgs":
build_py_pure_pkgs()
elif command == "py-xla-compiler-tools-pkg":
Expand Down
50 changes: 50 additions & 0 deletions build_tools/github_actions/install_tbb_manylinux2014.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#!/bin/bash
# Copyright 2021 The IREE Authors
#
# 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
# The version of tbb installed on manylinux2014 is too old to support the
# parallel STL libraries on the installed GCC9-based toolchain. Further,
# Intel *broke* compatibility starting in 2021 for GCC<=10.
# To make matters worse, the prior 2020 versions did not have cmake or
# install support.
# Shame on you Intel.
# See: https://community.intel.com/t5/Intel-oneAPI-Threading-Building/tbb-task-has-not-been-declared/m-p/1254418
# Since this is unlikely to be helpful outside of the old centos systems
# that manylinux2014 is based on (newer ones are based on Debian),
# we just tailor this specifically for docker images of that distro.

# You can test this with either an official manylinux2014 docker image or
# our special one (which is really only special in that it includes bazel):
# docker run --rm -it -v $(pwd):/work stellaraccident/manylinux2014_x86_64-bazel-3.7.2:latest /bin/bash

set -e

mkdir -p /tmp/libtbb_build
cd /tmp/libtbb_build
curl -o tbbsrc.tgz -L https://github.com/oneapi-src/oneTBB/archive/refs/tags/v2020.3.tar.gz
tar xzf tbbsrc.tgz
cd oneTBB-*/

echo "****** BUILDING TBB ******"
make -j$(nproc)
cp -R include/* /usr/include
cp build/*_release/* /usr/lib64
echo "prefix=/usr
exec_prefix=${prefix}
libdir=${exec_prefix}/lib64
includedir=${prefix}/include
Name: Threading Building Blocks
Description: Intel's parallelism library for C++
URL: http://www.threadingbuildingblocks.org/
Version:
Libs: -ltbb
Cflags:
" > /usr/lib64/pkgconfig/tbb.pc

echo "****** DONE BUILDING TBB ******"

cd /
rm -Rf /tmp/libtbb_build
14 changes: 14 additions & 0 deletions build_tools/github_actions/install_tracy_cli_deps_manylinux2014.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/bash
# Copyright 2021 The IREE Authors
#
# 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
# Installs deps on a manylinux2014 CentOS docker container needed for
# building Tracy CLI capture tool.

set -e

td="$(cd $(dirname $0) && pwd)"
yum -y install capstone-devel libzstd-devel
$td/install_tbb_manylinux2014.sh
Loading

0 comments on commit 13c9db4

Please sign in to comment.