Michael Martis | 26abcd8 | 2018-08-08 10:57:25 +1000 | [diff] [blame] | 1 | // Copyright 2018 The Chromium OS Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #include "ml/graph_executor_impl.h" |
alanlxl | cb1f856 | 2018-11-01 15:16:11 +1100 | [diff] [blame] | 6 | #include "ml/request_metrics.h" |
Michael Martis | 26abcd8 | 2018-08-08 10:57:25 +1000 | [diff] [blame] | 7 | |
| 8 | #include <set> |
| 9 | #include <utility> |
Hidehiko Abe | 8ab64a6 | 2018-09-19 00:04:39 +0900 | [diff] [blame] | 10 | #include <vector> |
Michael Martis | 26abcd8 | 2018-08-08 10:57:25 +1000 | [diff] [blame] | 11 | |
Qijiang Fan | e19d67d | 2020-04-01 08:18:39 +0900 | [diff] [blame] | 12 | #include <base/stl_util.h> |
| 13 | |
Hidehiko Abe | aa488c3 | 2018-08-31 23:49:41 +0900 | [diff] [blame] | 14 | #include "ml/mojom/tensor.mojom.h" |
Michael Martis | 26abcd8 | 2018-08-08 10:57:25 +1000 | [diff] [blame] | 15 | #include "ml/tensor_view.h" |
Michael Martis | 26abcd8 | 2018-08-08 10:57:25 +1000 | [diff] [blame] | 16 | |
| 17 | namespace ml { |
| 18 | |
| 19 | namespace { |
| 20 | |
| 21 | using ::chromeos::machine_learning::mojom::ExecuteResult; |
Andrew Moylan | b481af7 | 2020-07-09 15:22:00 +1000 | [diff] [blame] | 22 | using ::chromeos::machine_learning::mojom::GraphExecutor; |
Michael Martis | 26abcd8 | 2018-08-08 10:57:25 +1000 | [diff] [blame] | 23 | using ::chromeos::machine_learning::mojom::Int64List; |
| 24 | using ::chromeos::machine_learning::mojom::Tensor; |
| 25 | using ::chromeos::machine_learning::mojom::TensorPtr; |
| 26 | using ::chromeos::machine_learning::mojom::ValueList; |
| 27 | |
alanlxl | cb1f856 | 2018-11-01 15:16:11 +1100 | [diff] [blame] | 28 | // Base name for UMA metrics related to graph execution |
Honglin Yu | 6adafcd | 2019-07-22 13:48:11 +1000 | [diff] [blame] | 29 | constexpr char kMetricsRequestName[] = "ExecuteResult"; |
alanlxl | cb1f856 | 2018-11-01 15:16:11 +1100 | [diff] [blame] | 30 | |
Andrew Moylan | 79b34a4 | 2020-07-08 11:13:11 +1000 | [diff] [blame] | 31 | // Verifies `tensor` is valid (i.e. is of type `TensorType` and of the correct |
| 32 | // shape for this input) and copies its data into the graph `interpreter` at |
| 33 | // position `index`. |
Michael Martis | 26abcd8 | 2018-08-08 10:57:25 +1000 | [diff] [blame] | 34 | template <typename TensorType, typename MemoryType> |
| 35 | ExecuteResult PopulateInput(const TensorPtr& tensor, |
| 36 | const int index, |
| 37 | tflite::Interpreter* const interpreter) { |
| 38 | const TensorView<TensorType> tensor_view(tensor); |
| 39 | |
| 40 | if (!tensor_view.IsValidType()) |
| 41 | return ExecuteResult::INPUT_TYPE_ERROR; |
| 42 | |
| 43 | if (!tensor_view.IsValidFormat()) |
| 44 | return ExecuteResult::INPUT_FORMAT_ERROR; |
| 45 | |
| 46 | // Check that given input shape matches that expected by TF lite. |
| 47 | |
| 48 | const TfLiteIntArray& expected_dims = *interpreter->tensor(index)->dims; |
Hidehiko Abe | 8ab64a6 | 2018-09-19 00:04:39 +0900 | [diff] [blame] | 49 | const std::vector<int64_t>& actual_dims = tensor_view.GetShape(); |
Michael Martis | 26abcd8 | 2018-08-08 10:57:25 +1000 | [diff] [blame] | 50 | |
| 51 | bool shape_matches = expected_dims.size == actual_dims.size(); |
| 52 | for (int i = 0; shape_matches && i < expected_dims.size; ++i) { |
| 53 | shape_matches = expected_dims.data[i] == actual_dims[i]; |
| 54 | } |
| 55 | |
| 56 | if (!shape_matches) |
| 57 | return ExecuteResult::INPUT_SHAPE_ERROR; |
| 58 | |
| 59 | MemoryType* const input_memory = interpreter->typed_tensor<MemoryType>(index); |
Hidehiko Abe | 8ab64a6 | 2018-09-19 00:04:39 +0900 | [diff] [blame] | 60 | const std::vector<TensorType>& tensor_values = tensor_view.GetValues(); |
Michael Martis | 26abcd8 | 2018-08-08 10:57:25 +1000 | [diff] [blame] | 61 | for (int i = 0; i < tensor_values.size(); ++i) { |
| 62 | input_memory[i] = tensor_values[i]; |
| 63 | } |
| 64 | |
| 65 | return ExecuteResult::OK; |
| 66 | } |
| 67 | |
| 68 | ExecuteResult InvalidInput(const TensorPtr&, int, tflite::Interpreter*) { |
| 69 | return ExecuteResult::EXECUTION_ERROR; |
| 70 | } |
| 71 | |
| 72 | // A table of functions to validate / populate data for model nodes expecting |
| 73 | // input of each TF lite type. |
| 74 | // |
| 75 | // This table is indexed by TfLiteType, the possible values of which can be |
Michael Martis | 8783c8e | 2019-06-26 17:30:54 +1000 | [diff] [blame] | 76 | // found at <tensorflow/lite/context.h>. We make the following |
Michael Martis | 26abcd8 | 2018-08-08 10:57:25 +1000 | [diff] [blame] | 77 | // assumptions about index values: |
| 78 | // 1) They will remain consistent across TF lite releases, and |
| 79 | // 2) They will always start from (close to) 0 and be (mostly) consecutive. |
| 80 | // |
| 81 | // Since TfLiteType is part of the stable C API for TF lite, these assumptions |
| 82 | // seem fair. |
| 83 | constexpr decltype(&InvalidInput) kPopulateInputFns[] = { |
| 84 | &InvalidInput, // kTfLiteNoType |
| 85 | &PopulateInput<double, float>, // kTfLiteFloat32 |
| 86 | &PopulateInput<int64_t, int32_t>, // kTfLiteInt32 |
| 87 | &PopulateInput<int64_t, uint8_t>, // kTfLiteUInt8 |
| 88 | &PopulateInput<int64_t, int64_t>, // kTfLiteInt64 |
| 89 | &InvalidInput, // kTfLiteString |
| 90 | &PopulateInput<int64_t, bool>, // kTfLiteBool |
| 91 | }; |
| 92 | |
Andrew Moylan | 79b34a4 | 2020-07-08 11:13:11 +1000 | [diff] [blame] | 93 | // Copies data from position `index` in the graph `interpreter` into the given |
Michael Martis | 26abcd8 | 2018-08-08 10:57:25 +1000 | [diff] [blame] | 94 | // tensor object. |
| 95 | template <typename TensorType, typename MemoryType> |
| 96 | ExecuteResult PopulateOutput(const int index, |
| 97 | const tflite::Interpreter& interpreter, |
| 98 | const TensorPtr& tensor) { |
| 99 | TensorView<TensorType> tensor_view(tensor); |
| 100 | tensor_view.Allocate(); |
| 101 | |
| 102 | // Empty output is not valid. |
| 103 | const TfLiteIntArray& dims = *interpreter.tensor(index)->dims; |
| 104 | if (dims.size == 0) |
| 105 | return ExecuteResult::EXECUTION_ERROR; |
| 106 | |
| 107 | // Copy across size information and calculate the number of elements being |
| 108 | // output. |
| 109 | int64_t num_entries = 1; |
Hidehiko Abe | 8ab64a6 | 2018-09-19 00:04:39 +0900 | [diff] [blame] | 110 | std::vector<int64_t>& tensor_dims = tensor_view.GetShape(); |
Michael Martis | 26abcd8 | 2018-08-08 10:57:25 +1000 | [diff] [blame] | 111 | tensor_dims.resize(dims.size); |
| 112 | for (int i = 0; i < dims.size; ++i) { |
| 113 | const int64_t dim_length = dims.data[i]; |
| 114 | |
| 115 | if (dim_length <= 0) |
| 116 | return ExecuteResult::EXECUTION_ERROR; |
| 117 | |
| 118 | tensor_dims[i] = dim_length; |
| 119 | num_entries *= dim_length; |
| 120 | } |
| 121 | |
| 122 | // Populate tensor values. |
| 123 | const MemoryType* const output_memory = |
| 124 | interpreter.typed_tensor<MemoryType>(index); |
Hidehiko Abe | 8ab64a6 | 2018-09-19 00:04:39 +0900 | [diff] [blame] | 125 | std::vector<TensorType>& tensor_values = tensor_view.GetValues(); |
Michael Martis | 26abcd8 | 2018-08-08 10:57:25 +1000 | [diff] [blame] | 126 | tensor_values.resize(num_entries); |
| 127 | for (int i = 0; i < num_entries; ++i) { |
| 128 | tensor_values[i] = output_memory[i]; |
| 129 | } |
| 130 | |
| 131 | return ExecuteResult::OK; |
| 132 | } |
| 133 | |
| 134 | ExecuteResult InvalidOutput(int, const tflite::Interpreter&, const TensorPtr&) { |
| 135 | return ExecuteResult::EXECUTION_ERROR; |
| 136 | } |
| 137 | |
| 138 | // A table of functions to populate data for tensors from output of each TF lite |
| 139 | // type. |
| 140 | // |
| 141 | // This table is indexed by TfLiteType, the possible values of which can be |
Michael Martis | 8783c8e | 2019-06-26 17:30:54 +1000 | [diff] [blame] | 142 | // found at <tensorflow/lite/context.h>. See the caveats discussed in |
Andrew Moylan | 79b34a4 | 2020-07-08 11:13:11 +1000 | [diff] [blame] | 143 | // the comment above `kPopulateInputFns`. |
Michael Martis | 26abcd8 | 2018-08-08 10:57:25 +1000 | [diff] [blame] | 144 | constexpr decltype(&InvalidOutput) kPopulateOutputFns[] = { |
| 145 | &InvalidOutput, // kTfLiteNoType |
| 146 | &PopulateOutput<double, float>, // kTfLiteFloat32 |
| 147 | &PopulateOutput<int64_t, int32_t>, // kTfLiteInt32 |
| 148 | &PopulateOutput<int64_t, uint8_t>, // kTfLiteUInt8 |
| 149 | &PopulateOutput<int64_t, int64_t>, // kTfLiteInt64 |
| 150 | &InvalidOutput, // kTfLiteString |
| 151 | &PopulateOutput<int64_t, bool>, // kTfLiteBool |
| 152 | }; |
| 153 | |
Michael Martis | 26abcd8 | 2018-08-08 10:57:25 +1000 | [diff] [blame] | 154 | } // namespace |
| 155 | |
| 156 | GraphExecutorImpl::GraphExecutorImpl( |
| 157 | const std::map<std::string, int>& required_inputs, |
| 158 | const std::map<std::string, int>& required_outputs, |
| 159 | std::unique_ptr<tflite::Interpreter> interpreter, |
Andrew Moylan | b481af7 | 2020-07-09 15:22:00 +1000 | [diff] [blame] | 160 | mojo::PendingReceiver<GraphExecutor> receiver, |
Honglin Yu | 6adafcd | 2019-07-22 13:48:11 +1000 | [diff] [blame] | 161 | const std::string& metrics_model_name) |
Michael Martis | 26abcd8 | 2018-08-08 10:57:25 +1000 | [diff] [blame] | 162 | : required_inputs_(required_inputs), |
| 163 | required_outputs_(required_outputs), |
| 164 | interpreter_(std::move(interpreter)), |
Andrew Moylan | b481af7 | 2020-07-09 15:22:00 +1000 | [diff] [blame] | 165 | receiver_(this, std::move(receiver)), |
Honglin Yu | 6adafcd | 2019-07-22 13:48:11 +1000 | [diff] [blame] | 166 | metrics_model_name_(metrics_model_name) {} |
Michael Martis | 26abcd8 | 2018-08-08 10:57:25 +1000 | [diff] [blame] | 167 | |
Andrew Moylan | b481af7 | 2020-07-09 15:22:00 +1000 | [diff] [blame] | 168 | void GraphExecutorImpl::set_disconnect_handler( |
| 169 | base::Closure disconnect_handler) { |
| 170 | receiver_.set_disconnect_handler(std::move(disconnect_handler)); |
Michael Martis | 26abcd8 | 2018-08-08 10:57:25 +1000 | [diff] [blame] | 171 | } |
| 172 | |
Qijiang Fan | 5d381a0 | 2020-04-19 23:42:37 +0900 | [diff] [blame] | 173 | void GraphExecutorImpl::Execute(base::flat_map<std::string, TensorPtr> tensors, |
| 174 | const std::vector<std::string>& outputs, |
| 175 | ExecuteCallback callback) { |
Honglin Yu | 6adafcd | 2019-07-22 13:48:11 +1000 | [diff] [blame] | 176 | DCHECK(!metrics_model_name_.empty()); |
alanlxl | cb1f856 | 2018-11-01 15:16:11 +1100 | [diff] [blame] | 177 | |
Honglin Yu | 6adafcd | 2019-07-22 13:48:11 +1000 | [diff] [blame] | 178 | RequestMetrics<ExecuteResult> request_metrics(metrics_model_name_, |
| 179 | kMetricsRequestName); |
alanlxl | cb1f856 | 2018-11-01 15:16:11 +1100 | [diff] [blame] | 180 | request_metrics.StartRecordingPerformanceMetrics(); |
| 181 | |
Michael Martis | 26abcd8 | 2018-08-08 10:57:25 +1000 | [diff] [blame] | 182 | // Validate input and output names (before executing graph, for efficiency). |
| 183 | |
| 184 | for (const auto& kv : tensors) { |
Hidehiko Abe | 8ab64a6 | 2018-09-19 00:04:39 +0900 | [diff] [blame] | 185 | const std::string& cur_input_name = kv.first; |
Michael Martis | 26abcd8 | 2018-08-08 10:57:25 +1000 | [diff] [blame] | 186 | |
| 187 | const auto name_lookup = required_inputs_.find(cur_input_name); |
| 188 | if (name_lookup == required_inputs_.end() || |
| 189 | name_lookup->second >= interpreter_->tensors_size()) { |
Qijiang Fan | 5d381a0 | 2020-04-19 23:42:37 +0900 | [diff] [blame] | 190 | std::move(callback).Run(ExecuteResult::UNKNOWN_INPUT_ERROR, |
| 191 | base::nullopt); |
alanlxl | cb1f856 | 2018-11-01 15:16:11 +1100 | [diff] [blame] | 192 | request_metrics.RecordRequestEvent(ExecuteResult::UNKNOWN_INPUT_ERROR); |
Michael Martis | 26abcd8 | 2018-08-08 10:57:25 +1000 | [diff] [blame] | 193 | return; |
| 194 | } |
| 195 | } |
| 196 | if (tensors.size() != required_inputs_.size()) { |
Qijiang Fan | 5d381a0 | 2020-04-19 23:42:37 +0900 | [diff] [blame] | 197 | std::move(callback).Run(ExecuteResult::INPUT_MISSING_ERROR, base::nullopt); |
alanlxl | cb1f856 | 2018-11-01 15:16:11 +1100 | [diff] [blame] | 198 | request_metrics.RecordRequestEvent(ExecuteResult::INPUT_MISSING_ERROR); |
Michael Martis | 26abcd8 | 2018-08-08 10:57:25 +1000 | [diff] [blame] | 199 | return; |
| 200 | } |
| 201 | |
| 202 | std::set<std::string> seen_outputs; |
Hidehiko Abe | 31bb963 | 2018-11-23 02:49:56 +0900 | [diff] [blame] | 203 | for (const auto& cur_output_name : outputs) { |
Hidehiko Abe | 8ab64a6 | 2018-09-19 00:04:39 +0900 | [diff] [blame] | 204 | const auto name_lookup = required_outputs_.find(cur_output_name); |
Michael Martis | 26abcd8 | 2018-08-08 10:57:25 +1000 | [diff] [blame] | 205 | if (name_lookup == required_outputs_.end() || |
| 206 | name_lookup->second >= interpreter_->tensors_size()) { |
Qijiang Fan | 5d381a0 | 2020-04-19 23:42:37 +0900 | [diff] [blame] | 207 | std::move(callback).Run(ExecuteResult::UNKNOWN_OUTPUT_ERROR, |
| 208 | base::nullopt); |
alanlxl | cb1f856 | 2018-11-01 15:16:11 +1100 | [diff] [blame] | 209 | request_metrics.RecordRequestEvent(ExecuteResult::UNKNOWN_OUTPUT_ERROR); |
Michael Martis | 26abcd8 | 2018-08-08 10:57:25 +1000 | [diff] [blame] | 210 | return; |
| 211 | } |
| 212 | |
| 213 | // Specifying the same output twice is an error. |
Hidehiko Abe | 8ab64a6 | 2018-09-19 00:04:39 +0900 | [diff] [blame] | 214 | const auto insert_result = seen_outputs.insert(cur_output_name); |
Michael Martis | 26abcd8 | 2018-08-08 10:57:25 +1000 | [diff] [blame] | 215 | if (!insert_result.second) { |
Qijiang Fan | 5d381a0 | 2020-04-19 23:42:37 +0900 | [diff] [blame] | 216 | std::move(callback).Run(ExecuteResult::DUPLICATE_OUTPUT_ERROR, |
| 217 | base::nullopt); |
alanlxl | cb1f856 | 2018-11-01 15:16:11 +1100 | [diff] [blame] | 218 | request_metrics.RecordRequestEvent(ExecuteResult::DUPLICATE_OUTPUT_ERROR); |
Michael Martis | 26abcd8 | 2018-08-08 10:57:25 +1000 | [diff] [blame] | 219 | return; |
| 220 | } |
| 221 | } |
| 222 | if (outputs.size() != required_outputs_.size()) { |
Qijiang Fan | 5d381a0 | 2020-04-19 23:42:37 +0900 | [diff] [blame] | 223 | std::move(callback).Run(ExecuteResult::OUTPUT_MISSING_ERROR, base::nullopt); |
alanlxl | cb1f856 | 2018-11-01 15:16:11 +1100 | [diff] [blame] | 224 | request_metrics.RecordRequestEvent(ExecuteResult::OUTPUT_MISSING_ERROR); |
Michael Martis | 26abcd8 | 2018-08-08 10:57:25 +1000 | [diff] [blame] | 225 | return; |
| 226 | } |
| 227 | |
| 228 | // Copy input data into the interpreter. |
| 229 | for (const auto& kv : tensors) { |
Hidehiko Abe | 8ab64a6 | 2018-09-19 00:04:39 +0900 | [diff] [blame] | 230 | const std::string& cur_input_name = kv.first; |
Michael Martis | 26abcd8 | 2018-08-08 10:57:25 +1000 | [diff] [blame] | 231 | const TensorPtr& cur_input = kv.second; |
| 232 | |
| 233 | // Always valid, by the input name check at the start of this function. |
| 234 | const int cur_input_id = required_inputs_.find(cur_input_name)->second; |
| 235 | |
| 236 | // Check that the current input node is a supported type. |
| 237 | const uint32_t cur_input_type = interpreter_->tensor(cur_input_id)->type; |
Qijiang Fan | e19d67d | 2020-04-01 08:18:39 +0900 | [diff] [blame] | 238 | if (cur_input_type >= base::size(kPopulateInputFns)) { |
Michael Martis | 26abcd8 | 2018-08-08 10:57:25 +1000 | [diff] [blame] | 239 | LOG(ERROR) << "TF lite graph contains invalid input node " << cur_input_id |
| 240 | << " of type " << cur_input_type << "."; |
Qijiang Fan | 5d381a0 | 2020-04-19 23:42:37 +0900 | [diff] [blame] | 241 | std::move(callback).Run(ExecuteResult::EXECUTION_ERROR, base::nullopt); |
alanlxl | cb1f856 | 2018-11-01 15:16:11 +1100 | [diff] [blame] | 242 | request_metrics.RecordRequestEvent(ExecuteResult::EXECUTION_ERROR); |
Michael Martis | 26abcd8 | 2018-08-08 10:57:25 +1000 | [diff] [blame] | 243 | return; |
| 244 | } |
| 245 | |
| 246 | // Attempt to copy input data into the current input node. |
| 247 | const ExecuteResult populate_input_result = |
| 248 | (*kPopulateInputFns[cur_input_type])(cur_input, cur_input_id, |
| 249 | interpreter_.get()); |
| 250 | if (populate_input_result != ExecuteResult::OK) { |
Qijiang Fan | 5d381a0 | 2020-04-19 23:42:37 +0900 | [diff] [blame] | 251 | std::move(callback).Run(populate_input_result, base::nullopt); |
alanlxl | cb1f856 | 2018-11-01 15:16:11 +1100 | [diff] [blame] | 252 | request_metrics.RecordRequestEvent(populate_input_result); |
Michael Martis | 26abcd8 | 2018-08-08 10:57:25 +1000 | [diff] [blame] | 253 | return; |
| 254 | } |
| 255 | } |
| 256 | |
| 257 | // Execute graph. |
| 258 | if (interpreter_->Invoke() != kTfLiteOk) { |
| 259 | LOG(ERROR) << "TF lite graph execution failed unexpectedly."; |
Qijiang Fan | 5d381a0 | 2020-04-19 23:42:37 +0900 | [diff] [blame] | 260 | std::move(callback).Run(ExecuteResult::EXECUTION_ERROR, base::nullopt); |
alanlxl | cb1f856 | 2018-11-01 15:16:11 +1100 | [diff] [blame] | 261 | request_metrics.RecordRequestEvent(ExecuteResult::EXECUTION_ERROR); |
Michael Martis | 26abcd8 | 2018-08-08 10:57:25 +1000 | [diff] [blame] | 262 | return; |
| 263 | } |
| 264 | |
| 265 | // Extract output. |
Hidehiko Abe | 31bb963 | 2018-11-23 02:49:56 +0900 | [diff] [blame] | 266 | std::vector<chromeos::machine_learning::mojom::TensorPtr> output_tensors; |
| 267 | for (const auto& cur_output_name : outputs) { |
Michael Martis | 26abcd8 | 2018-08-08 10:57:25 +1000 | [diff] [blame] | 268 | output_tensors.push_back(Tensor::New()); |
| 269 | |
| 270 | // Always valid, by the output name check at the start of this function. |
| 271 | const int cur_output_id = |
Hidehiko Abe | 8ab64a6 | 2018-09-19 00:04:39 +0900 | [diff] [blame] | 272 | required_outputs_.find(cur_output_name)->second; |
Michael Martis | 26abcd8 | 2018-08-08 10:57:25 +1000 | [diff] [blame] | 273 | |
| 274 | // Check that the current output node is a supported type. |
| 275 | const uint32_t cur_output_type = interpreter_->tensor(cur_output_id)->type; |
Qijiang Fan | e19d67d | 2020-04-01 08:18:39 +0900 | [diff] [blame] | 276 | if (cur_output_type >= base::size(kPopulateOutputFns)) { |
Michael Martis | 26abcd8 | 2018-08-08 10:57:25 +1000 | [diff] [blame] | 277 | LOG(ERROR) << "TF lite graph contains invalid output node " |
| 278 | << cur_output_id << " of type " << cur_output_type << "."; |
Qijiang Fan | 5d381a0 | 2020-04-19 23:42:37 +0900 | [diff] [blame] | 279 | std::move(callback).Run(ExecuteResult::EXECUTION_ERROR, base::nullopt); |
alanlxl | cb1f856 | 2018-11-01 15:16:11 +1100 | [diff] [blame] | 280 | request_metrics.RecordRequestEvent(ExecuteResult::EXECUTION_ERROR); |
Michael Martis | 26abcd8 | 2018-08-08 10:57:25 +1000 | [diff] [blame] | 281 | return; |
| 282 | } |
| 283 | |
| 284 | // Attempt to extract data from the current output node. |
| 285 | const ExecuteResult populate_output_result = |
| 286 | (*kPopulateOutputFns[cur_output_type])(cur_output_id, *interpreter_, |
| 287 | *--output_tensors.end()); |
| 288 | if (populate_output_result != ExecuteResult::OK) { |
Qijiang Fan | 5d381a0 | 2020-04-19 23:42:37 +0900 | [diff] [blame] | 289 | std::move(callback).Run(populate_output_result, base::nullopt); |
alanlxl | cb1f856 | 2018-11-01 15:16:11 +1100 | [diff] [blame] | 290 | request_metrics.RecordRequestEvent(populate_output_result); |
Michael Martis | 26abcd8 | 2018-08-08 10:57:25 +1000 | [diff] [blame] | 291 | return; |
| 292 | } |
| 293 | } |
| 294 | |
Qijiang Fan | 5d381a0 | 2020-04-19 23:42:37 +0900 | [diff] [blame] | 295 | std::move(callback).Run(ExecuteResult::OK, std::move(output_tensors)); |
alanlxl | cb1f856 | 2018-11-01 15:16:11 +1100 | [diff] [blame] | 296 | request_metrics.FinishRecordingPerformanceMetrics(); |
| 297 | request_metrics.RecordRequestEvent(ExecuteResult::OK); |
Michael Martis | 26abcd8 | 2018-08-08 10:57:25 +1000 | [diff] [blame] | 298 | } |
| 299 | |
| 300 | } // namespace ml |