Skip to content
Permalink
Browse files

Run test on Arduino

111ms on ESP32, way to slow. Needs to be <<10ms
  • Loading branch information...
jonnor committed Nov 25, 2018
1 parent c35f080 commit 2c2762dffc88975a3df1b8602e6adc04278ffa91
Showing with 43 additions and 12 deletions.
  1. +35 −6 emlearn.ino
  2. +4 −5 emlearn/eml_benchmark.h
  3. +4 −1 test/bench.c
@@ -1,9 +1,10 @@

#include <eml_trees.h>
#include <eml_benchmark.h>
//#include "emlearn/eml_trees.h"
#include "emlearn/eml_audio.h"
#include "emlearn/eml_benchmark.h"

#include "digits.h"

#if 0

void send_reply(int32_t request, int32_t time_taken,
int32_t prediction, int32_t n_repetitions)
@@ -67,11 +68,39 @@ void parse_predict_reply(char *buffer, float *values, int32_t values_length)
send_reply(request, time_taken, prediction, n_repetitions);
}

#endif

#define N_REPS 10
float input_data[EML_AUDIOFFT_LENGTH] = {0};
float temp_data[EML_AUDIOFFT_LENGTH] = {0};
float times[N_REPS];

EmlError
bench_melspec()
{
const int n_reps = N_REPS;
const EmlAudioMel mel = { 64, 0, 20000, 1024, 44100 };

eml_benchmark_melspectrogram(mel, input_data, temp_data, n_reps, times);
EmlVector t = { times, n_reps };

const float mean = eml_vector_mean(t);
printf("melspec ms: %f\n", mean/1000);
return EmlOk;
}



void setup() {
Serial.begin(115200);

Serial.write("starting\n");
delay(100);
bench_melspec();
Serial.write("benchmarks done\n");
}


void loop() {
const int32_t n_features = 64;
const int32_t bytes_per_number = 20; // 32bit integer, plus separator. But better to have too much
@@ -89,15 +118,15 @@ void loop() {

if (receive_idx >= buffer_length-1) {
receive_idx = 0;
memset(receive_buffer, buffer_length, 0);
memset(receive_buffer, 0, buffer_length);
Serial.println("Error, buffer overflow");
}

if (ch == '\n') {
parse_predict_reply();
//parse_predict_reply();

receive_idx = 0;
memset(receive_buffer, buffer_length, 0);
memset(receive_buffer, 0, buffer_length);
}
}
}
@@ -68,13 +68,12 @@ eml_benchmark_fill(float *values, int features) {


EmlError
eml_benchmark_melspectrogram(EmlAudioMel mel_params, int n_repetitions, float *times)
eml_benchmark_melspectrogram(EmlAudioMel mel_params,
float *input_data, float *temp_data,
int n_repetitions, float *times)
{
// prepare data
// FIXME: unhardcode lengths, pass in from outside
float input_data[EML_AUDIOFFT_LENGTH];
float temp_data[EML_AUDIOFFT_LENGTH];

// FIXME: unhardcode lengths
EmlVector input = { input_data, EML_AUDIOFFT_LENGTH };
EmlVector temp = { temp_data, EML_AUDIOFFT_LENGTH };

@@ -11,9 +11,12 @@ bench_melspec()
const EmlAudioMel mel = { 64, 0, 20000, 1024, 44100 };
float times[n_reps];

float input_data[EML_AUDIOFFT_LENGTH] = {0};
float temp_data[EML_AUDIOFFT_LENGTH] = {0};

eml_benchmark_fill(times, n_reps);

eml_benchmark_melspectrogram(mel, n_reps, times);
eml_benchmark_melspectrogram(mel, input_data, temp_data, n_reps, times);
EmlVector t = { times, n_reps };

const float mean = eml_vector_mean(t);

0 comments on commit 2c2762d

Please sign in to comment.
You can’t perform that action at this time.