From 83d0646d794654d2c5d6eb0aa5a6b8aeb208ae3b Mon Sep 17 00:00:00 2001 From: Tomeu Vizoso Date: Sun, 24 May 2026 10:28:41 +0200 Subject: [PATCH] teflon/tests: make tflite stubs fail loudly with diagnostics MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Be more explicit when the stubs are used, even if that shouldn't happen any more. Reviewed-by: MaĆ­ra Canal Part-of: --- src/gallium/targets/teflon/tflite-stub.c | 34 ++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/src/gallium/targets/teflon/tflite-stub.c b/src/gallium/targets/teflon/tflite-stub.c index f1d72f1dbfe..f6afa59bc01 100644 --- a/src/gallium/targets/teflon/tflite-stub.c +++ b/src/gallium/targets/teflon/tflite-stub.c @@ -1,15 +1,34 @@ /* * Copyright (c) 2023-2024 Tomeu Vizoso * SPDX-License-Identifier: MIT + * + * Stub implementations of TensorFlow Lite C API. + * */ #include "tensorflow/lite/c/c_api.h" #include "tensorflow/lite/c/common.h" #include "tensorflow/lite/core/c/c_api.h" +#include +#include +#include + +#define TFLITE_STUB_NOT_IMPLEMENTED(func_name) \ + do { \ + fprintf(stderr, \ + "ERROR: TensorFlow Lite stub called: %s()\n" \ + " TensorFlow Lite is not properly installed.\n" \ + " This function has no real implementation.\n", \ + func_name); \ + fflush(stderr); \ + assert(!"TensorFlow Lite stub invoked - TFLite not installed"); \ + } while (0) + void TfLiteInterpreterOptionsAddDelegate(TfLiteInterpreterOptions *options, TfLiteOpaqueDelegate *delegate) { + TFLITE_STUB_NOT_IMPLEMENTED(__func__); } void @@ -18,6 +37,7 @@ TfLiteInterpreterOptionsSetErrorReporter( void (*reporter)(void *user_data, const char *format, va_list args), void *user_data) { + TFLITE_STUB_NOT_IMPLEMENTED(__func__); } TfLiteInterpreter * @@ -25,24 +45,28 @@ TfLiteInterpreterCreate( const TfLiteModel *model, const TfLiteInterpreterOptions *optional_options) { + TFLITE_STUB_NOT_IMPLEMENTED(__func__); return NULL; } TfLiteStatus TfLiteInterpreterAllocateTensors(TfLiteInterpreter *interpreter) { + TFLITE_STUB_NOT_IMPLEMENTED(__func__); return 0; } int32_t TfLiteInterpreterGetInputTensorCount(const TfLiteInterpreter *interpreter) { + TFLITE_STUB_NOT_IMPLEMENTED(__func__); return 0; } TfLiteTensor * TfLiteInterpreterGetInputTensor(const TfLiteInterpreter *interpreter, int32_t input_index) { + TFLITE_STUB_NOT_IMPLEMENTED(__func__); return NULL; } @@ -51,24 +75,28 @@ TfLiteTensorCopyFromBuffer(TfLiteTensor *tensor, const void *input_data, size_t input_data_size) { + TFLITE_STUB_NOT_IMPLEMENTED(__func__); return 0; } TfLiteStatus TfLiteInterpreterInvoke(TfLiteInterpreter *interpreter) { + TFLITE_STUB_NOT_IMPLEMENTED(__func__); return 0; } int32_t TfLiteInterpreterGetOutputTensorCount(const TfLiteInterpreter *interpreter) { + TFLITE_STUB_NOT_IMPLEMENTED(__func__); return 0; } const TfLiteTensor * TfLiteInterpreterGetOutputTensor(const TfLiteInterpreter *interpreter, int32_t output_index) { + TFLITE_STUB_NOT_IMPLEMENTED(__func__); return NULL; } @@ -77,28 +105,33 @@ TfLiteTensorCopyToBuffer(const TfLiteTensor *tensor, void *output_data, size_t output_data_size) { + TFLITE_STUB_NOT_IMPLEMENTED(__func__); return 0; } void TfLiteInterpreterDelete(TfLiteInterpreter *interpreter) { + TFLITE_STUB_NOT_IMPLEMENTED(__func__); } void TfLiteInterpreterOptionsDelete(TfLiteInterpreterOptions *options) { + TFLITE_STUB_NOT_IMPLEMENTED(__func__); } TfLiteModel * TfLiteModelCreate(const void *model_data, size_t model_size) { + TFLITE_STUB_NOT_IMPLEMENTED(__func__); return NULL; } void TfLiteModelDelete(TfLiteModel *model) { + TFLITE_STUB_NOT_IMPLEMENTED(__func__); } /* FIXME: Why do we need to redeclare the prototype for this one here? */ @@ -107,5 +140,6 @@ TfLiteInterpreterOptions *TfLiteInterpreterOptionsCreate(void); TfLiteInterpreterOptions * TfLiteInterpreterOptionsCreate(void) { + TFLITE_STUB_NOT_IMPLEMENTED(__func__); return NULL; }