tflite: mtk_neuron: Respect the model_token provided by caller The current model token generating method can easily generate thes same token for different models. Since we're also providing the model token and is expecting them to be unique, we can mix the original token calculation logic and the provided token to avoid collision. BUG=b:378633716 TEST=Run VC and not see cache corruption error Change-Id: I0088c57d345769f45ae70977043362377e2f1920 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/tflite/+/6074030 Reviewed-by: Shik Chen <shik@chromium.org> Tested-by: Tommy Chiang <ototot@google.com> Commit-Queue: Tommy Chiang <ototot@google.com>
diff --git a/delegate/mtk_neuron/neuron_delegate_kernel.cc b/delegate/mtk_neuron/neuron_delegate_kernel.cc index 4d9d670..edcbecd 100644 --- a/delegate/mtk_neuron/neuron_delegate_kernel.cc +++ b/delegate/mtk_neuron/neuron_delegate_kernel.cc
@@ -2175,11 +2175,12 @@ } // gen model token nn_compilation_cache_token_.clear(); - std::string bytes_count_str = + std::string model_token_str = + options_.model_token + "/" + std::to_string(TfLiteOpaqueContextGetNumTensors(context)); - const char* model_token = bytes_count_str.c_str(); uint64_t token_parts[4]; - token_parts[0] = ::util::Fingerprint64(model_token, std::strlen(model_token)); + token_parts[0] = + ::util::Fingerprint64(model_token_str.c_str(), model_token_str.size()); if (params != nullptr) { token_parts[1] = GetHash(params->nodes_to_replace); token_parts[2] = GetHash(params->input_tensors);