ml: Implement model-specific metric reports to UMA
In the previous code, the metrics of each type of system resource
usage (RAM, cpu time etc.) are aggregated over all the models. So one
cannot see the resource usage of a particular model. In this CL, we
make such metrics and reports (to UMA) model-specific.
For example, assume there are two models with |metric_base_name|
"SmartDimModel" and "TestModel", respectively. In logging the cpu
usage of model loading, the preivous code will only generate one
histogram on UMA:
MachineLearningService.LoadModelResult.CpuTimeMicrosec
which contains metrics of both "SmartDimModel" and "TestModel". Now
there will be two histograms,
MachineLearningService.SmartDimModel.LoadModelResult.CpuTimeMicrosec
MachineLearningService.TestModel.LoadModelResult.CpuTimeMicrosec
which record the metrics for each model separately.
This is achieved by requiring model owners to specify a
metrics_model_name in their ModelMetadata.
BUG=chromium:924709
TEST=test on device
TEST=histogram names of TestModel are correct
TEST=histogram name of model specification error is correct
Change-Id: Id55b9d0385ec80e0606fa4d663dbd2bcc9c24cf3
Reviewed-on: https://chromium-review.googlesource.com/1710251
Tested-by: Honglin Yu <honglinyu@chromium.org>
Commit-Ready: Honglin Yu <honglinyu@chromium.org>
Legacy-Commit-Queue: Commit Bot <commit-bot@chromium.org>
Reviewed-by: Andrew Moylan <amoylan@chromium.org>
diff --git a/ml/graph_executor_impl.h b/ml/graph_executor_impl.h
index 68452e8..9d57b14 100644
--- a/ml/graph_executor_impl.h
+++ b/ml/graph_executor_impl.h
@@ -38,13 +38,16 @@
// from required input / output tensor names to their indices in the TF lite
// graph, and must outlive this object.
//
+ // UMA metrics will be logged with the specified |metrics_model_name|.
+ //
// As is standard, |interpreter| must outlive the model with which it was
// constructed.
GraphExecutorImpl(
const std::map<std::string, int>& required_inputs,
const std::map<std::string, int>& required_outputs,
std::unique_ptr<tflite::Interpreter> interpreter,
- chromeos::machine_learning::mojom::GraphExecutorRequest request);
+ chromeos::machine_learning::mojom::GraphExecutorRequest request,
+ const std::string& metrics_model_name);
void set_connection_error_handler(base::Closure connection_error_handler);
@@ -63,6 +66,9 @@
mojo::Binding<chromeos::machine_learning::mojom::GraphExecutor> binding_;
+ // Model name as it should appear in UMA histogram names.
+ const std::string metrics_model_name_;
+
DISALLOW_COPY_AND_ASSIGN(GraphExecutorImpl);
};