Skip to content

Commit 6c76d01

Browse files
committed
[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
1 parent 8383e49 commit 6c76d01

File tree

7 files changed

+16
-8
lines changed

7 files changed

+16
-8
lines changed

llvm/CMakeLists.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -850,6 +850,13 @@ if (NOT TENSORFLOW_AOT_PATH STREQUAL "")
850850
install(TARGETS tf_xla_runtime EXPORT LLVMExports
851851
ARCHIVE DESTINATION lib${LLVM_LIBDIR_SUFFIX} COMPONENT tf_xla_runtime)
852852
set_property(GLOBAL APPEND PROPERTY LLVM_EXPORTS tf_xla_runtime)
853+
# Once we add more modules, we should handle this more automatically.
854+
if (NOT DEFINED LLVM_INLINER_MODEL_PATH
855+
OR "${LLVM_INLINER_MODEL_PATH}" STREQUAL ""
856+
OR "${LLVM_INLINER_MODEL_PATH}" STREQUAL "autogenerate")
857+
set(LLVM_INLINER_MODEL_PATH "autogenerate")
858+
set(LLVM_INLINER_MODEL_AUTOGENERATED 1)
859+
endif()
853860
endif()
854861

855862
# Configure the three LLVM configuration header files.

llvm/lib/Analysis/CMakeLists.txt

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,6 @@ if (DEFINED LLVM_HAVE_TF_AOT OR DEFINED LLVM_HAVE_TF_API)
88
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")
99

1010
if (DEFINED LLVM_HAVE_TF_AOT)
11-
# If the path is empty, autogenerate the model
12-
if (NOT DEFINED LLVM_INLINER_MODEL_PATH OR "${LLVM_INLINER_MODEL_PATH}" STREQUAL "")
13-
set(LLVM_INLINER_MODEL_PATH "autogenerate")
14-
message(WARNING "LLVM_INLINER_MODEL_PATH was not set: autogenerating a model to finish the build.")
15-
endif()
16-
1711
tf_find_and_compile(
1812
${LLVM_INLINER_MODEL_PATH}
1913
${LLVM_INLINER_MODEL_CURRENT_URL}

llvm/test/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ llvm_canonicalize_cmake_booleans(
1717
LLVM_BYE_LINK_INTO_TOOLS
1818
LLVM_HAVE_TF_AOT
1919
LLVM_HAVE_TF_API
20+
LLVM_INLINER_MODEL_AUTOGENERATED
2021
LLVM_ENABLE_EXPENSIVE_CHECKS
2122
)
2223

llvm/test/Transforms/Inline/ML/bounds-checks.ll

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
; Test behavior when inlining policy grows size out of control.
22
; In all cases, the end result is the same: mandatory inlinings must happen.
3-
; However, when we discover we 'trip' over the artificially-low size increase
3+
; However, when we discover we 'trip' over the artificially-low size increase
44
; factor, we don't inline anymore.
55
; REQUIRES: have_tf_aot
6+
; REQUIRES: llvm_inliner_model_autogenerated
67
; 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
78
; 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
89

@@ -38,4 +39,4 @@ attributes #0 = { alwaysinline }
3839
; @some-function isn't mandatory, and when we set the increase threshold too low,
3940
; it won't be inlined.
4041
; NOBOUNDS-NOT: @some_function
41-
; BOUNDS: call i64 @some_function
42+
; BOUNDS: call i64 @some_function

llvm/test/Transforms/Inline/ML/ml-test-release-mode.ll

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,6 @@
66
; for the 'development' mode.
77
;
88
; REQUIRES: have_tf_aot
9+
; REQUIRES: llvm_inliner_model_autogenerated
910
; 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
1011
; 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

llvm/test/lit.cfg.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,9 @@ def get_asan_rtlib():
254254
if config.have_tf_api:
255255
config.available_features.add("have_tf_api")
256256

257+
if config.llvm_inliner_model_autogenerated:
258+
config.available_features.add("llvm_inliner_model_autogenerated")
259+
257260
def have_cxx_shared_library():
258261
readobj_exe = lit.util.which('llvm-readobj', config.llvm_tools_dir)
259262
if not readobj_exe:

llvm/test/lit.site.cfg.py.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ config.has_plugins = @LLVM_ENABLE_PLUGINS@
5454
config.linked_bye_extension = @LLVM_BYE_LINK_INTO_TOOLS@
5555
config.have_tf_aot = @LLVM_HAVE_TF_AOT@
5656
config.have_tf_api = @LLVM_HAVE_TF_API@
57+
config.llvm_inliner_model_autogenerated = @LLVM_INLINER_MODEL_AUTOGENERATED@
5758
config.expensive_checks = @LLVM_ENABLE_EXPENSIVE_CHECKS@
5859

5960
# Support substitution of the tools_dir with user parameters. This is

0 commit comments

Comments
 (0)