From b43acca23a8230ff52643d97feaf591d56819afb Mon Sep 17 00:00:00 2001 From: Carlos Pereira Atencio Date: Tue, 4 Jun 2024 17:30:50 +0100 Subject: [PATCH] Fix missing updates to example_dataprocessor since last refactor. --- mlrunner/example_dataprocessor.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/mlrunner/example_dataprocessor.c b/mlrunner/example_dataprocessor.c index 61b6d5b..1fd1909 100644 --- a/mlrunner/example_dataprocessor.c +++ b/mlrunner/example_dataprocessor.c @@ -27,22 +27,30 @@ static bool exampleDataProcessor_isDataReady(); static float* exampleDataProcessor_getProcessedData(); -MldpReturn_t exampleDataProcessor_init(const int samples, const int dimensions, const int output_length) { - if (samples <= 0 || dimensions <= 0 || outputLength <= 0) { +MldpReturn_t exampleDataProcessor_init(const MlDataProcessorConfig_t* config) { + if (config->samples <= 0 || config->dimensions <= 0 || config->output_length <= 0) { exampleDataProcessor_deinit(); return MLDP_ERROR_CONFIG; } if (accData != NULL) { exampleDataProcessor_deinit(); } - accDataSize = samples * dimensions; + + accDataIndex = 0; + accDimensions = config->dimensions; + accDataSize = config->samples * config->dimensions; + + if (config->output_length != accDataSize) { + exampleDataProcessor_deinit(); + return MLDP_ERROR_CONFIG; + } + accData = (float*)malloc(accDataSize * sizeof(float)); if (accData == NULL) { exampleDataProcessor_deinit(); return MLDP_ERROR_ALLOC; } - accDimensions = dimensions; - accDataIndex = 0; + return MLDP_SUCCESS; }