[llvm] 6c76d01 - [mlgo][aot] requrie the model is autogenerated for test determinism
Mircea Trofin via llvm-commits
llvm-commits at lists.llvm.org
Wed Oct 13 14:30:07 PDT 2021
Author: Mircea Trofin
Date: 2021-10-13T14:02:41-07:00
New Revision: 6c76d0101193aa4eb891a6954ff047eda2f9cf71
URL: https://github.com/llvm/llvm-project/commit/6c76d0101193aa4eb891a6954ff047eda2f9cf71
DIFF: https://github.com/llvm/llvm-project/commit/6c76d0101193aa4eb891a6954ff047eda2f9cf71.diff
LOG: [mlgo][aot] requrie the model is autogenerated for test determinism
The tests that exercise the 'release' mode, where the model is AOT-ed,
check the output has certain properties, to validate that, indeed, a
different policy from the default one was exercised. For determinism, we
can't reliably check that output for an arbitrary learned policy, since
it could be that policy happens to mimic the default one in that
particular case.
This patch adds a requirement that those tests run only when the model
is autogenerated (e.g. on build bots).
Differential Revision: https://reviews.llvm.org/D111747
Added:
Modified:
llvm/CMakeLists.txt
llvm/lib/Analysis/CMakeLists.txt
llvm/test/CMakeLists.txt
llvm/test/Transforms/Inline/ML/bounds-checks.ll
llvm/test/Transforms/Inline/ML/ml-test-release-mode.ll
llvm/test/lit.cfg.py
llvm/test/lit.site.cfg.py.in
Removed:
################################################################################
diff --git a/llvm/CMakeLists.txt b/llvm/CMakeLists.txt
index f10f8d66d0b88..9e674c9bcf1cc 100644
--- a/llvm/CMakeLists.txt
+++ b/llvm/CMakeLists.txt
@@ -850,6 +850,13 @@ if (NOT TENSORFLOW_AOT_PATH STREQUAL "")
install(TARGETS tf_xla_runtime EXPORT LLVMExports
ARCHIVE DESTINATION lib${LLVM_LIBDIR_SUFFIX} COMPONENT tf_xla_runtime)
set_property(GLOBAL APPEND PROPERTY LLVM_EXPORTS tf_xla_runtime)
+ # Once we add more modules, we should handle this more automatically.
+ if (NOT DEFINED LLVM_INLINER_MODEL_PATH
+ OR "${LLVM_INLINER_MODEL_PATH}" STREQUAL ""
+ OR "${LLVM_INLINER_MODEL_PATH}" STREQUAL "autogenerate")
+ set(LLVM_INLINER_MODEL_PATH "autogenerate")
+ set(LLVM_INLINER_MODEL_AUTOGENERATED 1)
+ endif()
endif()
# Configure the three LLVM configuration header files.
diff --git a/llvm/lib/Analysis/CMakeLists.txt b/llvm/lib/Analysis/CMakeLists.txt
index f3e5b81645982..9da07cb1c4850 100644
--- a/llvm/lib/Analysis/CMakeLists.txt
+++ b/llvm/lib/Analysis/CMakeLists.txt
@@ -8,12 +8,6 @@ if (DEFINED LLVM_HAVE_TF_AOT OR DEFINED LLVM_HAVE_TF_API)
set(LLVM_INLINER_MODEL_CURRENT_URL "https://github.com/google/ml-compiler-opt/releases/download/inlining-Oz-v1.1/inlining-Oz-99f0063-v1.1.tar.gz")
if (DEFINED LLVM_HAVE_TF_AOT)
- # If the path is empty, autogenerate the model
- if (NOT DEFINED LLVM_INLINER_MODEL_PATH OR "${LLVM_INLINER_MODEL_PATH}" STREQUAL "")
- set(LLVM_INLINER_MODEL_PATH "autogenerate")
- message(WARNING "LLVM_INLINER_MODEL_PATH was not set: autogenerating a model to finish the build.")
- endif()
-
tf_find_and_compile(
${LLVM_INLINER_MODEL_PATH}
${LLVM_INLINER_MODEL_CURRENT_URL}
diff --git a/llvm/test/CMakeLists.txt b/llvm/test/CMakeLists.txt
index 607076b78208a..ff2505ee2987e 100644
--- a/llvm/test/CMakeLists.txt
+++ b/llvm/test/CMakeLists.txt
@@ -17,6 +17,7 @@ llvm_canonicalize_cmake_booleans(
LLVM_BYE_LINK_INTO_TOOLS
LLVM_HAVE_TF_AOT
LLVM_HAVE_TF_API
+ LLVM_INLINER_MODEL_AUTOGENERATED
LLVM_ENABLE_EXPENSIVE_CHECKS
)
diff --git a/llvm/test/Transforms/Inline/ML/bounds-checks.ll b/llvm/test/Transforms/Inline/ML/bounds-checks.ll
index b98e23acb4270..a462c6b4722fb 100644
--- a/llvm/test/Transforms/Inline/ML/bounds-checks.ll
+++ b/llvm/test/Transforms/Inline/ML/bounds-checks.ll
@@ -1,8 +1,9 @@
; Test behavior when inlining policy grows size out of control.
; In all cases, the end result is the same: mandatory inlinings must happen.
-; However, when we discover we 'trip' over the artificially-low size increase
+; However, when we discover we 'trip' over the artificially-low size increase
; factor, we don't inline anymore.
; REQUIRES: have_tf_aot
+; REQUIRES: llvm_inliner_model_autogenerated
; RUN: opt -passes=scc-oz-module-inliner -enable-ml-inliner=release -ml-advisor-size-increase-threshold=10.0 -S < %s 2>&1 | FileCheck %s --check-prefix=CHECK --check-prefix=NOBOUNDS
; RUN: opt -passes=scc-oz-module-inliner -enable-ml-inliner=release -ml-advisor-size-increase-threshold=1.0 -S < %s 2>&1 | FileCheck %s --check-prefix=CHECK --check-prefix=BOUNDS
@@ -38,4 +39,4 @@ attributes #0 = { alwaysinline }
; @some-function isn't mandatory, and when we set the increase threshold too low,
; it won't be inlined.
; NOBOUNDS-NOT: @some_function
-; BOUNDS: call i64 @some_function
\ No newline at end of file
+; BOUNDS: call i64 @some_function
diff --git a/llvm/test/Transforms/Inline/ML/ml-test-release-mode.ll b/llvm/test/Transforms/Inline/ML/ml-test-release-mode.ll
index 8e19659bf4eb2..7b0a253b0509b 100644
--- a/llvm/test/Transforms/Inline/ML/ml-test-release-mode.ll
+++ b/llvm/test/Transforms/Inline/ML/ml-test-release-mode.ll
@@ -6,5 +6,6 @@
; for the 'development' mode.
;
; REQUIRES: have_tf_aot
+; REQUIRES: llvm_inliner_model_autogenerated
; RUN: opt -passes=scc-oz-module-inliner -enable-ml-inliner=release -S < %S/Inputs/test-module.ll 2>&1 | FileCheck %S/Inputs/test-module.ll --check-prefix=CHECK
; RUN: opt -passes=scc-oz-module-inliner -enable-ml-inliner=default -S < %S/Inputs/test-module.ll 2>&1 | FileCheck %S/Inputs/test-module.ll --check-prefix=DEFAULT
diff --git a/llvm/test/lit.cfg.py b/llvm/test/lit.cfg.py
index 6772066eacd26..0ff42a3e5b214 100644
--- a/llvm/test/lit.cfg.py
+++ b/llvm/test/lit.cfg.py
@@ -254,6 +254,9 @@ def get_asan_rtlib():
if config.have_tf_api:
config.available_features.add("have_tf_api")
+if config.llvm_inliner_model_autogenerated:
+ config.available_features.add("llvm_inliner_model_autogenerated")
+
def have_cxx_shared_library():
readobj_exe = lit.util.which('llvm-readobj', config.llvm_tools_dir)
if not readobj_exe:
diff --git a/llvm/test/lit.site.cfg.py.in b/llvm/test/lit.site.cfg.py.in
index f33069555d2a6..e90d5d07f5432 100644
--- a/llvm/test/lit.site.cfg.py.in
+++ b/llvm/test/lit.site.cfg.py.in
@@ -54,6 +54,7 @@ config.has_plugins = @LLVM_ENABLE_PLUGINS@
config.linked_bye_extension = @LLVM_BYE_LINK_INTO_TOOLS@
config.have_tf_aot = @LLVM_HAVE_TF_AOT@
config.have_tf_api = @LLVM_HAVE_TF_API@
+config.llvm_inliner_model_autogenerated = @LLVM_INLINER_MODEL_AUTOGENERATED@
config.expensive_checks = @LLVM_ENABLE_EXPENSIVE_CHECKS@
# Support substitution of the tools_dir with user parameters. This is
More information about the llvm-commits
mailing list