ChromeML: Add API for logging histograms
This will allow the library implementation to use UMA.
Bug: b:320773251
Change-Id: Icb5544cd248708c985a04556ef7c78add279f738
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5212409
Reviewed-by: Clark DuVall <cduvall@chromium.org>
Commit-Queue: Ken Rockot <rockot@google.com>
Cr-Commit-Position: refs/heads/main@{#1248907}
diff --git a/services/on_device_model/ml/chrome_ml_api.h b/services/on_device_model/ml/chrome_ml_api.h
index d52889c..6ea82ab 100644
--- a/services/on_device_model/ml/chrome_ml_api.h
+++ b/services/on_device_model/ml/chrome_ml_api.h
@@ -202,6 +202,21 @@
WGPUBackendType backend_type;
};
+struct ChromeMLMetricsFns {
+ // Logs an exact sample for the named metric.
+ void (*RecordExactLinearHistogram)(const char* name,
+ int sample,
+ int exclusive_max);
+
+ // Logs a sample for the named metric into one of a fixed number of buckets
+ // spanning the specified range.
+ void (*RecordCustomCountsHistogram)(const char* name,
+ int sample,
+ int min,
+ int exclusive_max,
+ size_t buckets);
+};
+
// IMPORTANT: All functions that call ChromeMLAPI should be annotated with
// DISABLE_CFI_DLSYM.
@@ -211,6 +226,9 @@
// functions.
void (*InitDawnProcs)(const DawnProcTable& procs);
+ // Sets functions which can be used to log metrics from within the library.
+ void (*SetMetricsFns)(const ChromeMLMetricsFns* fns);
+
// Sets an error handling function for fatal errors in the GPU. See also
// SetFatalErrorNonGpuFn.
void (*SetFatalErrorFn)(ChromeMLFatalErrorFn error_fn) = nullptr;