Edge AI Add-on API 2.3.0
Loading...
Searching...
No Matches

◆ nrf_edgeai_obsv_metric_cpd_create()

void nrf_edgeai_obsv_metric_cpd_create ( nrf_edgeai_obsv_metric_t * metric,
void * buf,
uint16_t n_classes )

#include <include/nrf_edgeai_obsv/nrf_edgeai_obsv_metrics.h>

Initialize a class predictions distribution metric using caller-provided storage.

Consumes the class-probability stream (NRF_EDGEAI_OBSV_SOURCE_PROBS) and, per inference, feeds two per-class views into one 2*num_classes x bin_num matrix:

  • rows [0, num_classes): the probability distribution — each class's predicted probability binned uniformly over [0, 1]; every inference adds one sample to every class row, so each of these rows sums to the inference count;
  • rows [num_classes, 2*num_classes): the streak distribution — a per-class histogram of how many consecutive inferences the dominant class (argmax) stays that class. A streak is recorded when it ends; up to CONFIG_NRF_EDGEAI_OBSV_CLASS_PRED_DIST_STREAK_TOL consecutive mismatching frames are bridged (not counted into the length, unless they turn out to start a new streak of another class, in which case they count toward that new streak). Streak lengths are binned uniformly over [1, TOP], lengths >= TOP saturating the top bin (CONFIG_NRF_EDGEAI_OBSV_CLASS_PRED_DIST_STREAK_TOP_BIN). These rows do not sum to the inference count.

One bin count (CONFIG_NRF_EDGEAI_OBSV_CLASS_PRED_DIST_BIN_NUM) is shared by both row groups. Merges the former probability distribution and class streak distribution metrics.

The caller allocates a buffer of at least NRF_EDGEAI_OBSV_CPD_STORAGE_BYTES bytes, passes it here, then registers the metric with nrf_edgeai_obsv_core_register().

Parameters
metricMetric descriptor to fill. Must not be NULL.
bufBuffer of at least NRF_EDGEAI_OBSV_CPD_STORAGE_BYTES(n_classes) bytes, aligned to at least sizeof(uint32_t). Must not be NULL.
n_classesNumber of model output classes (> 0).