Loading...
Searching...
No Matches
loom_features.c
Go to the documentation of this file.
43 const size_t offset = IMX500_TENSOR_DIMENSIONS_OFFSET + dimension * IMX500_TENSOR_DIMENSION_BYTES;
102 return count && count <= IMX500_TENSOR_ELEMENT_LIMIT ? 32 + IMX500_TENSOR_INFO_BYTES + count * 4 : 0;
113 for (size_t index = 0; index < bytes; ++index) data[index] = (unsigned char)(value >> (8 * index));
116bool loom_features_pack(unsigned char *record, size_t capacity, const float *values, size_t count,
121 if (!record || !size || capacity < size || !loom_features_valid(values, count, information, information_size)) return false;
128 for (size_t index = 0; index < IMX500_TENSOR_INFO_BYTES; ++index) record[32 + index] = information[index];
136bool loom_features_unpack(const unsigned char *record, size_t size, float *values, size_t capacity,
141 if (!record || size < 32 || !values || !information || !count || !sequence || !sensor_timestamp_ns
144 for (size_t index = 0; index < 8; ++index) if (record[index] != (unsigned char)magic[index]) return false;
148 for (size_t index = 0; index < IMX500_TENSOR_INFO_BYTES; ++index) information[index] = record[32 + index];
150 union { uint32_t bits; float floating; } value = {.bits = feature_u32(record + 32 + IMX500_TENSOR_INFO_BYTES + index * 4)};
156 *sensor_timestamp_ns = (uint64_t)feature_u32(record + 16) | (uint64_t)feature_u32(record + 20) << 32;
static int record(const union dc_shot_union *shot)
Retrieve a point and admit a new observation only when its credit is free.
Definition dipla_camera_backend.c:206
Shared IMX500 tensor-info wire layout and bounded decoding policy.
#define IMX500_TENSOR_DIMENSION_BYTES
Each extent is a little-endian unsigned 16-bit value.
Definition imx500_tensor.h:43
#define IMX500_TENSOR_DIMENSIONS_OFFSET
First shape extent follows the two 32-bit fields.
Definition imx500_tensor.h:41
#define IMX500_TENSOR_COUNT_OFFSET
Little-endian 32-bit tensor count starts after the fixed header.
Definition imx500_tensor.h:31
#define IMX500_TENSOR_ELEMENT_LIMIT
Sensoraia's accepted element budget, not a claim about every RPK model.
Definition imx500_tensor.h:52
#define IMX500_TENSOR_INFO_BYTES
Full accessible metadata required before following record offsets.
Definition imx500_tensor.h:49
#define IMX500_TENSOR_FIRST_RECORD_OFFSET
First record starts after the count, keeping offset arithmetic in one place.
Definition imx500_tensor.h:33
#define IMX500_TENSOR_MAX_COUNT
Metadata reserves sixteen records even when a model uses fewer outputs.
Definition imx500_tensor.h:47
#define IMX500_TENSOR_LENGTH_OFFSET
Element count offset within a record, distinct from its byte length.
Definition imx500_tensor.h:37
#define IMX500_TENSOR_MAX_RANK
Fixed shape capacity in the driver ABI; reject greater ranks before indexing.
Definition imx500_tensor.h:45
#define IMX500_TENSOR_RECORD_BYTES
One record contains length, rank and sixteen 16-bit shape extents.
Definition imx500_tensor.h:35
bool loom_features_pack(unsigned char *record, size_t capacity, const float *values, size_t count, const uint8_t *information, size_t information_size, uint64_t sequence, uint64_t sensor_timestamp_ns)
Pack validated same-exposure shapes, exact uint64 identities and float bits.
Definition loom_features.c:116
size_t loom_features_size(size_t count)
Required bytes for 1..4096 floats, or zero for unsupported counts.
Definition loom_features.c:100
static uint32_t feature_u32(const uint8_t *data)
Read four checked little-endian bytes without an unaligned cast.
Definition loom_features.c:31
static void feature_put(unsigned char *data, uint64_t value, size_t bytes)
Encode one little-endian field in a LOOM evidence record.
Definition loom_features.c:111
bool loom_features_valid(const float *values, size_t count, const uint8_t *information, size_t information_size)
Validate finite features against the shared IMX500 shape metadata.
Definition loom_features.c:47
bool loom_features_unpack(const unsigned char *record, size_t size, float *values, size_t capacity, uint8_t *information, size_t information_size, size_t *count, uint64_t *sequence, uint64_t *sensor_timestamp_ns)
Validate and decode an exact-sized binary record into bounded output.
Definition loom_features.c:136
static uint32_t feature_extent(const uint8_t *record, uint32_t dimension)
Read a bounded shape extent from one driver tensor record.
Definition loom_features.c:41
LOOM-owned bounded feature validation and evidence serialization.