thneed_pc.cc 718 B

1234567891011121314151617181920212223242526272829303132
  1. #include "selfdrive/modeld/thneed/thneed.h"
  2. #include <cassert>
  3. #include "common/clutil.h"
  4. #include "common/timing.h"
  5. Thneed::Thneed(bool do_clinit, cl_context _context) {
  6. context = _context;
  7. if (do_clinit) clinit();
  8. char *thneed_debug_env = getenv("THNEED_DEBUG");
  9. debug = (thneed_debug_env != NULL) ? atoi(thneed_debug_env) : 0;
  10. }
  11. void Thneed::execute(float **finputs, float *foutput, bool slow) {
  12. uint64_t tb, te;
  13. if (debug >= 1) tb = nanos_since_boot();
  14. // ****** copy inputs
  15. copy_inputs(finputs);
  16. // ****** run commands
  17. clexec();
  18. // ****** copy outputs
  19. copy_output(foutput);
  20. if (debug >= 1) {
  21. te = nanos_since_boot();
  22. printf("model exec in %lu us\n", (te-tb)/1000);
  23. }
  24. }