mirror of
https://github.com/firestar5683/StarPilot.git
synced 2026-09-28 02:13:45 +08:00
acd46aa94b
* modeld: Retain pre-20hz drive model support * Method not available anymore on OP * some fixes * Revert "Long planner get accel: new function args (#34288)" * Revert "Fix low-speed allow_throttle behavior in long planner (#33894)" * Revert "long planner: allow throttle reflects usage (#33792)" * Revert "Gate acceleration on model gas press predictions (#33643)" * Reapply "Gate acceleration on model gas press predictions (#33643)" This reverts commit 76b08e37cb8eb94266ad9f6fed80db227e7c3428. * Reapply "long planner: allow throttle reflects usage (#33792)" This reverts commit c75244ca4e9c48084b0205b7c871e1a4e0f4e693. * Reapply "Fix low-speed allow_throttle behavior in long planner (#33894)" This reverts commit b2b7d21b7b685a2785d1beede3d223f0bb954807. * Reapply "Long planner get accel: new function args (#34288)" This reverts commit 74dca2fccf4da59cc8ac62ba9c0ad10ba3fc264b. * don't need * retain snpe * wrong * they're symlinks * remove * put back into VCS * add back * don't include built * Refactor model runner retrieval with caching support Added caching for active model runner type via `ModelRunnerTypeCache` to enhance performance and avoid redundant checks. Introduced a `force_check` flag to bypass the cache when necessary. Updated related code to handle cache clearing during onroad transitions. * Update model runner determination logic with caching fix Enhances `get_active_model_runner` to utilize caching more effectively by ensuring type consistency and updating cache only when necessary. Also updates `is_snpe_model` to pass the `started` state to the runner determination function, improving behavior for dynamic checks. * default to none * enable in next PR * more --------- Co-authored-by: DevTekVE <devtekve@gmail.com>
59 lines
1.4 KiB
C++
59 lines
1.4 KiB
C++
#include "sunnypilot/modeld/runners/thneedmodel.h"
|
|
|
|
#include <string>
|
|
|
|
#include "common/swaglog.h"
|
|
|
|
ThneedModel::ThneedModel(const std::string path, float *_output, size_t _output_size, int runtime, bool luse_tf8, cl_context context) {
|
|
thneed = new Thneed(true, context);
|
|
thneed->load(path.c_str());
|
|
thneed->clexec();
|
|
|
|
recorded = false;
|
|
output = _output;
|
|
}
|
|
|
|
void* ThneedModel::getCLBuffer(const std::string name) {
|
|
int index = -1;
|
|
for (int i = 0; i < inputs.size(); i++) {
|
|
if (name == inputs[i]->name) {
|
|
index = i;
|
|
break;
|
|
}
|
|
}
|
|
|
|
if (index == -1) {
|
|
LOGE("Tried to get CL buffer for input `%s` but no input with this name exists", name.c_str());
|
|
assert(false);
|
|
}
|
|
|
|
if (thneed->input_clmem.size() >= inputs.size()) {
|
|
return &thneed->input_clmem[inputs.size() - index - 1];
|
|
} else {
|
|
return nullptr;
|
|
}
|
|
}
|
|
|
|
void ThneedModel::execute() {
|
|
if (!recorded) {
|
|
thneed->record = true;
|
|
float *input_buffers[inputs.size()];
|
|
for (int i = 0; i < inputs.size(); i++) {
|
|
input_buffers[inputs.size() - i - 1] = inputs[i]->buffer;
|
|
}
|
|
|
|
thneed->copy_inputs(input_buffers);
|
|
thneed->clexec();
|
|
thneed->copy_output(output);
|
|
thneed->stop();
|
|
|
|
recorded = true;
|
|
} else {
|
|
float *input_buffers[inputs.size()];
|
|
for (int i = 0; i < inputs.size(); i++) {
|
|
input_buffers[inputs.size() - i - 1] = inputs[i]->buffer;
|
|
}
|
|
thneed->execute(input_buffers, output);
|
|
}
|
|
}
|