0

Pass an explicitly invalid cache file if not set

PlatformFile is declared as an int on non-Windows platforms, which
means that a default-initialized PlatformFile may be 0, which is a
valid file descriptor. This is not intended

Bug: 401011041
Change-Id: Ia41e57903eb0876331dacbbdd117b284aeda842c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6543265
Auto-Submit: Austin Sullivan <asully@chromium.org>
Reviewed-by: Clark DuVall <cduvall@chromium.org>
Commit-Queue: Clark DuVall <cduvall@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1460121}
This commit is contained in:
Austin Sullivan
2025-05-14 08:29:10 -07:00
committed by Chromium LUCI CQ
parent 44a68adfbc
commit 571dcda12d

@ -542,10 +542,11 @@ LoadModelResult OnDeviceModelExecutor::Init(
data.sentencepiece_model_path = sp_model_path_str.data();
}
// TODO(crbug.com/400998489): Cache files are experimental for now.
if (optimization_guide::features::ForceCpuBackendForOnDeviceModel() &&
assets.cache.IsValid()) {
data.cache_file = assets.cache.TakePlatformFile();
}
data.cache_file =
optimization_guide::features::ForceCpuBackendForOnDeviceModel() &&
assets.cache.IsValid()
? assets.cache.TakePlatformFile()
: base::kInvalidPlatformFile;
ChromeMLModelDescriptor descriptor = {
.backend_type = params->backend_type,
.model_data = &data,