Loading...
Searching...
No Matches
loom_onnx_features.c
Go to the documentation of this file.
20 * @details Fixed little-endian fields preserve float bits and feature-space identity across PC/ARM64. */
33/** @brief Decode an already-bounds-checked field without host-endian or alignment assumptions. */
39size_t loom_onnx_features_pack(unsigned char *record, size_t capacity, const struct inference_model *model,
49 !((descriptor >= '0' && descriptor <= '9') || (descriptor >= 'a' && descriptor <= 'f'))) return 0;
52 /* Validate every output before touching the destination so a rejected feature set leaves no partial record. */
57 !onnx_tensor_bytes(tensor->type, tensor->dimensions, tensor->rank, &bytes) || bytes != tensor->bytes ||
62 if ((unsigned char)tensor->name[character] < 32 || (unsigned char)tensor->name[character] == 127) return 0;
63 for (size_t axis = 0; axis < tensor->rank; ++axis) if (tensor->dimensions[axis] > UINT32_MAX) return 0;
65 for (size_t value = 0; value < bytes / sizeof(float); ++value) if (!isfinite(values[value])) return 0;
105 if (!record || size < 156 || size > LOOM_ONNX_FEATURE_CAPACITY || memcmp(record, "LOOMOX01", 8)) return false;
107 if (!((record[index] >= '0' && record[index] <= '9') || (record[index] >= 'a' && record[index] <= 'f'))) return false;
108 /* Matching shapes alone cannot make descriptors from different trained feature spaces comparable. */
109 if (model_sha256 && (strnlen(model_sha256, 65) != 64 || memcmp(record + 8, model_sha256, 64))) return false;
110 if (descriptor_sha256 && (strnlen(descriptor_sha256, 65) != 64 || memcmp(record + 72, descriptor_sha256, 64))) return false;
118 for (uint32_t index = 0; index < name; ++index) if (record[offset + index] < 32 || record[offset + index] == 127) return false;
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
Integrity-checked model contracts and independently owned tensor workspaces.
LOOM-owned bounded feature validation and evidence serialization.
static void write_u32(unsigned char *destination, uint32_t value)
Encode an already-bounds-checked field without unaligned integer stores.
Definition loom_onnx_features.c:28
bool loom_onnx_features_valid(const unsigned char *record, size_t size, const char *model_sha256, const char *descriptor_sha256)
Validate the exact binary layout and optionally require the same trained feature space.
Definition loom_onnx_features.c:102
size_t loom_onnx_features_pack(unsigned char *record, size_t capacity, const struct inference_model *model, uint64_t sequence, uint64_t sensor_timestamp_ns)
Encode a complete LOOMOX01 record without fabricating an IMX500 metadata header.
Definition loom_onnx_features.c:39
static uint32_t read_u32(const unsigned char *source)
Decode an already-bounds-checked field without host-endian or alignment assumptions.
Definition loom_onnx_features.c:34
bool loom_onnx_return_vector(const unsigned char *record, size_t size, const char *model_sha256, const char *descriptor_sha256, float values[3])
Decode an explicitly declared two/three-value return-vector record.
Definition loom_onnx_features.c:142
bool onnx_tensor_bytes(enum onnx_element_type type, const int64_t *dimensions, size_t rank, size_t *bytes)
Compute bounded concrete storage, rejecting unsupported types, dynamic extents and overflow.
Definition onnx_session.c:47
Parsed descriptor with self-referencing tensor-name pointers; do not copy after parsing.
Definition inference_model.h:31
struct onnx_tensor outputs[ONNX_TENSOR_LIMIT]
Definition inference_model.h:36
Named concrete tensor view; its aligned backing storage must outlive the session.
Definition onnx_session.h:44