Skip to content

Commit

Permalink
Fix missing updates to example_dataprocessor since last refactor.
Browse files Browse the repository at this point in the history
  • Loading branch information
microbit-carlos committed Jun 4, 2024
1 parent cacb46f commit b43acca
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions mlrunner/example_dataprocessor.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down

0 comments on commit b43acca

Please sign in to comment.