Commit 71d4f8fc authored by Andrew Moylan's avatar Andrew Moylan Committed by Commit Bot

Fix accidental double logging of successful ML Service call

This function is called by both TfNative and MlService codepaths, and ML
Service code path was already logging success.

Moved the logging out of the common function and made it explicit in
each codepath.

Bug: 935838
Test: no
Change-Id: I8a9a5882f339866ffd309e7ffa87945adf455c7a
Reviewed-on: https://chromium-review.googlesource.com/c/1488391
Auto-Submit: Andrew Moylan <amoylan@chromium.org>
Reviewed-by: default avatarJia Meng <jiameng@chromium.org>
Commit-Queue: Andrew Moylan <amoylan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#635458}
parent 83391efb
...@@ -118,10 +118,10 @@ void MlServiceClientImpl::ExecuteCallback( ...@@ -118,10 +118,10 @@ void MlServiceClientImpl::ExecuteCallback(
prediction.set_response(UserActivityEvent::ModelPrediction::MODEL_ERROR); prediction.set_response(UserActivityEvent::ModelPrediction::MODEL_ERROR);
LogPowerMLSmartDimModelResult(SmartDimModelResult::kOtherError); LogPowerMLSmartDimModelResult(SmartDimModelResult::kOtherError);
} else { } else {
LogPowerMLSmartDimModelResult(SmartDimModelResult::kSuccess);
float inactivity_score = float inactivity_score =
(outputs.value())[0]->data->get_float_list()->value[0]; (outputs.value())[0]->data->get_float_list()->value[0];
prediction = get_prediction_callback.Run(inactivity_score); prediction = get_prediction_callback.Run(inactivity_score);
LogPowerMLSmartDimModelResult(SmartDimModelResult::kSuccess);
} }
std::move(decision_callback).Run(prediction); std::move(decision_callback).Run(prediction);
......
...@@ -326,7 +326,6 @@ SmartDimModelImpl::CreatePredictionFromInactivityScore(float inactivity_score) { ...@@ -326,7 +326,6 @@ SmartDimModelImpl::CreatePredictionFromInactivityScore(float inactivity_score) {
prediction.set_response(UserActivityEvent::ModelPrediction::NO_DIM); prediction.set_response(UserActivityEvent::ModelPrediction::NO_DIM);
} }
LogPowerMLSmartDimModelResult(SmartDimModelResult::kSuccess);
return prediction; return prediction;
} }
...@@ -345,8 +344,7 @@ UserActivityEvent::ModelPrediction SmartDimModelImpl::ShouldDimTfNative( ...@@ -345,8 +344,7 @@ UserActivityEvent::ModelPrediction SmartDimModelImpl::ShouldDimTfNative(
return prediction; return prediction;
} }
// Logging for the success case will take place in LogPowerMLSmartDimModelResult(SmartDimModelResult::kSuccess);
// CreatePredictionFromInactivityScore().
return CreatePredictionFromInactivityScore(inactivity_score); return CreatePredictionFromInactivityScore(inactivity_score);
} }
......
...@@ -91,12 +91,6 @@ class SmartDimModelImpl : public SmartDimModel { ...@@ -91,12 +91,6 @@ class SmartDimModelImpl : public SmartDimModel {
// Takes an |inactivity_score| returned from the ML model and, using that, // Takes an |inactivity_score| returned from the ML model and, using that,
// returns a ModelPrediction. // returns a ModelPrediction.
//
// NOTE: This function is only expected to be called after successful
// inference executions, and therefore does not have an error path.
// As a corollary, it also performs the logging of a successful inference
// call to UMA (doing this here allows the logging to take place in a Mojo
// callback in case the ML service was used).
UserActivityEvent::ModelPrediction CreatePredictionFromInactivityScore( UserActivityEvent::ModelPrediction CreatePredictionFromInactivityScore(
float inactivity_score); float inactivity_score);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment