mirror of
https://github.com/firestar5683/StarPilot.git
synced 2026-07-05 13:32:05 +08:00
modeld: cleanup commonmodel (#32618)
cleanup old-commit-hash: 2482ed085ebfd2c09394ce59900348334772d58f
This commit is contained in:
@@ -1,13 +1,10 @@
|
||||
#include "selfdrive/modeld/models/commonmodel.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <cassert>
|
||||
#include <cmath>
|
||||
#include <cstring>
|
||||
|
||||
#include "common/clutil.h"
|
||||
#include "common/mat.h"
|
||||
#include "common/timing.h"
|
||||
|
||||
ModelFrame::ModelFrame(cl_device_id device_id, cl_context context) {
|
||||
input_frames = std::make_unique<float[]>(buf_size);
|
||||
@@ -52,21 +49,6 @@ ModelFrame::~ModelFrame() {
|
||||
CL_CHECK(clReleaseCommandQueue(q));
|
||||
}
|
||||
|
||||
void softmax(const float* input, float* output, size_t len) {
|
||||
const float max_val = *std::max_element(input, input + len);
|
||||
float denominator = 0;
|
||||
for (int i = 0; i < len; i++) {
|
||||
float const v_exp = expf(input[i] - max_val);
|
||||
denominator += v_exp;
|
||||
output[i] = v_exp;
|
||||
}
|
||||
|
||||
const float inv_denominator = 1. / denominator;
|
||||
for (int i = 0; i < len; i++) {
|
||||
output[i] *= inv_denominator;
|
||||
}
|
||||
}
|
||||
|
||||
float sigmoid(float input) {
|
||||
return 1 / (1 + expf(-input));
|
||||
}
|
||||
|
||||
@@ -13,20 +13,11 @@
|
||||
#endif
|
||||
|
||||
#include "common/mat.h"
|
||||
#include "cereal/messaging/messaging.h"
|
||||
#include "selfdrive/modeld/transforms/loadyuv.h"
|
||||
#include "selfdrive/modeld/transforms/transform.h"
|
||||
|
||||
const bool send_raw_pred = getenv("SEND_RAW_PRED") != NULL;
|
||||
|
||||
void softmax(const float* input, float* output, size_t len);
|
||||
float sigmoid(float input);
|
||||
|
||||
template<class T, size_t size>
|
||||
constexpr const kj::ArrayPtr<const T> to_kj_array_ptr(const std::array<T, size> &arr) {
|
||||
return kj::ArrayPtr(arr.data(), arr.size());
|
||||
}
|
||||
|
||||
class ModelFrame {
|
||||
public:
|
||||
ModelFrame(cl_device_id device_id, cl_context context);
|
||||
|
||||
Reference in New Issue
Block a user