model_publish: use kj::ArrayPtr<const float> raw_pred (#19917)
parent
c22d6e315d
commit
0b7b7241c8
|
@ -185,8 +185,8 @@ int main(int argc, char **argv) {
|
|||
if (run_count < 10) frames_dropped = 0; // let frame drops warm up
|
||||
float frame_drop_ratio = frames_dropped / (1 + frames_dropped);
|
||||
|
||||
const float *raw_pred_ptr = send_raw_pred ? &model.output[0] : nullptr;
|
||||
model_publish(pm, extra.frame_id, frame_id, frame_drop_ratio, model_buf, raw_pred_ptr, extra.timestamp_eof, model_execution_time);
|
||||
model_publish(pm, extra.frame_id, frame_id, frame_drop_ratio, model_buf, extra.timestamp_eof, model_execution_time,
|
||||
kj::ArrayPtr<const float>(model.output.data(), model.output.size()));
|
||||
posenet_publish(pm, extra.frame_id, vipc_dropped_frames, model_buf, extra.timestamp_eof);
|
||||
|
||||
LOGD("model process: %.2fms, from last %.2fms, vipc_frame_id %u, frame_id, %u, frame_drop %.3f", mt2-mt1, mt1-last, extra.frame_id, frame_id, frame_drop_ratio);
|
||||
|
|
|
@ -53,10 +53,10 @@ void model_init(ModelState* s, cl_device_id device_id, cl_context context) {
|
|||
s->input_frames = std::make_unique<float[]>(MODEL_FRAME_SIZE * 2);
|
||||
|
||||
constexpr int output_size = OUTPUT_SIZE + TEMPORAL_SIZE;
|
||||
s->output = std::make_unique<float[]>(output_size);
|
||||
s->output.resize(output_size);
|
||||
|
||||
#if defined(QCOM) || defined(QCOM2)
|
||||
s->m = std::make_unique<ThneedModel>("../../models/supercombo.thneed", &s->output[0], output_size, USE_GPU_RUNTIME);
|
||||
s->m = std::make_unique<ThneedModel>("../../models/supercombo.thneed", s->output[0], output_size, USE_GPU_RUNTIME);
|
||||
#else
|
||||
s->m = std::make_unique<DefaultRunModel>("../../models/supercombo.dlc", &s->output[0], output_size, USE_GPU_RUNTIME);
|
||||
#endif
|
||||
|
@ -262,8 +262,8 @@ void fill_model(cereal::ModelDataV2::Builder &framed, const ModelDataRaw &net_ou
|
|||
}
|
||||
|
||||
void model_publish(PubMaster &pm, uint32_t vipc_frame_id, uint32_t frame_id, float frame_drop,
|
||||
const ModelDataRaw &net_outputs, const float *raw_pred, uint64_t timestamp_eof,
|
||||
float model_execution_time) {
|
||||
const ModelDataRaw &net_outputs, uint64_t timestamp_eof,
|
||||
float model_execution_time, kj::ArrayPtr<const float> raw_pred) {
|
||||
const uint32_t frame_age = (frame_id > vipc_frame_id) ? (frame_id - vipc_frame_id) : 0;
|
||||
MessageBuilder msg;
|
||||
auto framed = msg.initEvent().initModelV2();
|
||||
|
@ -273,7 +273,7 @@ void model_publish(PubMaster &pm, uint32_t vipc_frame_id, uint32_t frame_id, flo
|
|||
framed.setTimestampEof(timestamp_eof);
|
||||
framed.setModelExecutionTime(model_execution_time);
|
||||
if (send_raw_pred) {
|
||||
framed.setRawPred(kj::arrayPtr((const uint8_t *)raw_pred, (OUTPUT_SIZE + TEMPORAL_SIZE) * sizeof(float)));
|
||||
framed.setRawPred(raw_pred.asBytes());
|
||||
}
|
||||
fill_model(framed, net_outputs);
|
||||
pm.send("modelV2", msg);
|
||||
|
|
|
@ -34,7 +34,7 @@ struct ModelDataRaw {
|
|||
|
||||
typedef struct ModelState {
|
||||
ModelFrame frame;
|
||||
std::unique_ptr<float[]> output;
|
||||
std::vector<float> output;
|
||||
std::unique_ptr<float[]> input_frames;
|
||||
std::unique_ptr<RunModel> m;
|
||||
cl_command_queue q;
|
||||
|
@ -53,7 +53,7 @@ ModelDataRaw model_eval_frame(ModelState* s, cl_mem yuv_cl, int width, int heigh
|
|||
void model_free(ModelState* s);
|
||||
void poly_fit(float *in_pts, float *in_stds, float *out);
|
||||
void model_publish(PubMaster &pm, uint32_t vipc_frame_id, uint32_t frame_id, float frame_drop,
|
||||
const ModelDataRaw &net_outputs, const float *raw_pred, uint64_t timestamp_eof,
|
||||
float model_execution_time);
|
||||
const ModelDataRaw &net_outputs, uint64_t timestamp_eof,
|
||||
float model_execution_time, kj::ArrayPtr<const float> raw_pred);
|
||||
void posenet_publish(PubMaster &pm, uint32_t vipc_frame_id, uint32_t vipc_dropped_frames,
|
||||
const ModelDataRaw &net_outputs, uint64_t timestamp_eof);
|
||||
|
|
Loading…
Reference in New Issue