15#ifndef NRF_EDGEAI_OBSV_METRICS_H
16#define NRF_EDGEAI_OBSV_METRICS_H
179#if defined(CONFIG_NRF_EDGEAI_OBSV_METRIC_PROBS_DISTRIBUTION)
194 float bin_edges[CONFIG_NRF_EDGEAI_OBSV_PROBS_DISTRIBUTION_BIN_NUM - 1];
207 uint16_t num_classes;
212_Static_assert(
sizeof(_nrf_obsv_pd_hdr_t) == 4,
213 "Layout changed; update NRF_EDGEAI_OBSV_PD_STORAGE_BYTES and storage accessors");
221#define NRF_EDGEAI_OBSV_PD_STORAGE_BYTES(n_classes) \
222 (sizeof(_nrf_obsv_pd_hdr_t) \
223 + ((size_t)CONFIG_NRF_EDGEAI_OBSV_PROBS_DISTRIBUTION_BIN_NUM - 1U) * sizeof(float) \
224 + (size_t)(n_classes) * CONFIG_NRF_EDGEAI_OBSV_PROBS_DISTRIBUTION_BIN_NUM \
243#if defined(CONFIG_NRF_EDGEAI_OBSV_METRIC_TRANSITION_MATRIX)
255 uint16_t num_classes;
259_Static_assert(
sizeof(_nrf_obsv_tm_hdr_t) == 4,
260 "Layout changed; update NRF_EDGEAI_OBSV_TM_STORAGE_BYTES and storage accessors");
268#define NRF_EDGEAI_OBSV_TM_STORAGE_BYTES(n_classes) \
269 (sizeof(_nrf_obsv_tm_hdr_t) + (size_t)(n_classes) * (size_t)(n_classes) * sizeof(uint32_t))
287#if defined(CONFIG_NRF_EDGEAI_OBSV_METRIC_PREDICTION_SWITCHING_RATE)
299 uint16_t num_classes;
301} _nrf_obsv_psr_hdr_t;
303_Static_assert(
sizeof(_nrf_obsv_psr_hdr_t) == 4,
304 "Layout changed; update NRF_EDGEAI_OBSV_PSR_STORAGE_BYTES and storage accessors");
316#define NRF_EDGEAI_OBSV_PSR_STORAGE_BYTES(n_classes) \
317 (sizeof(_nrf_obsv_psr_hdr_t) + 2U * sizeof(uint32_t))
341#if defined(CONFIG_NRF_EDGEAI_OBSV_METRIC_PROBS_ENTROPY_DIST)
353 uint16_t num_classes;
356} _nrf_obsv_ped_hdr_t;
358_Static_assert(
sizeof(_nrf_obsv_ped_hdr_t) == 4,
359 "Layout changed; update NRF_EDGEAI_OBSV_PED_STORAGE_BYTES and storage accessors");
370#define NRF_EDGEAI_OBSV_PED_STORAGE_BYTES(n_classes) \
371 (sizeof(_nrf_obsv_ped_hdr_t) \
372 + (size_t)CONFIG_NRF_EDGEAI_OBSV_PROBS_ENTROPY_DIST_BIN_NUM * sizeof(uint32_t))
395#if defined(CONFIG_NRF_EDGEAI_OBSV_METRIC_PROBS_TOP2_MARGIN_DIST)
407 uint16_t num_classes;
410} _nrf_obsv_pmd_hdr_t;
412_Static_assert(
sizeof(_nrf_obsv_pmd_hdr_t) == 4,
413 "Layout changed; update NRF_EDGEAI_OBSV_PMD_STORAGE_BYTES and storage accessors");
424#define NRF_EDGEAI_OBSV_PMD_STORAGE_BYTES(n_classes) \
425 (sizeof(_nrf_obsv_pmd_hdr_t) \
426 + (size_t)CONFIG_NRF_EDGEAI_OBSV_PROBS_TOP2_MARGIN_DIST_BIN_NUM * sizeof(uint32_t))
449#if defined(CONFIG_NRF_EDGEAI_OBSV_METRIC_MEL_ENERGY_DESC)
462 uint16_t num_features;
467} _nrf_obsv_med_hdr_t;
469_Static_assert(
sizeof(_nrf_obsv_med_hdr_t) == 12,
470 "Layout changed; update NRF_EDGEAI_OBSV_MED_STORAGE_BYTES and storage accessors");
473#define NRF_EDGEAI_OBSV_MED_NUM_ROWS 4
484#define NRF_EDGEAI_OBSV_MED_STORAGE_BYTES(n_features) \
485 (sizeof(_nrf_obsv_med_hdr_t) \
486 + (size_t)NRF_EDGEAI_OBSV_MED_NUM_ROWS \
487 * CONFIG_NRF_EDGEAI_OBSV_MEL_ENERGY_DESC_BIN_NUM * sizeof(uint32_t))
509 uint16_t n_features);
513#if defined(CONFIG_NRF_EDGEAI_OBSV_METRIC_MEL_SPECTRAL_DESC)
526 uint16_t num_features;
529} _nrf_obsv_msd_hdr_t;
531_Static_assert(
sizeof(_nrf_obsv_msd_hdr_t) == 4,
532 "Layout changed; update NRF_EDGEAI_OBSV_MSD_STORAGE_BYTES and storage accessors");
535#define NRF_EDGEAI_OBSV_MSD_NUM_ROWS 8
546#define NRF_EDGEAI_OBSV_MSD_STORAGE_BYTES(n_features) \
547 (sizeof(_nrf_obsv_msd_hdr_t) \
548 + (size_t)NRF_EDGEAI_OBSV_MSD_NUM_ROWS \
549 * CONFIG_NRF_EDGEAI_OBSV_MEL_SPECTRAL_DESC_BIN_NUM * sizeof(uint32_t))
569 uint16_t n_features);
nrf_edgeai_obsv_source
Data stream a metric consumes.
Definition nrf_edgeai_obsv_metrics.h:70
@ NRF_EDGEAI_OBSV_SOURCE_PROBS
Model output: class-probability vector (length == num_classes).
Definition nrf_edgeai_obsv_metrics.h:72
@ NRF_EDGEAI_OBSV_SOURCE_FEATURES
Model input: extracted feature vector (length supplied per update).
Definition nrf_edgeai_obsv_metrics.h:74
void nrf_edgeai_obsv_metric_pd_create(nrf_edgeai_obsv_metric_t *metric, void *buf, uint16_t n_classes)
Initialize a probability distribution metric using caller-provided storage.
nrf_edgeai_obsv_metric_id
Metric identifier values emitted by each metric's snapshot.
Definition nrf_edgeai_obsv_metrics.h:169
@ NRF_EDGEAI_OBSV_METRIC_ID_PREDICTION_SWITCHING_RATE
Definition nrf_edgeai_obsv_metrics.h:172
@ NRF_EDGEAI_OBSV_METRIC_ID_MEL_SPECTRAL_DESC
Definition nrf_edgeai_obsv_metrics.h:176
@ NRF_EDGEAI_OBSV_METRIC_ID_TRANSITION_MATRIX
Definition nrf_edgeai_obsv_metrics.h:170
@ NRF_EDGEAI_OBSV_METRIC_ID_MEL_ENERGY_DESC
Definition nrf_edgeai_obsv_metrics.h:175
@ NRF_EDGEAI_OBSV_METRIC_ID_PROBS_TOP2_MARGIN_DIST
Definition nrf_edgeai_obsv_metrics.h:174
@ NRF_EDGEAI_OBSV_METRIC_ID_PROBS_DISTRIBUTION
Definition nrf_edgeai_obsv_metrics.h:171
@ NRF_EDGEAI_OBSV_METRIC_ID_PROBS_ENTROPY_DIST
Definition nrf_edgeai_obsv_metrics.h:173
void nrf_edgeai_obsv_metric_tm_create(nrf_edgeai_obsv_metric_t *metric, void *buf, uint16_t n_classes)
Initialize a transition matrix metric using caller-provided storage.
struct nrf_edgeai_obsv_metric_s nrf_edgeai_obsv_metric_t
Observability metric operation table and list node.
void(* snapshot)(nrf_edgeai_obsv_metric_snapshot_t *out, void *priv)
Populates a read-only view over the metric's counters.
Definition nrf_edgeai_obsv_metrics.h:147
struct nrf_edgeai_obsv_metric_s * p_next
Pointer to next metric in context list.
Definition nrf_edgeai_obsv_metrics.h:163
void(* init)(const void *p_cfg, void *priv)
Initializes metric internal state.
Definition nrf_edgeai_obsv_metrics.h:93
enum nrf_edgeai_obsv_source source
Data stream this metric consumes (nrf_edgeai_obsv_source).
Definition nrf_edgeai_obsv_metrics.h:157
void(* finalize)(void *priv)
Finalizes metric state before a snapshot is taken.
Definition nrf_edgeai_obsv_metrics.h:132
void * priv
Opaque per-instance storage; set by the define macro.
Definition nrf_edgeai_obsv_metrics.h:160
void(* clear)(void *priv)
Resets accumulated counters without touching configuration.
Definition nrf_edgeai_obsv_metrics.h:123
void(* update)(const float *p_data, uint16_t n, void *priv)
Consumes one data vector from the metric's source stream.
Definition nrf_edgeai_obsv_metrics.h:111
Observability metric operation table and list node.
Definition nrf_edgeai_obsv_metrics.h:87
uint16_t num_rows
Number of rows in the counter matrix.
Definition nrf_edgeai_obsv_metrics.h:48
uint16_t num_cols
Number of columns in the counter matrix.
Definition nrf_edgeai_obsv_metrics.h:50
uint32_t version
Metric payload version.
Definition nrf_edgeai_obsv_metrics.h:46
uint32_t metric_id
On-wire metric identifier.
Definition nrf_edgeai_obsv_metrics.h:44
const uint32_t * counts
Row-major counter matrix, num_rows x num_cols uint32s.
Definition nrf_edgeai_obsv_metrics.h:57
Read-only view over one metric's accumulated counters.
Definition nrf_edgeai_obsv_metrics.h:42
Runtime configuration for probability distribution metric.
Definition nrf_edgeai_obsv_metrics.h:187