Files
dragonpilot/selfdrive/modeld/thneed/compile.cc
George Hotz 59fac9fdc6 Thneed load/save (#19700)
* start thneed load/save

* compiling

* fix loading

* build thneed model in scons

* don't hardcode /data/openpilot

* release files

* those too

* support for loading/saving binary kernels

* save binaries out of json band

* make binary a command line flag to the compiler

* need include assert

* fix shadowed common in SConscript

* cleanup run.h

* hmm, the recurrent buffer wasn't 0ed

* ugh, unique ptr

* remove power constraint, refactor record

* Revert "remove power constraint, refactor record"

This reverts commit bb6fa52db6df59cd9d6420a6f630430e35af8a5e.

* print on thneed stop

* fingers crossed for this one

* recorded

* just curious

* okay okay, pass tests?

* cleanups

* refactor wait

Co-authored-by: Comma Device <device@comma.ai>
Co-authored-by: Adeeb Shihadeh <adeebshihadeh@gmail.com>
2021-01-19 18:08:31 -08:00

35 lines
1022 B
C++

#include <string.h>
#include "thneed.h"
#include "../runners/snpemodel.h"
#define TEMPORAL_SIZE 512
#define DESIRE_LEN 8
#define TRAFFIC_CONVENTION_LEN 2
// TODO: This should probably use SNPE directly.
int main(int argc, char* argv[]) {
#define OUTPUT_SIZE 0x10000
float *output = (float*)calloc(OUTPUT_SIZE, sizeof(float));
SNPEModel mdl(argv[1], output, 0, USE_GPU_RUNTIME);
float state[TEMPORAL_SIZE] = {0};
float desire[DESIRE_LEN] = {0};
float traffic_convention[TRAFFIC_CONVENTION_LEN] = {0};
float *input = (float*)calloc(0x1000000, sizeof(float));;
mdl.addRecurrent(state, TEMPORAL_SIZE);
mdl.addDesire(desire, DESIRE_LEN);
mdl.addTrafficConvention(traffic_convention, TRAFFIC_CONVENTION_LEN);
// first run
printf("************** execute 1 **************\n");
memset(output, 0, OUTPUT_SIZE * sizeof(float));
mdl.execute(input, 0);
// save model
bool save_binaries = (argc > 3) && (strcmp(argv[3], "--binary") == 0);
mdl.thneed->save(argv[2], save_binaries);
return 0;
}