Merge google -> main (#2559)
Submodule updates and markdown formatting.
* d0a09812 Merge pull request #2549 from ScottTodd:main-to-google
* bc2a0879 Synchronize submodules
* 4d7a87ba Integrate TF at tensorflow/tensorflow@e36aca0132fb
* 3d575845 Synchronize submodules
* bb3c982a Integrate LLVM at https://github.com/llvm/llvm-project/commit/de0c6bd56b41
* db1898cf Synchronize submodules
* 1d14c787 Integrate LLVM at https://github.com/llvm/llvm-project/commit/e297006d6f02
* 1f41395f Synchronize submodules
* 757ce14d Integrate LLVM at https://github.com/llvm/llvm-project/commit/6bba95831e48
* 38617f1f Synchronize submodules
* 11adbdcd Integrate LLVM at https://github.com/llvm/llvm-project/commit/8ef9e2bf355d
* 71b5a11d Synchronize submodules
* 6da6e431 Integrate LLVM at https://github.com/llvm/llvm-project/commit/1d3f61f8a799
diff --git a/.bazelrc b/.bazelrc
index 27a05f2..2fbdb6f 100644
--- a/.bazelrc
+++ b/.bazelrc
@@ -12,276 +12,10 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-###############################################################################
-# Common flags that apply to all configurations.
-# Use sparingly for things common to all compilers and platforms.
-###############################################################################
-# Prevent invalid caching if input files are modified during a build.
-build --experimental_guard_against_concurrent_changes
-# Default to optimized builds
-# Override via: "-c dbg" or --compilation_mode=dbg
-build --compilation_mode=opt
-# Used in TensorFlow, so we have to enable it here as well.
-common --experimental_repo_remote_exec
-# Actually printing output on errors is... a useful default
-test --test_output=errors
-
-# TODO: Transition to the explicit init_py mechanism. See #2405
-# This is commented out while considering transition path but left as a
-# breadcrumb.
-# build --incompatible_default_to_explicit_init_py
-
-# TensorFlow always sets these in OSS which makes it impossible to build TF
-# without them...
-build --define open_source_build=true
-
-###############################################################################
-# Options for "generic_clang" builds: these options should generally apply to
-# either clang or gcc and are curated based on need.
-###############################################################################
-
-# C++14 standard version is required.
-build:generic_clang --cxxopt=-std=c++14 --host_cxxopt=-std=c++14
-
-# Default to adding back asserts in optimized builds.
-# This is a good compromise between runtime and debugability.
-build:generic_clang --copt=-UNDEBUG
-
-# Treat warnings in-workspace as errors.
-build:generic_clang --per_file_copt=-external/.*@-Werror
-# ...and silence them outside of the workspace.
-build:generic_clang --per_file_copt=external/.*@-w
-
-# LINT.IfChange(clang_diagnostics)
-# Set clang diagnostics. These largely match the set of warnings used within
-# Google. They have not been audited super carefully by the IREE team but are
-# generally thought to be a good set and consistency with those used internally
-# is very useful when importing. If you feel hat some of these should be
-# different, please raise an issue!
-
-build:generic_clang --copt=-Wall
-
-# Disable warnings we don't care about or that generally have a low signal/noise
-# ratio.
-build:generic_clang --copt=-Wno-ambiguous-member-template
-build:generic_clang --copt=-Wno-char-subscripts
-build:generic_clang --copt=-Wno-error=deprecated-declarations
-build:generic_clang --copt=-Wno-extern-c-compat # Matches upstream. Cannot impact due to extern C inclusion method.
-build:generic_clang --copt=-Wno-gnu-alignof-expression
-build:generic_clang --copt=-Wno-gnu-variable-sized-type-not-at-end
-build:generic_clang --copt=-Wno-ignored-optimization-argument
-build:generic_clang --copt=-Wno-invalid-offsetof # Technically UB but needed for intrusive ptrs
-build:generic_clang --copt=-Wno-invalid-source-encoding
-build:generic_clang --copt=-Wno-mismatched-tags
-build:generic_clang --copt=-Wno-pointer-sign
-build:generic_clang --copt=-Wno-reserved-user-defined-literal
-build:generic_clang --copt=-Wno-return-type-c-linkage
-build:generic_clang --copt=-Wno-self-assign-overloaded
-build:generic_clang --copt=-Wno-sign-compare
-build:generic_clang --copt=-Wno-signed-unsigned-wchar
-build:generic_clang --copt=-Wno-strict-overflow
-build:generic_clang --copt=-Wno-trigraphs
-build:generic_clang --copt=-Wno-unknown-pragmas
-build:generic_clang --copt=-Wno-unknown-warning-option
-build:generic_clang --copt=-Wno-unused-command-line-argument
-build:generic_clang --copt=-Wno-unused-const-variable
-build:generic_clang --copt=-Wno-unused-function
-build:generic_clang --copt=-Wno-unused-local-typedef
-build:generic_clang --copt=-Wno-unused-private-field
-build:generic_clang --copt=-Wno-user-defined-warnings
-build:generic_clang --copt=-Wno-macro-redefined # TODO(GH-2556): Re-enable (IREE and TF both define LOG)
-
-# Explicitly enable some additional warnings.
-# Some of these aren't on by default, or under -Wall, or are subsets of warnings
-# turned off above.
-build:generic_clang --copt=-Wctad-maybe-unsupported
-build:generic_clang --copt=-Wfloat-overflow-conversion
-build:generic_clang --copt=-Wfloat-zero-conversion
-build:generic_clang --copt=-Wfor-loop-analysis
-build:generic_clang --copt=-Wformat-security
-build:generic_clang --copt=-Wgnu-redeclared-enum
-build:generic_clang --copt=-Wimplicit-fallthrough
-build:generic_clang --copt=-Winfinite-recursion
-build:generic_clang --copt=-Wliteral-conversion
-build:generic_clang --copt=-Wnon-virtual-dtor
-build:generic_clang --copt=-Woverloaded-virtual
-build:generic_clang --copt=-Wself-assign
-build:generic_clang --copt=-Wstring-conversion
-build:generic_clang --copt=-Wtautological-overlap-compare
-build:generic_clang --copt=-Wthread-safety
-build:generic_clang --copt=-Wthread-safety-beta
-build:generic_clang --copt=-Wunused-comparison
-build:generic_clang --copt=-Wunused-variable
-build:generic_clang --copt=-Wvla
-# LINT.ThenChange(https://github.com/google/iree/tree/main/build_tools/cmake/iree_copts.cmake:clang_diagnostics)
-
-###############################################################################
-# Options for building with address sanitizer.
-# https://github.com/google/sanitizers/wiki/AddressSanitizer
-###############################################################################
-
-# Turn on asan. Some toolchains make use of the asan feature and we'll directly
-# set the appropriate opts.
-build:asan --features=asan
-build:asan --copt=-fsanitize=address
-build:asan --linkopt=-fsanitize=address
-
-# Don't strip debug info
-build:asan --strip=never
-# Ignore settings of `linkopts = ["-static"]` which can screw up the sanitizer.
-# We don't use this in IREE (that's what linkstatic is for), but it could show
-# up in dependencies.
-build:asan --force_ignore_dash_static
-# asan tests tend to take longer, so increase the timeouts
-build:asan --test_timeout=120,600,1800,-1
-# Make the outputs easy to find
-build:asan --cc_output_directory_tag=asan
-# Get better stack traces
-build:asan --copt=-fno-omit-frame-pointer
-# This macro define is used by absl
-build:asan --copt=-DADDRESS_SANITIZER
-
-###############################################################################
-# Architecture specific options
-###############################################################################
-
-# Enable some default cpu flags for x86 optimization.
-build:x86opt --copt=-mavx2
-
-###############################################################################
-# Configuration for building remotely using Remote Build Execution (RBE)
-# https://cloud.google.com/remote-build-execution/
-# Based on https://github.com/bazelbuild/bazel-toolchains/blob/master/bazelrc/bazel-1.0.0.bazelrc
-# Currently in development only usable by CI.
-###############################################################################
-
-# Options for connecting to the IREE GCP remote build project. These are
-# repeated separately in each config to avoid warnings about configs being
-# expanded more than once.
-
-# Enable authentication. This will pick up application default credentials by
-# default. You can use --google_credentials=some_file.json to use a service
-# account credential instead.
-build:rbe --google_default_credentials=true
-# Point to the remote instance constructed in the iree-oss project
-build:rbe --remote_instance_name=projects/iree-oss/instances/default_instance
-
-# Depending on how many machines are in the remote execution instance, setting
-# this higher can make builds faster by allowing more jobs to run in parallel.
-# Setting it too high can result in jobs that timeout, however, while waiting
-# for a remote machine to execute them.
-build:rbe --jobs=50
-
-# Flags related to specifying the platform, toolchain and java properties.
-# These flags must be adapted to work with toolchain containers other than
-# rbe-ubuntu16-04
-# References to "rbe_default" matches rbe_autoconfig(name="rbe_default") in
-# WORKSPACE
-build:rbe --host_javabase=@rbe_default//java:jdk
-build:rbe --javabase=@rbe_default//java:jdk
-build:rbe --host_java_toolchain=@bazel_tools//tools/jdk:toolchain_hostjdk8
-build:rbe --java_toolchain=@bazel_tools//tools/jdk:toolchain_hostjdk8
-build:rbe --crosstool_top=@rbe_default//cc:toolchain
-build:rbe --action_env=BAZEL_DO_NOT_DETECT_CPP_TOOLCHAIN=1
-# Platform flags:
-# The toolchain container used for execution is defined in the target indicated
-# by "extra_execution_platforms", "host_platform" and "platforms".
-# More about platforms: https://docs.bazel.build/versions/master/platforms.html
-build:rbe --extra_toolchains=@rbe_default//config:cc-toolchain
-build:rbe --extra_execution_platforms=@rbe_default//config:platform
-build:rbe --host_platform=@rbe_default//config:platform
-build:rbe --platforms=@rbe_default//config:platform
-
-build:rbe --define=EXECUTOR=remote
-
-# Enable remote execution so actions are performed on the remote systems.
-build:rbe --remote_executor=grpcs://remotebuildexecution.googleapis.com
-
-# Enforce stricter environment rules, which eliminates some non-hermetic
-# behavior and therefore improves both the remote cache hit rate and the
-# correctness and repeatability of the build.
-build:rbe --incompatible_strict_action_env=true
-
-# Set a higher timeout value, just in case.
-build:rbe --remote_timeout=3600
-
-# Local disk cache is incompatible with remote execution (for obvious reasons).
-build:rbe --disk_cache=""
-
-###############################################################################
-# Configuration for uploading build results to Result Store UI
-# https://cloud.google.com/remote-build-execution/docs/results-ui/getting-started-results-ui
-# Can be used either with or without --config=rbe.
-###############################################################################
-
-# Options for connecting to the IREE GCP remote build project. These are
-# repeated separately in each config to avoid warnings about configs being
-# expanded more than once.
-
-# Enable authentication. This will pick up application default credentials by
-# default. You can use --google_credentials=some_file.json to use a service
-# account credential instead.
-build:rs --google_default_credentials=true
-# Point to the remote instance constructed in the iree-oss project
-build:rs --remote_instance_name=projects/iree-oss/instances/default_instance
-
-build:rs --bes_backend="buildeventservice.googleapis.com"
-build:rs --bes_results_url="https://source.cloud.google.com/results/invocations/"
-build:rs --project_id=iree-oss
-
-###############################################################################
-# Windows specific flags for building with VC.
-###############################################################################
-
-build:windows --define=iree_is_msvc=true
-build:windows --copt=/wd4624 # destructor was implicitly defined as deleted
-build:windows --copt=/wd4244 # possible loss of data
-build:windows --copt=/wd4005 # macro redefinition
-build:windows --copt=/wd4267 # initializing: possible loss of data
-build:windows --copt=/wd4141 # inline used more than once
-build:windows --per_file_copt=mkl_dnn@/wd4551 # missing argument list
-build:windows --per_file_copt=mkl_dnn@/wd4068 # unknown pragma
-build:windows --per_file_copt=farmhash@/wd4319 # zero extending to T of greater size
-
-build:windows --linkopt=/IGNORE:4217 # mismatch import/export declspec
-
-# Enables unix-style runfiles link trees (requires symlink permission).
-# See: https://blogs.windows.com/windowsdeveloper/2016/12/02/symlinks-windows-10/
-# Generally: Enable Developer Mode in the Developer Settings page of the
-# system settings.
-build:windows --experimental_enable_runfiles
-# Flags to make tensorflow build.
-# Some of these are also of general use and fine to enable globally for windows.
-build:windows --copt=/arch:AVX
-# Host and target are the same in windows so don't waste time building both.
-build:windows --distinct_host_configuration=false
-# Avoids incompatible versions of winsock and other badness.
-build:windows --copt=/DWIN32_LEAN_AND_MEAN --host_copt=/DWIN32_LEAN_AND_MEAN
-# That is one way to have less warnings :(
-build:windows --per_file_copt=tensorflow@-w
-build:windows --per_file_copt=protobuf@-w
-# Why are min/max macros? No one knows.
-build:windows --copt=/DNOMINMAX --host_copt=/DNOMINMAX
-# Yay for security warnings. Boo for non-standard.
-build:windows --copt=/D_CRT_SECURE_NO_WARNINGS --host_copt=/D_CRT_SECURE_NO_WARNINGS
-# TensorFlow requires the "monolithic" build mode for now on Windows.
-build:windows --define framework_shared_object=false
-# Necessary for M_* math constants.
-build:windows --copt=/D_USE_MATH_DEFINES --host_copt=/D_USE_MATH_DEFINES
-
-# Workaround WinGDI.h defining `ERROR`, which conflicts with logging macros.
-# Note that IREE and TensorFlow both `#undef ERROR` and define their own
-# separate logging constants with the same name, but IREE needs the Windows
-# "graphics device interface" (GDI) for certain GUI sample projects.
-build:windows --per_file_copt=tensorflow@-DNOGDI
-
-# Disables TensorFlow eigen bloat and reduces compile times.
-build:windows --define=override_eigen_strong_inline=true
-
-# Another TensorFlow flag from their config script.
-build:windows --define with_default_optimizations=true
-
-###############################################################################
+# Import the main bazelrc config. This is in a separate file so that it's
+# possible to turn off all user bazelrc options by specifying
+# `--nosystem_rc --nohome_rc --noworkspace_rc --bazelrc=build_tools/bazel/iree.bazelrc`
+try-import %workspace%/build_tools/bazel/iree.bazelrc
# Run the configure_bazel.py script to generate.
try-import %workspace%/configured.bazelrc
diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml
index d8eeecf..45cf1bd 100644
--- a/.github/workflows/lint.yml
+++ b/.github/workflows/lint.yml
@@ -66,14 +66,6 @@
with:
strict: true
- pr-title-length:
- runs-on: ubuntu-18.04
- steps:
- - uses: deepakputhraya/action-pr-title@v1.0.0
- with:
- min_length: 5
- max_length: 80
-
buildifier:
runs-on: ubuntu-18.04
steps:
diff --git a/build_tools/bazel/build_bindings.sh b/build_tools/bazel/build_bindings.sh
index e79cade..b4a417e 100755
--- a/build_tools/bazel/build_bindings.sh
+++ b/build_tools/bazel/build_bindings.sh
@@ -74,12 +74,22 @@
# `bazel test //...` because the latter excludes targets tagged "manual". The
# "manual" tag allows targets to be excluded from human wildcard builds, but we
# want them built by CI unless they are excluded with "nokokoro".
-bazel query //bindings/... | \
- xargs bazel test ${test_env_args[@]} \
- --config=generic_clang \
- --build_tag_filters="${BUILD_TAG_FILTERS?}" \
- --test_tag_filters="${TEST_TAG_FILTERS?}" \
- --keep_going \
- --test_output=errors \
- --config=rs \
- --config=rbe
+# Explicitly list bazelrc so that builds are reproducible and get cache hits
+# when this script is invoked locally.
+bazel \
+ --nosystem_rc --nohome_rc --noworkspace_rc \
+ --bazelrc=build_tools/bazel/iree.bazelrc \
+ query \
+ //bindings/... | \
+ xargs bazel \
+ --nosystem_rc --nohome_rc --noworkspace_rc \
+ --bazelrc=build_tools/bazel/iree.bazelrc \
+ test \
+ ${test_env_args[@]} \
+ --config=generic_clang \
+ --build_tag_filters="${BUILD_TAG_FILTERS?}" \
+ --test_tag_filters="${TEST_TAG_FILTERS?}" \
+ --keep_going \
+ --test_output=errors \
+ --config=rs \
+ --config=rbe
diff --git a/build_tools/bazel/build_core.sh b/build_tools/bazel/build_core.sh
index 307d326..89d94e2 100755
--- a/build_tools/bazel/build_core.sh
+++ b/build_tools/bazel/build_core.sh
@@ -72,12 +72,22 @@
# `bazel test //...` because the latter excludes targets tagged "manual". The
# "manual" tag allows targets to be excluded from human wildcard builds, but we
# want them built by CI unless they are excluded with "nokokoro".
-bazel query //iree/... + //build_tools/... | \
- xargs bazel test ${test_env_args[@]} \
- --config=generic_clang \
- --build_tag_filters="${BUILD_TAG_FILTERS?}" \
- --test_tag_filters="${TEST_TAG_FILTERS?}" \
- --keep_going \
- --test_output=errors \
- --config=rs \
- --config=rbe
+# Explicitly list bazelrc so that builds are reproducible and get cache hits
+# when this script is invoked locally.
+bazel \
+ --nosystem_rc --nohome_rc --noworkspace_rc \
+ --bazelrc=build_tools/bazel/iree.bazelrc \
+ query \
+ //iree/... + //build_tools/... | \
+ xargs bazel \
+ --nosystem_rc --nohome_rc --noworkspace_rc \
+ --bazelrc=build_tools/bazel/iree.bazelrc \
+ test \
+ ${test_env_args[@]} \
+ --config=generic_clang \
+ --build_tag_filters="${BUILD_TAG_FILTERS?}" \
+ --test_tag_filters="${TEST_TAG_FILTERS?}" \
+ --keep_going \
+ --test_output=errors \
+ --config=rs \
+ --config=rbe
diff --git a/build_tools/bazel/build_tensorflow.sh b/build_tools/bazel/build_tensorflow.sh
index bfabd6d..07b0eb8 100755
--- a/build_tools/bazel/build_tensorflow.sh
+++ b/build_tools/bazel/build_tensorflow.sh
@@ -72,13 +72,23 @@
# `bazel test //...` because the latter excludes targets tagged "manual". The
# "manual" tag allows targets to be excluded from human wildcard builds, but we
# want them built by CI unless they are excluded with "nokokoro".
-bazel query //integrations/... + //colab/... + //packaging/... | \
- xargs bazel test ${test_env_args[@]} \
- --config=generic_clang \
- --build_tag_filters="${BUILD_TAG_FILTERS?}" \
- --test_tag_filters="${TEST_TAG_FILTERS?}" \
- --test_output=errors \
- --keep_going
- # TODO: Enable result store once the Kokoro VMs used for this test have the
- # appropriate auth.
- # --config=rs
+# Explicitly list bazelrc so that builds are reproducible and get cache hits
+# when this script is invoked locally.
+bazel \
+ --nosystem_rc --nohome_rc --noworkspace_rc \
+ --bazelrc=build_tools/bazel/iree.bazelrc \
+ query \
+ //integrations/... + //colab/... + //packaging/... | \
+ xargs bazel \
+ --nosystem_rc --nohome_rc --noworkspace_rc \
+ --bazelrc=build_tools/bazel/iree.bazelrc \
+ test \
+ ${test_env_args[@]} \
+ --config=generic_clang \
+ --build_tag_filters="${BUILD_TAG_FILTERS?}" \
+ --test_tag_filters="${TEST_TAG_FILTERS?}" \
+ --test_output=errors \
+ --keep_going
+ # TODO: Enable result store once the Kokoro VMs used for this test have the
+ # appropriate auth.
+ # --config=rs
diff --git a/build_tools/bazel/iree.bazelrc b/build_tools/bazel/iree.bazelrc
new file mode 100644
index 0000000..dba02ed
--- /dev/null
+++ b/build_tools/bazel/iree.bazelrc
@@ -0,0 +1,284 @@
+# Copyright 2019 Google LLC
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# https://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+###############################################################################
+# Common flags that apply to all configurations.
+# Use sparingly for things common to all compilers and platforms.
+###############################################################################
+# Prevent invalid caching if input files are modified during a build.
+build --experimental_guard_against_concurrent_changes
+# Default to optimized builds
+# Override via: "-c dbg" or --compilation_mode=dbg
+build --compilation_mode=opt
+# Used in TensorFlow, so we have to enable it here as well.
+common --experimental_repo_remote_exec
+# Actually printing output on errors is... a useful default
+test --test_output=errors
+
+# TODO: Transition to the explicit init_py mechanism. See #2405
+# This is commented out while considering transition path but left as a
+# breadcrumb.
+# build --incompatible_default_to_explicit_init_py
+
+# TensorFlow always sets these in OSS which makes it impossible to build TF
+# without them...
+build --define open_source_build=true
+
+###############################################################################
+# Options for "generic_clang" builds: these options should generally apply to
+# either clang or gcc and are curated based on need.
+###############################################################################
+
+# C++14 standard version is required.
+build:generic_clang --cxxopt=-std=c++14 --host_cxxopt=-std=c++14
+
+# Default to adding back asserts in optimized builds.
+# This is a good compromise between runtime and debugability.
+build:generic_clang --copt=-UNDEBUG
+
+# Treat warnings in-workspace as errors.
+build:generic_clang --per_file_copt=-external/.*@-Werror
+# ...and silence them outside of the workspace.
+build:generic_clang --per_file_copt=external/.*@-w
+
+# LINT.IfChange(clang_diagnostics)
+# Set clang diagnostics. These largely match the set of warnings used within
+# Google. They have not been audited super carefully by the IREE team but are
+# generally thought to be a good set and consistency with those used internally
+# is very useful when importing. If you feel hat some of these should be
+# different, please raise an issue!
+
+build:generic_clang --copt=-Wall
+
+# Disable warnings we don't care about or that generally have a low signal/noise
+# ratio.
+build:generic_clang --copt=-Wno-ambiguous-member-template
+build:generic_clang --copt=-Wno-char-subscripts
+build:generic_clang --copt=-Wno-error=deprecated-declarations
+build:generic_clang --copt=-Wno-extern-c-compat # Matches upstream. Cannot impact due to extern C inclusion method.
+build:generic_clang --copt=-Wno-gnu-alignof-expression
+build:generic_clang --copt=-Wno-gnu-variable-sized-type-not-at-end
+build:generic_clang --copt=-Wno-ignored-optimization-argument
+build:generic_clang --copt=-Wno-invalid-offsetof # Technically UB but needed for intrusive ptrs
+build:generic_clang --copt=-Wno-invalid-source-encoding
+build:generic_clang --copt=-Wno-mismatched-tags
+build:generic_clang --copt=-Wno-pointer-sign
+build:generic_clang --copt=-Wno-reserved-user-defined-literal
+build:generic_clang --copt=-Wno-return-type-c-linkage
+build:generic_clang --copt=-Wno-self-assign-overloaded
+build:generic_clang --copt=-Wno-sign-compare
+build:generic_clang --copt=-Wno-signed-unsigned-wchar
+build:generic_clang --copt=-Wno-strict-overflow
+build:generic_clang --copt=-Wno-trigraphs
+build:generic_clang --copt=-Wno-unknown-pragmas
+build:generic_clang --copt=-Wno-unknown-warning-option
+build:generic_clang --copt=-Wno-unused-command-line-argument
+build:generic_clang --copt=-Wno-unused-const-variable
+build:generic_clang --copt=-Wno-unused-function
+build:generic_clang --copt=-Wno-unused-local-typedef
+build:generic_clang --copt=-Wno-unused-private-field
+build:generic_clang --copt=-Wno-user-defined-warnings
+build:generic_clang --copt=-Wno-macro-redefined # TODO(GH-2556): Re-enable (IREE and TF both define LOG)
+
+# Explicitly enable some additional warnings.
+# Some of these aren't on by default, or under -Wall, or are subsets of warnings
+# turned off above.
+build:generic_clang --copt=-Wctad-maybe-unsupported
+build:generic_clang --copt=-Wfloat-overflow-conversion
+build:generic_clang --copt=-Wfloat-zero-conversion
+build:generic_clang --copt=-Wfor-loop-analysis
+build:generic_clang --copt=-Wformat-security
+build:generic_clang --copt=-Wgnu-redeclared-enum
+build:generic_clang --copt=-Wimplicit-fallthrough
+build:generic_clang --copt=-Winfinite-recursion
+build:generic_clang --copt=-Wliteral-conversion
+build:generic_clang --copt=-Wnon-virtual-dtor
+build:generic_clang --copt=-Woverloaded-virtual
+build:generic_clang --copt=-Wself-assign
+build:generic_clang --copt=-Wstring-conversion
+build:generic_clang --copt=-Wtautological-overlap-compare
+build:generic_clang --copt=-Wthread-safety
+build:generic_clang --copt=-Wthread-safety-beta
+build:generic_clang --copt=-Wunused-comparison
+build:generic_clang --copt=-Wunused-variable
+build:generic_clang --copt=-Wvla
+# LINT.ThenChange(https://github.com/google/iree/tree/main/build_tools/cmake/iree_copts.cmake:clang_diagnostics)
+
+###############################################################################
+# Options for building with address sanitizer.
+# https://github.com/google/sanitizers/wiki/AddressSanitizer
+###############################################################################
+
+# Turn on asan. Some toolchains make use of the asan feature and we'll directly
+# set the appropriate opts.
+build:asan --features=asan
+build:asan --copt=-fsanitize=address
+build:asan --linkopt=-fsanitize=address
+
+# Don't strip debug info
+build:asan --strip=never
+# Ignore settings of `linkopts = ["-static"]` which can screw up the sanitizer.
+# We don't use this in IREE (that's what linkstatic is for), but it could show
+# up in dependencies.
+build:asan --force_ignore_dash_static
+# asan tests tend to take longer, so increase the timeouts
+build:asan --test_timeout=120,600,1800,-1
+# Make the outputs easy to find
+build:asan --cc_output_directory_tag=asan
+# Get better stack traces
+build:asan --copt=-fno-omit-frame-pointer
+# This macro define is used by absl
+build:asan --copt=-DADDRESS_SANITIZER
+
+###############################################################################
+# Architecture specific options
+###############################################################################
+
+# Enable some default cpu flags for x86 optimization.
+build:x86opt --copt=-mavx2
+
+###############################################################################
+# Configuration for building remotely using Remote Build Execution (RBE)
+# https://cloud.google.com/remote-build-execution/
+# Based on https://github.com/bazelbuild/bazel-toolchains/blob/master/bazelrc/bazel-1.0.0.bazelrc
+# Currently in development only usable by CI.
+###############################################################################
+
+# Options for connecting to the IREE GCP remote build project. These are
+# repeated separately in each config to avoid warnings about configs being
+# expanded more than once.
+
+# Enable authentication. This will pick up application default credentials by
+# default. You can use --google_credentials=some_file.json to use a service
+# account credential instead.
+build:rbe --google_default_credentials=true
+# Point to the remote instance constructed in the iree-oss project
+build:rbe --remote_instance_name=projects/iree-oss/instances/default_instance
+
+# Depending on how many machines are in the remote execution instance, setting
+# this higher can make builds faster by allowing more jobs to run in parallel.
+# Setting it too high can result in jobs that timeout, however, while waiting
+# for a remote machine to execute them.
+build:rbe --jobs=50
+
+# Flags related to specifying the platform, toolchain and java properties.
+# These flags must be adapted to work with toolchain containers other than
+# rbe-ubuntu16-04
+# References to "rbe_default" matches rbe_autoconfig(name="rbe_default") in
+# WORKSPACE
+build:rbe --host_javabase=@rbe_default//java:jdk
+build:rbe --javabase=@rbe_default//java:jdk
+build:rbe --host_java_toolchain=@bazel_tools//tools/jdk:toolchain_hostjdk8
+build:rbe --java_toolchain=@bazel_tools//tools/jdk:toolchain_hostjdk8
+build:rbe --crosstool_top=@rbe_default//cc:toolchain
+build:rbe --action_env=BAZEL_DO_NOT_DETECT_CPP_TOOLCHAIN=1
+# Platform flags:
+# The toolchain container used for execution is defined in the target indicated
+# by "extra_execution_platforms", "host_platform" and "platforms".
+# More about platforms: https://docs.bazel.build/versions/master/platforms.html
+build:rbe --extra_toolchains=@rbe_default//config:cc-toolchain
+build:rbe --extra_execution_platforms=@rbe_default//config:platform
+build:rbe --host_platform=@rbe_default//config:platform
+build:rbe --platforms=@rbe_default//config:platform
+
+build:rbe --define=EXECUTOR=remote
+
+# Enable remote execution so actions are performed on the remote systems.
+build:rbe --remote_executor=grpcs://remotebuildexecution.googleapis.com
+
+# Enforce stricter environment rules, which eliminates some non-hermetic
+# behavior and therefore improves both the remote cache hit rate and the
+# correctness and repeatability of the build.
+build:rbe --incompatible_strict_action_env=true
+
+# Set a higher timeout value, just in case.
+build:rbe --remote_timeout=3600
+
+# Local disk cache is incompatible with remote execution (for obvious reasons).
+build:rbe --disk_cache=""
+
+###############################################################################
+# Configuration for uploading build results to Result Store UI
+# https://cloud.google.com/remote-build-execution/docs/results-ui/getting-started-results-ui
+# Can be used either with or without --config=rbe.
+###############################################################################
+
+# Options for connecting to the IREE GCP remote build project. These are
+# repeated separately in each config to avoid warnings about configs being
+# expanded more than once.
+
+# Enable authentication. This will pick up application default credentials by
+# default. You can use --google_credentials=some_file.json to use a service
+# account credential instead.
+build:rs --google_default_credentials=true
+# Point to the remote instance constructed in the iree-oss project
+build:rs --remote_instance_name=projects/iree-oss/instances/default_instance
+
+build:rs --bes_backend="buildeventservice.googleapis.com"
+build:rs --bes_results_url="https://source.cloud.google.com/results/invocations/"
+build:rs --project_id=iree-oss
+
+###############################################################################
+# Windows specific flags for building with VC.
+###############################################################################
+
+build:windows --define=iree_is_msvc=true
+build:windows --copt=/wd4624 # destructor was implicitly defined as deleted
+build:windows --copt=/wd4244 # possible loss of data
+build:windows --copt=/wd4005 # macro redefinition
+build:windows --copt=/wd4267 # initializing: possible loss of data
+build:windows --copt=/wd4141 # inline used more than once
+build:windows --per_file_copt=mkl_dnn@/wd4551 # missing argument list
+build:windows --per_file_copt=mkl_dnn@/wd4068 # unknown pragma
+build:windows --per_file_copt=farmhash@/wd4319 # zero extending to T of greater size
+
+build:windows --linkopt=/IGNORE:4217 # mismatch import/export declspec
+
+# Enables unix-style runfiles link trees (requires symlink permission).
+# See: https://blogs.windows.com/windowsdeveloper/2016/12/02/symlinks-windows-10/
+# Generally: Enable Developer Mode in the Developer Settings page of the
+# system settings.
+build:windows --experimental_enable_runfiles
+# Flags to make tensorflow build.
+# Some of these are also of general use and fine to enable globally for windows.
+build:windows --copt=/arch:AVX
+# Host and target are the same in windows so don't waste time building both.
+build:windows --distinct_host_configuration=false
+# Avoids incompatible versions of winsock and other badness.
+build:windows --copt=/DWIN32_LEAN_AND_MEAN --host_copt=/DWIN32_LEAN_AND_MEAN
+# That is one way to have less warnings :(
+build:windows --per_file_copt=tensorflow@-w
+build:windows --per_file_copt=protobuf@-w
+# Why are min/max macros? No one knows.
+build:windows --copt=/DNOMINMAX --host_copt=/DNOMINMAX
+# Yay for security warnings. Boo for non-standard.
+build:windows --copt=/D_CRT_SECURE_NO_WARNINGS --host_copt=/D_CRT_SECURE_NO_WARNINGS
+# TensorFlow requires the "monolithic" build mode for now on Windows.
+build:windows --define framework_shared_object=false
+# Necessary for M_* math constants.
+build:windows --copt=/D_USE_MATH_DEFINES --host_copt=/D_USE_MATH_DEFINES
+
+# Workaround WinGDI.h defining `ERROR`, which conflicts with logging macros.
+# Note that IREE and TensorFlow both `#undef ERROR` and define their own
+# separate logging constants with the same name, but IREE needs the Windows
+# "graphics device interface" (GDI) for certain GUI sample projects.
+build:windows --per_file_copt=tensorflow@-DNOGDI
+
+# Disables TensorFlow eigen bloat and reduces compile times.
+build:windows --define=override_eigen_strong_inline=true
+
+# Another TensorFlow flag from their config script.
+build:windows --define with_default_optimizations=true
+
+###############################################################################
diff --git a/iree/tools/BUILD b/iree/tools/BUILD
index 6f3cd56..0f59359 100644
--- a/iree/tools/BUILD
+++ b/iree/tools/BUILD
@@ -344,6 +344,7 @@
hdrs = ["vm_util.h"],
deps = [
"//iree/base:api_util",
+ "//iree/base:file_io",
"//iree/base:signature_mangle",
"//iree/base:status",
"//iree/hal:api",
diff --git a/iree/tools/CMakeLists.txt b/iree/tools/CMakeLists.txt
index 9d57aff..a946695 100644
--- a/iree/tools/CMakeLists.txt
+++ b/iree/tools/CMakeLists.txt
@@ -362,6 +362,7 @@
absl::span
absl::strings
iree::base::api_util
+ iree::base::file_io
iree::base::signature_mangle
iree::base::status
iree::hal::api
diff --git a/iree/tools/benchmark_module_main.cc b/iree/tools/benchmark_module_main.cc
index 616c78a..6f11e4a 100644
--- a/iree/tools/benchmark_module_main.cc
+++ b/iree/tools/benchmark_module_main.cc
@@ -49,6 +49,10 @@
"values:\n"
"2x2xi32=[[1 2][3 4]], 1x2xf32=[[1 2]]");
+ABSL_FLAG(std::string, inputs_file, "",
+ "Provides a file for input shapes and optional values (see "
+ "ParseToVariantListFromFile in vm_util.h for details)");
+
namespace iree {
namespace {
@@ -103,10 +107,20 @@
RETURN_IF_ERROR(ValidateFunctionAbi(function));
ASSIGN_OR_RETURN(auto input_descs, ParseInputSignature(function));
- ASSIGN_OR_RETURN(
- iree_vm_variant_list_t * inputs,
- ParseToVariantList(input_descs, iree_hal_device_allocator(device),
- absl::GetFlag(FLAGS_inputs)));
+ iree_vm_variant_list_t* inputs;
+ if (!absl::GetFlag(FLAGS_inputs_file).empty()) {
+ if (!absl::GetFlag(FLAGS_inputs).empty()) {
+ return InvalidArgumentErrorBuilder(IREE_LOC)
+ << "Expected only one of inputs and inputs_flag to be set";
+ }
+ ASSIGN_OR_RETURN(inputs, ParseToVariantListFromFile(
+ input_descs, iree_hal_device_allocator(device),
+ absl::GetFlag(FLAGS_inputs_file)));
+ } else {
+ ASSIGN_OR_RETURN(inputs, ParseToVariantList(
+ input_descs, iree_hal_device_allocator(device),
+ absl::GetFlag(FLAGS_inputs)));
+ }
ASSIGN_OR_RETURN(auto output_descs, ParseOutputSignature(function));
diff --git a/iree/tools/run_mlir_main.cc b/iree/tools/run_mlir_main.cc
index 9f26284..ed09735 100644
--- a/iree/tools/run_mlir_main.cc
+++ b/iree/tools/run_mlir_main.cc
@@ -125,7 +125,7 @@
static llvm::cl::opt<std::string> input_values_file_flag{
"input-value-file",
llvm::cl::desc("Provides a file for input shapes and optional values (see "
- "run_module_main.cc for details)"),
+ "ParseToVariantListFromFile in vm_util.h for details)"),
llvm::cl::init(""),
};
@@ -265,23 +265,6 @@
return binary_contents;
}
-// Returns a splitted input values from `filename` using newline as separater.
-StatusOr<std::vector<std::string>> GetInputValues(const std::string& filename) {
- std::string error_message;
- auto file = mlir::openInputFile(filename, &error_message);
- if (!file) {
- return NotFoundErrorBuilder(IREE_LOC) << "Unable to open input file '"
- << filename << "': " << error_message;
- }
- llvm::SmallVector<llvm::StringRef, 8> source_buffers;
- file->getBuffer().split(source_buffers, /*Separator=*/"\n", /*MaxSplit=*/-1,
- /*KeepEmpty=*/false);
- std::vector<std::string> res;
- res.reserve(source_buffers.size());
- for (auto s : source_buffers) res.emplace_back(s);
- return res;
-}
-
// Evaluates a single function in its own fiber, printing the results to stdout.
Status EvaluateFunction(iree_vm_context_t* context,
iree_hal_allocator_t* allocator,
@@ -296,11 +279,11 @@
if (!input_values_flag.empty()) {
return InvalidArgumentErrorBuilder(IREE_LOC)
<< "Expected only one of input_values_file_flag and "
- "input_values_flag is set";
+ "input_values_flag to be set";
}
- ASSIGN_OR_RETURN(auto input_values, GetInputValues(input_values_file_flag));
ASSIGN_OR_RETURN(input_list,
- ParseToVariantList(input_descs, allocator, input_values));
+ ParseToVariantListFromFile(input_descs, allocator,
+ input_values_file_flag));
} else {
auto input_values_list = absl::MakeConstSpan(
input_values_flag.empty() ? nullptr : &input_values_flag.front(),
diff --git a/iree/tools/run_module_main.cc b/iree/tools/run_module_main.cc
index 2b1d6ed..45e2326 100644
--- a/iree/tools/run_module_main.cc
+++ b/iree/tools/run_module_main.cc
@@ -48,6 +48,10 @@
"values:\n"
"2x2xi32=[[1 2][3 4]], 1x2xf32=[[1 2]]");
+ABSL_FLAG(std::string, inputs_file, "",
+ "Provides a file for input shapes and optional values (see "
+ "ParseToVariantListFromFile in vm_util.h for details)");
+
namespace iree {
namespace {
@@ -105,10 +109,20 @@
RETURN_IF_ERROR(ValidateFunctionAbi(function));
ASSIGN_OR_RETURN(auto input_descs, ParseInputSignature(function));
- ASSIGN_OR_RETURN(
- iree_vm_variant_list_t * inputs,
- ParseToVariantList(input_descs, iree_hal_device_allocator(device),
- absl::GetFlag(FLAGS_inputs)));
+ iree_vm_variant_list_t* inputs;
+ if (!absl::GetFlag(FLAGS_inputs_file).empty()) {
+ if (!absl::GetFlag(FLAGS_inputs).empty()) {
+ return InvalidArgumentErrorBuilder(IREE_LOC)
+ << "Expected only one of inputs and inputs_flag to be set";
+ }
+ ASSIGN_OR_RETURN(inputs, ParseToVariantListFromFile(
+ input_descs, iree_hal_device_allocator(device),
+ absl::GetFlag(FLAGS_inputs_file)));
+ } else {
+ ASSIGN_OR_RETURN(inputs, ParseToVariantList(
+ input_descs, iree_hal_device_allocator(device),
+ absl::GetFlag(FLAGS_inputs)));
+ }
ASSIGN_OR_RETURN(auto output_descs, ParseOutputSignature(function));
iree_vm_variant_list_t* outputs = nullptr;
diff --git a/iree/tools/vm_util.cc b/iree/tools/vm_util.cc
index af9edfa..e7c6e7a 100644
--- a/iree/tools/vm_util.cc
+++ b/iree/tools/vm_util.cc
@@ -17,10 +17,12 @@
#include <ostream>
#include "absl/strings/numbers.h"
+#include "absl/strings/str_split.h"
#include "absl/strings/string_view.h"
#include "absl/strings/strip.h"
#include "absl/types/span.h"
#include "iree/base/api_util.h"
+#include "iree/base/file_io.h"
#include "iree/base/signature_mangle.h"
#include "iree/base/status.h"
#include "iree/hal/api.h"
@@ -80,6 +82,15 @@
return output_descs;
}
+StatusOr<iree_vm_variant_list_t*> ParseToVariantListFromFile(
+ absl::Span<const RawSignatureParser::Description> descs,
+ iree_hal_allocator_t* allocator, const std::string& filename) {
+ ASSIGN_OR_RETURN(auto s, file_io::GetFileContents(filename));
+ std::vector<std::string> input_strings =
+ absl::StrSplit(s, '\n', absl::SkipEmpty());
+ return ParseToVariantList(descs, allocator, input_strings);
+}
+
StatusOr<iree_vm_variant_list_t*> ParseToVariantList(
absl::Span<const RawSignatureParser::Description> descs,
iree_hal_allocator_t* allocator,
diff --git a/iree/tools/vm_util.h b/iree/tools/vm_util.h
index 1a793c3..c3f1c9c 100644
--- a/iree/tools/vm_util.h
+++ b/iree/tools/vm_util.h
@@ -40,6 +40,13 @@
StatusOr<std::vector<RawSignatureParser::Description>> ParseOutputSignature(
const iree_vm_function_t& function);
+// Parses the content in |filename| into a variant list of VM scalars and
+// buffers. See ParseToVariantList for the format of scalars and buffers. The
+// inputs are expected to be newline-separated.
+StatusOr<iree_vm_variant_list_t*> ParseToVariantListFromFile(
+ absl::Span<const RawSignatureParser::Description> descs,
+ iree_hal_allocator_t* allocator, const std::string& filename);
+
// Parses |input_strings| into a variant list of VM scalars and buffers.
// Scalars should be in the format:
// type=value