[mlgo] Support exposing more features than those supported by models
authorMircea Trofin <mtrofin@google.com>
Wed, 27 Apr 2022 21:19:14 +0000 (14:19 -0700)
committerMircea Trofin <mtrofin@google.com>
Tue, 10 May 2022 01:01:21 +0000 (18:01 -0700)
commitc35ad9ee4f21c03baaea65e2479e9d08c4b4acd2
treee4f2d6b69de6804ec3e1d1e34492e140857406b7
parenteef76f9821b845b684c9f54d4f3b6d67c0dc2acc
[mlgo] Support exposing more features than those supported by models

This allows the compiler to support more features than those supported by a
model. The only requirement (development mode only) is that the new
features must be appended at the end of the list of features requested
from the model. The support is transparent to compiler code: for
unsupported features, we provide a valid buffer to copy their values;
it's just that this buffer is disconnected from the model, so insofar
as the model is concerned (AOT or development mode), these features don't
exist. The buffers are allocated at setup - meaning, at steady state,
there is no extra allocation (maintaining the current invariant). These
buffers has 2 roles: one, keep the compiler code simple. Second, allow
logging their values in development mode. The latter allows retraining
a model supporting the larger feature set starting from traces produced
with the old model.

For release mode (AOT-ed models), this decouples compiler evolution from
model evolution, which we want in scenarios where the toolchain is
frequently rebuilt and redeployed: we can first deploy the new features,
and continue working with the older model, until a new model is made
available, which can then be picked up the next time the compiler is built.

Differential Revision: https://reviews.llvm.org/D124565
15 files changed:
llvm/include/llvm/Analysis/InlineModelFeatureMaps.h
llvm/include/llvm/Analysis/MLModelRunner.h
llvm/include/llvm/Analysis/ModelUnderTrainingRunner.h
llvm/include/llvm/Analysis/NoInferenceModelRunner.h
llvm/include/llvm/Analysis/ReleaseModeModelRunner.h
llvm/include/llvm/Analysis/TensorSpec.h
llvm/lib/Analysis/DevelopmentModeInlineAdvisor.cpp
llvm/lib/Analysis/MLInlineAdvisor.cpp
llvm/lib/Analysis/ModelUnderTrainingRunner.cpp
llvm/lib/Analysis/NoInferenceModelRunner.cpp
llvm/lib/Analysis/TFUtils.cpp
llvm/lib/CodeGen/MLRegallocEvictAdvisor.cpp
llvm/unittests/Analysis/CMakeLists.txt
llvm/unittests/Analysis/MLModelRunnerTest.cpp
llvm/unittests/Analysis/TFUtilsTest.cpp