Skip to main content

SimaPluginStaticManifestAbi.h File

Included Headers

#include <gst/gst.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <ev/ev_tensor_abi.h>

Classes Index

structSimaPluginStaticManifestAbiHeader
structSimaPluginStaticManifestHandle
structSimaPluginTensorSpec
structSimaPluginQuantSpec
structSimaPluginSinkRoute
structSimaPluginOutputRoute
structSimaPluginPhysicalBuffer
structSimaPluginLogicalTensor
structSimaPluginLogicalInput
structSimaPluginInputBinding
structSimaPluginProcessCvuStagePayload
structSimaPluginProcessMlaStagePayload
structSimaPluginBoxDecodeStagePayload
structSimaPluginDetessDequantStagePayload
structSimaPluginQuantLikeStagePayload
structSimaPluginStageSpec
structSimaPluginStaticManifestAccessor

Typedefs Index

typedefstruct SimaPluginStaticManifestAbiHeader SimaPluginStaticManifestAbiHeader
typedefstruct SimaPluginStaticManifestAccessor SimaPluginStaticManifestAccessor
typedefstruct SimaPluginStaticManifestHandle SimaPluginStaticManifestHandle
typedefenum SimaPluginManifestLookupStatus SimaPluginManifestLookupStatus
typedefenum SimaPluginStagePayloadKind SimaPluginStagePayloadKind
typedefstruct SimaPluginTensorSpec SimaPluginTensorSpec
typedefstruct SimaPluginQuantSpec SimaPluginQuantSpec
typedefstruct SimaPluginSinkRoute SimaPluginSinkRoute
typedefstruct SimaPluginOutputRoute SimaPluginOutputRoute
typedefenum SimaPluginDeviceKind SimaPluginDeviceKind
typedefenum SimaPluginTensorMaterializationKind SimaPluginTensorMaterializationKind
typedefstruct SimaPluginPhysicalBuffer SimaPluginPhysicalBuffer
typedefstruct SimaPluginLogicalTensor SimaPluginLogicalTensor
typedefstruct SimaPluginLogicalInput SimaPluginLogicalInput
typedefstruct SimaPluginInputBinding SimaPluginInputBinding
typedefenum SimaPluginProcessCvuGraphFamily SimaPluginProcessCvuGraphFamily
typedefenum SimaPluginProcessCvuOutputTransportKind SimaPluginProcessCvuOutputTransportKind
typedefenum SimaPluginProcessCvuOutputSemanticKind SimaPluginProcessCvuOutputSemanticKind
typedefstruct SimaPluginProcessCvuStagePayload SimaPluginProcessCvuStagePayload
typedefstruct SimaPluginProcessMlaStagePayload SimaPluginProcessMlaStagePayload
typedefstruct SimaPluginBoxDecodeStagePayload SimaPluginBoxDecodeStagePayload
typedefstruct SimaPluginDetessDequantStagePayload SimaPluginDetessDequantStagePayload
typedefstruct SimaPluginQuantLikeStagePayload SimaPluginQuantLikeStagePayload
typedefstruct SimaPluginStageSpec SimaPluginStageSpec

Enumerations Index

enumSimaPluginManifestLookupStatus { ... }
enumSimaPluginStagePayloadKind { ... }
enumSimaPluginDeviceKind { ... }
enumSimaPluginTensorMaterializationKind { ... }
enumSimaPluginProcessCvuGraphFamily { ... }
enumSimaPluginProcessCvuOutputTransportKind { ... }
enumSimaPluginProcessCvuOutputSemanticKind { ... }

Functions Index

static const gchar *sima_plugin_manifest_lookup_status_name (SimaPluginManifestLookupStatus status)
static const gchar *sima_plugin_manifest_lookup_status_error_message (SimaPluginManifestLookupStatus status)
static const gchar *sima_plugin_manifest_lookup_status_missing_field (SimaPluginManifestLookupStatus status)
static gpointersima_plugin_static_manifest_handle_boxed_copy (gpointer boxed)
static voidsima_plugin_static_manifest_handle_boxed_free (gpointer boxed)
static GTypesima_plugin_static_manifest_handle_get_type (void)
static voidsima_plugin_manifest_set_lookup_status (SimaPluginManifestLookupStatus *status, SimaPluginManifestLookupStatus value)
static gbooleansima_plugin_manifest_context_matches (const GstContext *context)
static const GstStructure *sima_plugin_manifest_context_structure (const GstContext *context)
static const SimaPluginStaticManifestHandle *sima_plugin_manifest_context_handle (const GstContext *context)
static const SimaPluginStaticManifestAccessor *sima_plugin_manifest_context_accessor_checked (const GstContext *context, SimaPluginManifestLookupStatus *status)
static const SimaPluginStaticManifestAccessor *sima_plugin_manifest_context_accessor (const GstContext *context)
static const gchar *sima_plugin_manifest_stage_key (const SimaPluginStageSpec *stage)
static gbooleansima_plugin_manifest_stage_matches_payload_kind (const SimaPluginStageSpec *stage, SimaPluginStagePayloadKind expected_payload_kind)
static const SimaPluginStageSpec *sima_plugin_manifest_stage_by_element_name (const SimaPluginStaticManifestAccessor *accessor, const gchar *element_name)
static const SimaPluginStageSpec *sima_plugin_manifest_stage_by_logical_id (const SimaPluginStaticManifestAccessor *accessor, const gchar *logical_stage_id)
static const SimaPluginStageSpec *sima_plugin_manifest_stage_lookup (const SimaPluginStaticManifestAccessor *accessor, const gchar *stage_id_or_name, const gchar *element_name_fallback)
static const SimaPluginStageSpec *sima_plugin_manifest_stage_lookup_typed (const SimaPluginStaticManifestAccessor *accessor, const gchar *stage_id_or_name, const gchar *element_name_fallback, SimaPluginStagePayloadKind expected_payload_kind)
static const SimaPluginStageSpec *sima_plugin_manifest_context_stage_lookup_typed_checked (const GstContext *context, const gchar *stage_id_or_name, const gchar *element_name_fallback, SimaPluginStagePayloadKind expected_payload_kind, SimaPluginManifestLookupStatus *status)
static const SimaPluginStageSpec *sima_plugin_manifest_context_stage_lookup_typed (const GstContext *context, const gchar *stage_id_or_name, const gchar *element_name_fallback, SimaPluginStagePayloadKind expected_payload_kind)
static const gchar *sima_plugin_manifest_stage_name_from_id (const SimaPluginStageSpec *stage, gint name_id)
static gintsima_plugin_stage_output_route_physical_index (const SimaPluginStageSpec *stage, gint logical_index, gint output_slot)
static gintsima_plugin_stage_output_route_logical_index (const SimaPluginStageSpec *stage, gint output_slot, const gchar *cm_output_name, const gchar *segment_name)

Macro Definitions Index

#defineSIMA_PLUGIN_STATIC_MANIFEST_CONTEXT_TYPE   "sima.model.manifest"
#defineSIMA_PLUGIN_STATIC_MANIFEST_ABI_VERSION   ((guint)19)
#defineSIMA_PLUGIN_STATIC_MANIFEST_KEY_SESSION_ID   "session_id"
#defineSIMA_PLUGIN_STATIC_MANIFEST_KEY_MODEL_ID   "model_id"
#defineSIMA_PLUGIN_STATIC_MANIFEST_KEY_HANDLE   "manifest_handle"

Typedefs

SimaPluginBoxDecodeStagePayload

typedef struct SimaPluginBoxDecodeStagePayload SimaPluginBoxDecodeStagePayload

Definition at line 333 of file SimaPluginStaticManifestAbi.h.

SimaPluginDetessDequantStagePayload

typedef struct SimaPluginDetessDequantStagePayload SimaPluginDetessDequantStagePayload

Definition at line 337 of file SimaPluginStaticManifestAbi.h.

SimaPluginDeviceKind

typedef enum SimaPluginDeviceKind SimaPluginDeviceKind

Definition at line 117 of file SimaPluginStaticManifestAbi.h.

SimaPluginInputBinding

typedef struct SimaPluginInputBinding SimaPluginInputBinding

Definition at line 200 of file SimaPluginStaticManifestAbi.h.

SimaPluginLogicalInput

typedef struct SimaPluginLogicalInput SimaPluginLogicalInput

Definition at line 183 of file SimaPluginStaticManifestAbi.h.

SimaPluginLogicalTensor

typedef struct SimaPluginLogicalTensor SimaPluginLogicalTensor

Definition at line 160 of file SimaPluginStaticManifestAbi.h.

SimaPluginManifestLookupStatus

typedef enum SimaPluginManifestLookupStatus SimaPluginManifestLookupStatus

Definition at line 60 of file SimaPluginStaticManifestAbi.h.

SimaPluginOutputRoute

typedef struct SimaPluginOutputRoute SimaPluginOutputRoute

Definition at line 110 of file SimaPluginStaticManifestAbi.h.

SimaPluginPhysicalBuffer

typedef struct SimaPluginPhysicalBuffer SimaPluginPhysicalBuffer

Definition at line 136 of file SimaPluginStaticManifestAbi.h.

SimaPluginProcessCvuGraphFamily

typedef enum SimaPluginProcessCvuGraphFamily SimaPluginProcessCvuGraphFamily

Definition at line 214 of file SimaPluginStaticManifestAbi.h.

SimaPluginProcessCvuOutputSemanticKind

typedef enum SimaPluginProcessCvuOutputSemanticKind SimaPluginProcessCvuOutputSemanticKind

Definition at line 229 of file SimaPluginStaticManifestAbi.h.

SimaPluginProcessCvuOutputTransportKind

typedef enum SimaPluginProcessCvuOutputTransportKind SimaPluginProcessCvuOutputTransportKind

Definition at line 220 of file SimaPluginStaticManifestAbi.h.

SimaPluginProcessCvuStagePayload

typedef struct SimaPluginProcessCvuStagePayload SimaPluginProcessCvuStagePayload

Definition at line 306 of file SimaPluginStaticManifestAbi.h.

SimaPluginProcessMlaStagePayload

typedef struct SimaPluginProcessMlaStagePayload SimaPluginProcessMlaStagePayload

Definition at line 316 of file SimaPluginStaticManifestAbi.h.

SimaPluginQuantLikeStagePayload

typedef struct SimaPluginQuantLikeStagePayload SimaPluginQuantLikeStagePayload

Definition at line 341 of file SimaPluginStaticManifestAbi.h.

SimaPluginQuantSpec

typedef struct SimaPluginQuantSpec SimaPluginQuantSpec

Definition at line 94 of file SimaPluginStaticManifestAbi.h.

SimaPluginSinkRoute

typedef struct SimaPluginSinkRoute SimaPluginSinkRoute

Definition at line 104 of file SimaPluginStaticManifestAbi.h.

SimaPluginStagePayloadKind

typedef enum SimaPluginStagePayloadKind SimaPluginStagePayloadKind

Definition at line 72 of file SimaPluginStaticManifestAbi.h.

SimaPluginStageSpec

typedef struct SimaPluginStageSpec SimaPluginStageSpec

Definition at line 381 of file SimaPluginStaticManifestAbi.h.

SimaPluginStaticManifestAbiHeader

typedef struct SimaPluginStaticManifestAbiHeader SimaPluginStaticManifestAbiHeader

Definition at line 38 of file SimaPluginStaticManifestAbi.h.

SimaPluginStaticManifestAccessor

typedef struct SimaPluginStaticManifestAccessor SimaPluginStaticManifestAccessor

SimaPluginStaticManifestHandle

typedef struct SimaPluginStaticManifestHandle SimaPluginStaticManifestHandle

Definition at line 48 of file SimaPluginStaticManifestAbi.h.

SimaPluginTensorMaterializationKind

typedef enum SimaPluginTensorMaterializationKind SimaPluginTensorMaterializationKind

Definition at line 124 of file SimaPluginStaticManifestAbi.h.

SimaPluginTensorSpec

typedef struct SimaPluginTensorSpec SimaPluginTensorSpec

Definition at line 85 of file SimaPluginStaticManifestAbi.h.

Enumerations

SimaPluginDeviceKind

enum SimaPluginDeviceKind
Enumeration values
SIMA_PLUGIN_DEVICE_KIND_UNKNOWN (= 0)
SIMA_PLUGIN_DEVICE_KIND_CPU (= 1)
SIMA_PLUGIN_DEVICE_KIND_MLA (= 2)
SIMA_PLUGIN_DEVICE_KIND_EVXX (= 3)

Definition at line 112 of file SimaPluginStaticManifestAbi.h.

SimaPluginManifestLookupStatus

enum SimaPluginManifestLookupStatus
Enumeration values
SIMA_PLUGIN_MANIFEST_LOOKUP_STATUS_OK (= 0)
SIMA_PLUGIN_MANIFEST_LOOKUP_STATUS_NO_CONTEXT (= 1)
SIMA_PLUGIN_MANIFEST_LOOKUP_STATUS_WRONG_CONTEXT_TYPE (= 2)
SIMA_PLUGIN_MANIFEST_LOOKUP_STATUS_MISSING_HANDLE (= 3)
SIMA_PLUGIN_MANIFEST_LOOKUP_STATUS_HANDLE_ABI_MISMATCH (= 4)
SIMA_PLUGIN_MANIFEST_LOOKUP_STATUS_HANDLE_ACCESSOR_NULL (= 5)
SIMA_PLUGIN_MANIFEST_LOOKUP_STATUS_HANDLE_CALLBACK_MISSING (= 6)
SIMA_PLUGIN_MANIFEST_LOOKUP_STATUS_STAGE_NOT_FOUND (= 7)
SIMA_PLUGIN_MANIFEST_LOOKUP_STATUS_PAYLOAD_KIND_MISMATCH (= 8)

Definition at line 50 of file SimaPluginStaticManifestAbi.h.

SimaPluginProcessCvuGraphFamily

enum SimaPluginProcessCvuGraphFamily
Enumeration values
SIMA_PLUGIN_PROCESSCVU_GRAPH_FAMILY_UNKNOWN (= 0)
SIMA_PLUGIN_PROCESSCVU_GRAPH_FAMILY_PREPROC (= 1)
SIMA_PLUGIN_PROCESSCVU_GRAPH_FAMILY_QUANT (= 2)
SIMA_PLUGIN_PROCESSCVU_GRAPH_FAMILY_TESS (= 3)
SIMA_PLUGIN_PROCESSCVU_GRAPH_FAMILY_QUANTTESS (= 4)
SIMA_PLUGIN_PROCESSCVU_GRAPH_FAMILY_CASTTESS (= 5)
SIMA_PLUGIN_PROCESSCVU_GRAPH_FAMILY_DETESS (= 6)
SIMA_PLUGIN_PROCESSCVU_GRAPH_FAMILY_DEQUANT (= 7)
SIMA_PLUGIN_PROCESSCVU_GRAPH_FAMILY_DETESSCAST (= 8)
SIMA_PLUGIN_PROCESSCVU_GRAPH_FAMILY_DETESSDEQUANT (= 9)
SIMA_PLUGIN_PROCESSCVU_GRAPH_FAMILY_CAST (= 10)

Definition at line 202 of file SimaPluginStaticManifestAbi.h.

SimaPluginProcessCvuOutputSemanticKind

enum SimaPluginProcessCvuOutputSemanticKind
Enumeration values
SIMA_PLUGIN_PROCESSCVU_OUTPUT_SEMANTIC_UNKNOWN (= 0)
SIMA_PLUGIN_PROCESSCVU_OUTPUT_SEMANTIC_IMAGE (= 1)
SIMA_PLUGIN_PROCESSCVU_OUTPUT_SEMANTIC_TESSELLATED_IMAGE (= 2)
SIMA_PLUGIN_PROCESSCVU_OUTPUT_SEMANTIC_QUANTIZED_TENSOR (= 3)
SIMA_PLUGIN_PROCESSCVU_OUTPUT_SEMANTIC_QUANTTESS_TENSOR (= 4)
SIMA_PLUGIN_PROCESSCVU_OUTPUT_SEMANTIC_TENSOR (= 5)

Definition at line 222 of file SimaPluginStaticManifestAbi.h.

SimaPluginProcessCvuOutputTransportKind

enum SimaPluginProcessCvuOutputTransportKind
Enumeration values
SIMA_PLUGIN_PROCESSCVU_OUTPUT_TRANSPORT_UNKNOWN (= 0)
SIMA_PLUGIN_PROCESSCVU_OUTPUT_TRANSPORT_DENSE (= 1)
SIMA_PLUGIN_PROCESSCVU_OUTPUT_TRANSPORT_PACKED (= 2)

Definition at line 216 of file SimaPluginStaticManifestAbi.h.

SimaPluginStagePayloadKind

enum SimaPluginStagePayloadKind
Enumeration values
SIMA_PLUGIN_STAGE_PAYLOAD_NONE (= 0)
SIMA_PLUGIN_STAGE_PAYLOAD_PROCESSCVU (= 1)
SIMA_PLUGIN_STAGE_PAYLOAD_PROCESSMLA (= 2)
SIMA_PLUGIN_STAGE_PAYLOAD_BOXDECODE (= 3)
SIMA_PLUGIN_STAGE_PAYLOAD_DETESSDEQUANT (= 4)
SIMA_PLUGIN_STAGE_PAYLOAD_QUANT (= 5)
SIMA_PLUGIN_STAGE_PAYLOAD_TESS (= 6)
SIMA_PLUGIN_STAGE_PAYLOAD_DEQUANT (= 7)
SIMA_PLUGIN_STAGE_PAYLOAD_QUANTTESS (= 8)

Definition at line 62 of file SimaPluginStaticManifestAbi.h.

SimaPluginTensorMaterializationKind

enum SimaPluginTensorMaterializationKind
Enumeration values
SIMA_PLUGIN_TENSOR_MATERIALIZATION_UNKNOWN (= 0)
SIMA_PLUGIN_TENSOR_MATERIALIZATION_DIRECT (= 1)
SIMA_PLUGIN_TENSOR_MATERIALIZATION_OFFSET_VIEW (= 2)
SIMA_PLUGIN_TENSOR_MATERIALIZATION_BF16_LANE_SPLIT_REPACK (= 3)

Definition at line 119 of file SimaPluginStaticManifestAbi.h.

Functions

sima_plugin_manifest_context_accessor()

const SimaPluginStaticManifestAccessor * sima_plugin_manifest_context_accessor (const GstContext * context)
inline static

Definition at line 608 of file SimaPluginStaticManifestAbi.h.

608sima_plugin_manifest_context_accessor(const GstContext* context) {
609 return sima_plugin_manifest_context_accessor_checked(context, NULL);
610}

sima_plugin_manifest_context_accessor_checked()

const SimaPluginStaticManifestAccessor * sima_plugin_manifest_context_accessor_checked (const GstContext * context, SimaPluginManifestLookupStatus * status)
inline static

Definition at line 545 of file SimaPluginStaticManifestAbi.h.

545sima_plugin_manifest_context_accessor_checked(const GstContext* context,
547 const bool debug_manifest_context = ([]() -> bool {
548 const char* raw = getenv("SIMA_MANIFEST_CONTEXT_DEBUG");
549 return raw && *raw && strcmp(raw, "0") != 0;
550 })();
551 if (!context) {
552 sima_plugin_manifest_set_lookup_status(status, SIMA_PLUGIN_MANIFEST_LOOKUP_STATUS_NO_CONTEXT);
553 return NULL;
554 }
555 if (!sima_plugin_manifest_context_matches(context)) {
556 sima_plugin_manifest_set_lookup_status(status,
558 return NULL;
559 }
560 const auto* handle = sima_plugin_manifest_context_handle(context);
561 if (!handle) {
562 sima_plugin_manifest_set_lookup_status(status,
564 return NULL;
565 }
566 if (handle->abi_version != SIMA_PLUGIN_STATIC_MANIFEST_ABI_VERSION) {
567 if (debug_manifest_context) {
568 fprintf(stderr,
569 "[manifest-context-debug] lookup=handle_abi_mismatch context=%p "
570 "handle=%p handle_abi=%u expected_abi=%u user_data=%p\n",
571 static_cast<const void*>(context), static_cast<const void*>(handle),
572 static_cast<unsigned>(handle->abi_version),
573 static_cast<unsigned>(SIMA_PLUGIN_STATIC_MANIFEST_ABI_VERSION), handle->user_data);
574 }
575 sima_plugin_manifest_set_lookup_status(status,
577 return NULL;
578 }
579 if (!handle->ref || !handle->unref || !handle->accessor) {
580 sima_plugin_manifest_set_lookup_status(
582 return NULL;
583 }
584 const auto* accessor = handle->accessor(handle->user_data);
585 if (!accessor) {
586 sima_plugin_manifest_set_lookup_status(status,
588 return NULL;
589 }
590 if (accessor->abi_version != SIMA_PLUGIN_STATIC_MANIFEST_ABI_VERSION) {
591 if (debug_manifest_context) {
592 fprintf(stderr,
593 "[manifest-context-debug] lookup=accessor_abi_mismatch context=%p "
594 "handle=%p accessor=%p accessor_abi=%u expected_abi=%u user_data=%p\n",
595 static_cast<const void*>(context), static_cast<const void*>(handle),
596 static_cast<const void*>(accessor), static_cast<unsigned>(accessor->abi_version),
597 static_cast<unsigned>(SIMA_PLUGIN_STATIC_MANIFEST_ABI_VERSION), accessor->user_data);
598 }
599 sima_plugin_manifest_set_lookup_status(status,
601 return NULL;
602 }
603 sima_plugin_manifest_set_lookup_status(status, SIMA_PLUGIN_MANIFEST_LOOKUP_STATUS_OK);
604 return accessor;
605}

sima_plugin_manifest_context_handle()

const SimaPluginStaticManifestHandle * sima_plugin_manifest_context_handle (const GstContext * context)
inline static

Definition at line 526 of file SimaPluginStaticManifestAbi.h.

526sima_plugin_manifest_context_handle(const GstContext* context) {
527 const GstStructure* structure = sima_plugin_manifest_context_structure(context);
528 if (!structure) {
529 return NULL;
530 }
531 const GValue* handle_val =
532 gst_structure_get_value(structure, SIMA_PLUGIN_STATIC_MANIFEST_KEY_HANDLE);
533 if (!handle_val || G_VALUE_TYPE(handle_val) != sima_plugin_static_manifest_handle_get_type()) {
534 return NULL;
535 }
536 const auto* handle =
537 static_cast<const SimaPluginStaticManifestHandle*>(g_value_get_boxed(handle_val));
538 if (!handle) {
539 return NULL;
540 }
541 return handle;
542}

sima_plugin_manifest_context_matches()

gboolean sima_plugin_manifest_context_matches (const GstContext * context)
inline static

Definition at line 509 of file SimaPluginStaticManifestAbi.h.

509static inline gboolean sima_plugin_manifest_context_matches(const GstContext* context) {
510 if (!context) {
511 return FALSE;
512 }
513 return g_strcmp0(gst_context_get_context_type(context),
515}

sima_plugin_manifest_context_stage_lookup_typed()

const SimaPluginStageSpec * sima_plugin_manifest_context_stage_lookup_typed (const GstContext * context, const gchar * stage_id_or_name, const gchar * element_name_fallback, SimaPluginStagePayloadKind expected_payload_kind)
inline static

Definition at line 686 of file SimaPluginStaticManifestAbi.h.

686static inline const SimaPluginStageSpec* sima_plugin_manifest_context_stage_lookup_typed(
687 const GstContext* context, const gchar* stage_id_or_name, const gchar* element_name_fallback,
688 SimaPluginStagePayloadKind expected_payload_kind) {
689 return sima_plugin_manifest_context_stage_lookup_typed_checked(
690 context, stage_id_or_name, element_name_fallback, expected_payload_kind, NULL);
691}

sima_plugin_manifest_context_stage_lookup_typed_checked()

const SimaPluginStageSpec * sima_plugin_manifest_context_stage_lookup_typed_checked (const GstContext * context, const gchar * stage_id_or_name, const gchar * element_name_fallback, SimaPluginStagePayloadKind expected_payload_kind, SimaPluginManifestLookupStatus * status)
inline static

Definition at line 693 of file SimaPluginStaticManifestAbi.h.

693static inline const SimaPluginStageSpec* sima_plugin_manifest_context_stage_lookup_typed_checked(
694 const GstContext* context, const gchar* stage_id_or_name, const gchar* element_name_fallback,
695 SimaPluginStagePayloadKind expected_payload_kind, SimaPluginManifestLookupStatus* status) {
696 const SimaPluginStaticManifestAccessor* accessor =
697 sima_plugin_manifest_context_accessor_checked(context, status);
698 if (!accessor) {
699 return NULL;
700 }
701 const SimaPluginStageSpec* stage =
702 sima_plugin_manifest_stage_lookup(accessor, stage_id_or_name, element_name_fallback);
703 if (!stage) {
704 sima_plugin_manifest_set_lookup_status(status,
706 return NULL;
707 }
708 if (!sima_plugin_manifest_stage_matches_payload_kind(stage, expected_payload_kind)) {
709 sima_plugin_manifest_set_lookup_status(
711 return NULL;
712 }
713 sima_plugin_manifest_set_lookup_status(status, SIMA_PLUGIN_MANIFEST_LOOKUP_STATUS_OK);
714 return stage;
715}

sima_plugin_manifest_context_structure()

const GstStructure * sima_plugin_manifest_context_structure (const GstContext * context)
inline static

Definition at line 518 of file SimaPluginStaticManifestAbi.h.

518sima_plugin_manifest_context_structure(const GstContext* context) {
519 if (!sima_plugin_manifest_context_matches(context)) {
520 return NULL;
521 }
522 return gst_context_get_structure(context);
523}

sima_plugin_manifest_lookup_status_error_message()

const gchar * sima_plugin_manifest_lookup_status_error_message (SimaPluginManifestLookupStatus status)
inline static

Definition at line 432 of file SimaPluginStaticManifestAbi.h.

432sima_plugin_manifest_lookup_status_error_message(SimaPluginManifestLookupStatus status) {
433 switch (status) {
435 return "Missing sima.model.manifest context";
437 return "Wrong sima.model.manifest context type";
439 return "Missing manifest handle in manifest context";
441 return "Manifest handle ABI mismatch";
444 return "Manifest accessor unavailable";
446 return "Missing stage entry in manifest context";
448 return "Manifest payload kind mismatch";
450 default:
451 return "Manifest lookup status OK";
452 }
453}

sima_plugin_manifest_lookup_status_missing_field()

const gchar * sima_plugin_manifest_lookup_status_missing_field (SimaPluginManifestLookupStatus status)
inline static

Definition at line 456 of file SimaPluginStaticManifestAbi.h.

456sima_plugin_manifest_lookup_status_missing_field(SimaPluginManifestLookupStatus status) {
457 switch (status) {
460 return "manifest_context";
463 return "manifest_handle";
466 return "manifest_accessor";
468 return "stage_spec";
470 return "typed_stage_payload";
472 default:
473 return "none";
474 }
475}

sima_plugin_manifest_lookup_status_name()

const gchar * sima_plugin_manifest_lookup_status_name (SimaPluginManifestLookupStatus status)
inline static

Definition at line 406 of file SimaPluginStaticManifestAbi.h.

406sima_plugin_manifest_lookup_status_name(SimaPluginManifestLookupStatus status) {
407 switch (status) {
409 return "ok";
411 return "no_context";
413 return "wrong_context_type";
415 return "missing_handle";
417 return "handle_abi_mismatch";
419 return "handle_accessor_null";
421 return "handle_callback_missing";
423 return "stage_not_found";
425 return "payload_kind_mismatch";
426 default:
427 return "unknown";
428 }
429}

sima_plugin_manifest_set_lookup_status()

void sima_plugin_manifest_set_lookup_status (SimaPluginManifestLookupStatus * status, SimaPluginManifestLookupStatus value)
inline static

Definition at line 502 of file SimaPluginStaticManifestAbi.h.

502static inline void sima_plugin_manifest_set_lookup_status(SimaPluginManifestLookupStatus* status,
504 if (status) {
505 *status = value;
506 }
507}

sima_plugin_manifest_stage_by_element_name()

const SimaPluginStageSpec * sima_plugin_manifest_stage_by_element_name (const SimaPluginStaticManifestAccessor * accessor, const gchar * element_name)
inline static

Definition at line 636 of file SimaPluginStaticManifestAbi.h.

636sima_plugin_manifest_stage_by_element_name(const SimaPluginStaticManifestAccessor* accessor,
637 const gchar* element_name) {
638 if (!accessor || !accessor->stage_by_element_name || !element_name || !*element_name) {
639 return NULL;
640 }
641 return accessor->stage_by_element_name(accessor->user_data, element_name);
642}

sima_plugin_manifest_stage_by_logical_id()

const SimaPluginStageSpec * sima_plugin_manifest_stage_by_logical_id (const SimaPluginStaticManifestAccessor * accessor, const gchar * logical_stage_id)
inline static

Definition at line 645 of file SimaPluginStaticManifestAbi.h.

645sima_plugin_manifest_stage_by_logical_id(const SimaPluginStaticManifestAccessor* accessor,
646 const gchar* logical_stage_id) {
647 if (!accessor || !accessor->stage_by_logical_stage_id || !logical_stage_id ||
648 !*logical_stage_id) {
649 return NULL;
650 }
651 return accessor->stage_by_logical_stage_id(accessor->user_data, logical_stage_id);
652}

sima_plugin_manifest_stage_key()

const gchar * sima_plugin_manifest_stage_key (const SimaPluginStageSpec * stage)
inline static

Definition at line 612 of file SimaPluginStaticManifestAbi.h.

612static inline const gchar* sima_plugin_manifest_stage_key(const SimaPluginStageSpec* stage) {
613 if (!stage) {
614 return NULL;
615 }
616 if (stage->logical_stage_id && *stage->logical_stage_id) {
617 return stage->logical_stage_id;
618 }
619 if (stage->element_name && *stage->element_name) {
620 return stage->element_name;
621 }
622 return NULL;
623}

sima_plugin_manifest_stage_lookup()

const SimaPluginStageSpec * sima_plugin_manifest_stage_lookup (const SimaPluginStaticManifestAccessor * accessor, const gchar * stage_id_or_name, const gchar * element_name_fallback)
inline static

Definition at line 655 of file SimaPluginStaticManifestAbi.h.

655sima_plugin_manifest_stage_lookup(const SimaPluginStaticManifestAccessor* accessor,
656 const gchar* stage_id_or_name,
657 const gchar* element_name_fallback) {
658 const SimaPluginStageSpec* out = NULL;
659 if (stage_id_or_name && *stage_id_or_name) {
660 out = sima_plugin_manifest_stage_by_logical_id(accessor, stage_id_or_name);
661 if (!out) {
662 out = sima_plugin_manifest_stage_by_element_name(accessor, stage_id_or_name);
663 }
664 }
665 if (!out && element_name_fallback && *element_name_fallback) {
666 out = sima_plugin_manifest_stage_by_element_name(accessor, element_name_fallback);
667 }
668 return out;
669}

sima_plugin_manifest_stage_lookup_typed()

const SimaPluginStageSpec * sima_plugin_manifest_stage_lookup_typed (const SimaPluginStaticManifestAccessor * accessor, const gchar * stage_id_or_name, const gchar * element_name_fallback, SimaPluginStagePayloadKind expected_payload_kind)
inline static

Definition at line 671 of file SimaPluginStaticManifestAbi.h.

671static inline const SimaPluginStageSpec* sima_plugin_manifest_stage_lookup_typed(
672 const SimaPluginStaticManifestAccessor* accessor, const gchar* stage_id_or_name,
673 const gchar* element_name_fallback, SimaPluginStagePayloadKind expected_payload_kind) {
674 const SimaPluginStageSpec* stage =
675 sima_plugin_manifest_stage_lookup(accessor, stage_id_or_name, element_name_fallback);
676 if (!sima_plugin_manifest_stage_matches_payload_kind(stage, expected_payload_kind)) {
677 return NULL;
678 }
679 return stage;
680}

sima_plugin_manifest_stage_matches_payload_kind()

gboolean sima_plugin_manifest_stage_matches_payload_kind (const SimaPluginStageSpec * stage, SimaPluginStagePayloadKind expected_payload_kind)
inline static

Definition at line 626 of file SimaPluginStaticManifestAbi.h.

626sima_plugin_manifest_stage_matches_payload_kind(const SimaPluginStageSpec* stage,
627 SimaPluginStagePayloadKind expected_payload_kind) {
628 if (!stage) {
629 return FALSE;
630 }
631 return expected_payload_kind == SIMA_PLUGIN_STAGE_PAYLOAD_NONE ||
632 stage->payload_kind == expected_payload_kind;
633}

sima_plugin_manifest_stage_name_from_id()

const gchar * sima_plugin_manifest_stage_name_from_id (const SimaPluginStageSpec * stage, gint name_id)
inline static

Definition at line 717 of file SimaPluginStaticManifestAbi.h.

717static inline const gchar* sima_plugin_manifest_stage_name_from_id(const SimaPluginStageSpec* stage,
718 gint name_id) {
719 if (!stage || !stage->name_table || name_id < 0 ||
720 static_cast<guint>(name_id) >= stage->name_table_len) {
721 return NULL;
722 }
723 return stage->name_table[name_id];
724}

sima_plugin_stage_output_route_logical_index()

gint sima_plugin_stage_output_route_logical_index (const SimaPluginStageSpec * stage, gint output_slot, const gchar * cm_output_name, const gchar * segment_name)
inline static

Definition at line 744 of file SimaPluginStaticManifestAbi.h.

744static inline gint sima_plugin_stage_output_route_logical_index(const SimaPluginStageSpec* stage,
745 gint output_slot,
746 const gchar* cm_output_name,
747 const gchar* segment_name) {
748 if (!stage || !stage->logical_outputs || stage->logical_outputs_len == 0U) {
749 return -1;
750 }
751
752 if (cm_output_name && *cm_output_name) {
753 for (guint i = 0; i < stage->logical_outputs_len; ++i) {
754 const SimaPluginLogicalTensor* logical = &stage->logical_outputs[i];
755 if (logical->backend_name && g_strcmp0(logical->backend_name, cm_output_name) == 0) {
756 return logical->logical_index;
757 }
758 }
759 }
760
761 if (segment_name && *segment_name) {
762 for (guint i = 0; i < stage->logical_outputs_len; ++i) {
763 const SimaPluginLogicalTensor* logical = &stage->logical_outputs[i];
764 if (logical->segment_name && g_strcmp0(logical->segment_name, segment_name) == 0) {
765 return logical->logical_index;
766 }
767 }
768 }
769
770 if (output_slot >= 0) {
771 for (guint i = 0; i < stage->logical_outputs_len; ++i) {
772 const SimaPluginLogicalTensor* logical = &stage->logical_outputs[i];
773 if (logical->output_slot == output_slot) {
774 return logical->logical_index;
775 }
776 }
777 }
778
779 return -1;
780}

sima_plugin_stage_output_route_physical_index()

gint sima_plugin_stage_output_route_physical_index (const SimaPluginStageSpec * stage, gint logical_index, gint output_slot)
inline static

Definition at line 726 of file SimaPluginStaticManifestAbi.h.

726static inline gint sima_plugin_stage_output_route_physical_index(const SimaPluginStageSpec* stage,
727 gint logical_index,
728 gint output_slot) {
729 if (!stage || !stage->logical_outputs || stage->logical_outputs_len == 0U) {
730 return -1;
731 }
732 for (guint i = 0; i < stage->logical_outputs_len; ++i) {
733 const SimaPluginLogicalTensor* logical = &stage->logical_outputs[i];
734 if (logical_index >= 0 && logical->logical_index == logical_index) {
735 return logical->physical_index;
736 }
737 if (output_slot >= 0 && logical->output_slot == output_slot) {
738 return logical->physical_index;
739 }
740 }
741 return -1;
742}

sima_plugin_static_manifest_handle_boxed_copy()

gpointer sima_plugin_static_manifest_handle_boxed_copy (gpointer boxed)
inline static

Definition at line 477 of file SimaPluginStaticManifestAbi.h.

477static inline gpointer sima_plugin_static_manifest_handle_boxed_copy(gpointer boxed) {
478 auto* handle = static_cast<SimaPluginStaticManifestHandle*>(boxed);
479 if (handle && handle->ref) {
480 handle->ref(handle->user_data);
481 }
482 return boxed;
483}

sima_plugin_static_manifest_handle_boxed_free()

void sima_plugin_static_manifest_handle_boxed_free (gpointer boxed)
inline static

Definition at line 485 of file SimaPluginStaticManifestAbi.h.

485static inline void sima_plugin_static_manifest_handle_boxed_free(gpointer boxed) {
486 auto* handle = static_cast<SimaPluginStaticManifestHandle*>(boxed);
487 if (handle && handle->unref) {
488 handle->unref(handle->user_data);
489 }
490}

sima_plugin_static_manifest_handle_get_type()

GType sima_plugin_static_manifest_handle_get_type (void)
inline static

Definition at line 492 of file SimaPluginStaticManifestAbi.h.

492static inline GType sima_plugin_static_manifest_handle_get_type(void) {
493 static const gchar* kTypeName = "SimaPluginStaticManifestHandle";
494 GType type = g_type_from_name(kTypeName);
495 if (type != 0) {
496 return type;
497 }
498 return g_boxed_type_register_static(kTypeName, sima_plugin_static_manifest_handle_boxed_copy,
499 sima_plugin_static_manifest_handle_boxed_free);
500}

Macro Definitions

SIMA_PLUGIN_STATIC_MANIFEST_ABI_VERSION

#define SIMA_PLUGIN_STATIC_MANIFEST_ABI_VERSION   ((guint)19)

Definition at line 30 of file SimaPluginStaticManifestAbi.h.

30#define SIMA_PLUGIN_STATIC_MANIFEST_ABI_VERSION ((guint)19)

SIMA_PLUGIN_STATIC_MANIFEST_CONTEXT_TYPE

#define SIMA_PLUGIN_STATIC_MANIFEST_CONTEXT_TYPE   "sima.model.manifest"

Definition at line 29 of file SimaPluginStaticManifestAbi.h.

29#define SIMA_PLUGIN_STATIC_MANIFEST_CONTEXT_TYPE "sima.model.manifest"

SIMA_PLUGIN_STATIC_MANIFEST_KEY_HANDLE

#define SIMA_PLUGIN_STATIC_MANIFEST_KEY_HANDLE   "manifest_handle"

Definition at line 34 of file SimaPluginStaticManifestAbi.h.

34#define SIMA_PLUGIN_STATIC_MANIFEST_KEY_HANDLE "manifest_handle"

SIMA_PLUGIN_STATIC_MANIFEST_KEY_MODEL_ID

#define SIMA_PLUGIN_STATIC_MANIFEST_KEY_MODEL_ID   "model_id"

Definition at line 33 of file SimaPluginStaticManifestAbi.h.

33#define SIMA_PLUGIN_STATIC_MANIFEST_KEY_MODEL_ID "model_id"

SIMA_PLUGIN_STATIC_MANIFEST_KEY_SESSION_ID

#define SIMA_PLUGIN_STATIC_MANIFEST_KEY_SESSION_ID   "session_id"

Definition at line 32 of file SimaPluginStaticManifestAbi.h.

32#define SIMA_PLUGIN_STATIC_MANIFEST_KEY_SESSION_ID "session_id"

File Listing

The file content with the documentation metadata removed is:

1#pragma once
2
3#include <gst/gst.h>
4#include <stdio.h>
5#include <stdlib.h>
6#include <string.h>
7#include <ev/ev_tensor_abi.h>
8
9#ifdef __cplusplus
10extern "C" {
11#endif
12
13/*
14 * Pipeline-level static manifest context contract for SIMA model plugins.
15 * This is an ABI contract header; plugin/dispatcher repos should carry a synced
16 * copy and must not link against framework internals.
17 *
18 * Context type:
19 * "sima.model.manifest"
20 *
21 * Required fields:
22 * - "manifest_handle" (SimaPluginStaticManifestHandle boxed value)
23 *
24 * Optional fields:
25 * - "session_id" (string)
26 * - "model_id" (string)
27 */
28
29#define SIMA_PLUGIN_STATIC_MANIFEST_CONTEXT_TYPE "sima.model.manifest"
30#define SIMA_PLUGIN_STATIC_MANIFEST_ABI_VERSION ((guint)19)
31
32#define SIMA_PLUGIN_STATIC_MANIFEST_KEY_SESSION_ID "session_id"
33#define SIMA_PLUGIN_STATIC_MANIFEST_KEY_MODEL_ID "model_id"
34#define SIMA_PLUGIN_STATIC_MANIFEST_KEY_HANDLE "manifest_handle"
35
39
41
44 gpointer user_data;
45 void (*ref)(gpointer user_data);
46 void (*unref)(gpointer user_data);
47 const SimaPluginStaticManifestAccessor* (*accessor)(gpointer user_data);
49
61
73
74typedef struct SimaPluginTensorSpec {
76 const gint64* shape;
77 guint shape_len;
78 const gchar* dtype;
79 const guint8* axis_semantics;
81 gint max_w;
82 gint max_h;
84 const gchar* semantic_tag;
86
87typedef struct SimaPluginQuantSpec {
89 gint axis;
90 const gdouble* scales;
91 guint scales_len;
92 const gint64* zero_points;
95
96typedef struct SimaPluginSinkRoute {
98 gboolean required;
99 const gchar* src_stage_id;
102 const gchar* cm_input_name;
103 const gchar* source_segment_name;
105
106typedef struct SimaPluginOutputRoute {
108 const gchar* cm_output_name;
109 const gchar* segment_name;
111
118
125
129 guint64 size_bytes;
131 guint64 memory_flags;
133 const gchar* segment_name;
137
145 guint64 size_bytes;
146 const gint64* shape;
147 guint shape_len;
148 const gint64* stride_bytes;
150 const gchar* dtype;
151 const guint8* axis_semantics;
154 const gchar* logical_name;
156 const gchar* backend_name;
158 const gchar* segment_name;
161
162typedef struct SimaPluginLogicalInput {
166 const gint64* shape;
167 guint shape_len;
168 const gint64* stride_bytes;
171 guint64 size_bytes;
172 const gchar* dtype;
173 const guint8* axis_semantics;
176 const gchar* logical_name;
178 const gchar* backend_name;
180 const gchar* segment_name;
184
185typedef struct SimaPluginInputBinding {
189 const gchar* src_stage_id;
195 gboolean required;
197 const gchar* cm_input_name;
199 const gchar* source_segment_name;
201
215
221
230
232 const gchar* graph_family;
234 const gchar* graph_name;
236 const gchar* run_target;
239 const gchar* default_input_name;
240 const gchar* const* default_output_names;
242 const gchar* primary_output_name;
245 const gchar* input_img_type;
246 const gchar* output_img_type;
247 const gchar* scaling_type;
248 const gchar* padding_type;
249 const gchar* input_dtype;
250 const gchar* output_dtype;
251 const gchar* out_dtype;
252
263 guint32 opt_flags;
266
267 /* tri-state values: -1 unset, 0 false, 1 true */
271
272 gdouble q_scale;
273 gint q_zp;
274 gboolean has_q_scale;
275 gboolean has_q_zp;
276 const gdouble* q_scale_array;
278 const gint* q_zp_array;
291 const gchar* const* runtime_output_dtype_array;
297 const gdouble* dq_scale_array;
299 const gint* dq_zp_array;
301
302 const gdouble* channel_mean;
304 const gdouble* channel_stddev;
307
309 const gchar* model_path;
312 const gchar* const* dispatcher_output_names;
317
319 const gchar* decode_type;
320 const gchar* decode_type_option;
323 gint topk;
325 const struct sima_ev_shape_desc* slice_shapes;
327 const gchar* input_dtype;
334
338
342
343typedef struct SimaPluginStageSpec {
344 const gchar* element_name;
345 const gchar* logical_stage_id;
346 const gchar* plugin_kind;
347 const gchar* kernel_kind;
348
349 const gchar* const* name_table;
363
366
369
371 union {
382
383/*
384 * ABI-safe accessor table carried via GstContext as a pointer.
385 *
386 * Lifetime:
387 * - The owner of this table must outlive pipeline/plugin usage.
388 * - Plugins must treat returned pointers as borrowed; copy if needed.
389 */
392 gpointer user_data;
393
394 const gchar* (*session_id)(gpointer user_data);
395 const gchar* (*model_id)(gpointer user_data);
396
397 guint (*stage_count)(gpointer user_data);
398 const SimaPluginStageSpec* (*stage_by_index)(gpointer user_data, guint index);
399 const SimaPluginStageSpec* (*stage_by_element_name)(gpointer user_data,
400 const gchar* element_name);
401 const SimaPluginStageSpec* (*stage_by_logical_stage_id)(gpointer user_data,
402 const gchar* logical_stage_id);
403};
404
405static inline const gchar*
406sima_plugin_manifest_lookup_status_name(SimaPluginManifestLookupStatus status) {
407 switch (status) {
409 return "ok";
411 return "no_context";
413 return "wrong_context_type";
415 return "missing_handle";
417 return "handle_abi_mismatch";
419 return "handle_accessor_null";
421 return "handle_callback_missing";
423 return "stage_not_found";
425 return "payload_kind_mismatch";
426 default:
427 return "unknown";
428 }
429}
430
431static inline const gchar*
432sima_plugin_manifest_lookup_status_error_message(SimaPluginManifestLookupStatus status) {
433 switch (status) {
435 return "Missing sima.model.manifest context";
437 return "Wrong sima.model.manifest context type";
439 return "Missing manifest handle in manifest context";
441 return "Manifest handle ABI mismatch";
444 return "Manifest accessor unavailable";
446 return "Missing stage entry in manifest context";
448 return "Manifest payload kind mismatch";
450 default:
451 return "Manifest lookup status OK";
452 }
453}
454
455static inline const gchar*
456sima_plugin_manifest_lookup_status_missing_field(SimaPluginManifestLookupStatus status) {
457 switch (status) {
460 return "manifest_context";
463 return "manifest_handle";
466 return "manifest_accessor";
468 return "stage_spec";
470 return "typed_stage_payload";
472 default:
473 return "none";
474 }
475}
476
477static inline gpointer sima_plugin_static_manifest_handle_boxed_copy(gpointer boxed) {
478 auto* handle = static_cast<SimaPluginStaticManifestHandle*>(boxed);
479 if (handle && handle->ref) {
480 handle->ref(handle->user_data);
481 }
482 return boxed;
483}
484
485static inline void sima_plugin_static_manifest_handle_boxed_free(gpointer boxed) {
486 auto* handle = static_cast<SimaPluginStaticManifestHandle*>(boxed);
487 if (handle && handle->unref) {
488 handle->unref(handle->user_data);
489 }
490}
491
492static inline GType sima_plugin_static_manifest_handle_get_type(void) {
493 static const gchar* kTypeName = "SimaPluginStaticManifestHandle";
494 GType type = g_type_from_name(kTypeName);
495 if (type != 0) {
496 return type;
497 }
498 return g_boxed_type_register_static(kTypeName, sima_plugin_static_manifest_handle_boxed_copy,
499 sima_plugin_static_manifest_handle_boxed_free);
500}
501
502static inline void sima_plugin_manifest_set_lookup_status(SimaPluginManifestLookupStatus* status,
504 if (status) {
505 *status = value;
506 }
507}
508
509static inline gboolean sima_plugin_manifest_context_matches(const GstContext* context) {
510 if (!context) {
511 return FALSE;
512 }
513 return g_strcmp0(gst_context_get_context_type(context),
515}
516
517static inline const GstStructure*
518sima_plugin_manifest_context_structure(const GstContext* context) {
519 if (!sima_plugin_manifest_context_matches(context)) {
520 return NULL;
521 }
522 return gst_context_get_structure(context);
523}
524
525static inline const SimaPluginStaticManifestHandle*
526sima_plugin_manifest_context_handle(const GstContext* context) {
527 const GstStructure* structure = sima_plugin_manifest_context_structure(context);
528 if (!structure) {
529 return NULL;
530 }
531 const GValue* handle_val =
532 gst_structure_get_value(structure, SIMA_PLUGIN_STATIC_MANIFEST_KEY_HANDLE);
533 if (!handle_val || G_VALUE_TYPE(handle_val) != sima_plugin_static_manifest_handle_get_type()) {
534 return NULL;
535 }
536 const auto* handle =
537 static_cast<const SimaPluginStaticManifestHandle*>(g_value_get_boxed(handle_val));
538 if (!handle) {
539 return NULL;
540 }
541 return handle;
542}
543
544static inline const SimaPluginStaticManifestAccessor*
545sima_plugin_manifest_context_accessor_checked(const GstContext* context,
547 const bool debug_manifest_context = ([]() -> bool {
548 const char* raw = getenv("SIMA_MANIFEST_CONTEXT_DEBUG");
549 return raw && *raw && strcmp(raw, "0") != 0;
550 })();
551 if (!context) {
552 sima_plugin_manifest_set_lookup_status(status, SIMA_PLUGIN_MANIFEST_LOOKUP_STATUS_NO_CONTEXT);
553 return NULL;
554 }
555 if (!sima_plugin_manifest_context_matches(context)) {
556 sima_plugin_manifest_set_lookup_status(status,
558 return NULL;
559 }
560 const auto* handle = sima_plugin_manifest_context_handle(context);
561 if (!handle) {
562 sima_plugin_manifest_set_lookup_status(status,
564 return NULL;
565 }
566 if (handle->abi_version != SIMA_PLUGIN_STATIC_MANIFEST_ABI_VERSION) {
567 if (debug_manifest_context) {
568 fprintf(stderr,
569 "[manifest-context-debug] lookup=handle_abi_mismatch context=%p "
570 "handle=%p handle_abi=%u expected_abi=%u user_data=%p\n",
571 static_cast<const void*>(context), static_cast<const void*>(handle),
572 static_cast<unsigned>(handle->abi_version),
573 static_cast<unsigned>(SIMA_PLUGIN_STATIC_MANIFEST_ABI_VERSION), handle->user_data);
574 }
575 sima_plugin_manifest_set_lookup_status(status,
577 return NULL;
578 }
579 if (!handle->ref || !handle->unref || !handle->accessor) {
580 sima_plugin_manifest_set_lookup_status(
582 return NULL;
583 }
584 const auto* accessor = handle->accessor(handle->user_data);
585 if (!accessor) {
586 sima_plugin_manifest_set_lookup_status(status,
588 return NULL;
589 }
590 if (accessor->abi_version != SIMA_PLUGIN_STATIC_MANIFEST_ABI_VERSION) {
591 if (debug_manifest_context) {
592 fprintf(stderr,
593 "[manifest-context-debug] lookup=accessor_abi_mismatch context=%p "
594 "handle=%p accessor=%p accessor_abi=%u expected_abi=%u user_data=%p\n",
595 static_cast<const void*>(context), static_cast<const void*>(handle),
596 static_cast<const void*>(accessor), static_cast<unsigned>(accessor->abi_version),
597 static_cast<unsigned>(SIMA_PLUGIN_STATIC_MANIFEST_ABI_VERSION), accessor->user_data);
598 }
599 sima_plugin_manifest_set_lookup_status(status,
601 return NULL;
602 }
603 sima_plugin_manifest_set_lookup_status(status, SIMA_PLUGIN_MANIFEST_LOOKUP_STATUS_OK);
604 return accessor;
605}
606
607static inline const SimaPluginStaticManifestAccessor*
608sima_plugin_manifest_context_accessor(const GstContext* context) {
609 return sima_plugin_manifest_context_accessor_checked(context, NULL);
610}
611
612static inline const gchar* sima_plugin_manifest_stage_key(const SimaPluginStageSpec* stage) {
613 if (!stage) {
614 return NULL;
615 }
616 if (stage->logical_stage_id && *stage->logical_stage_id) {
617 return stage->logical_stage_id;
618 }
619 if (stage->element_name && *stage->element_name) {
620 return stage->element_name;
621 }
622 return NULL;
623}
624
625static inline gboolean
626sima_plugin_manifest_stage_matches_payload_kind(const SimaPluginStageSpec* stage,
627 SimaPluginStagePayloadKind expected_payload_kind) {
628 if (!stage) {
629 return FALSE;
630 }
631 return expected_payload_kind == SIMA_PLUGIN_STAGE_PAYLOAD_NONE ||
632 stage->payload_kind == expected_payload_kind;
633}
634
635static inline const SimaPluginStageSpec*
636sima_plugin_manifest_stage_by_element_name(const SimaPluginStaticManifestAccessor* accessor,
637 const gchar* element_name) {
638 if (!accessor || !accessor->stage_by_element_name || !element_name || !*element_name) {
639 return NULL;
640 }
641 return accessor->stage_by_element_name(accessor->user_data, element_name);
642}
643
644static inline const SimaPluginStageSpec*
645sima_plugin_manifest_stage_by_logical_id(const SimaPluginStaticManifestAccessor* accessor,
646 const gchar* logical_stage_id) {
647 if (!accessor || !accessor->stage_by_logical_stage_id || !logical_stage_id ||
648 !*logical_stage_id) {
649 return NULL;
650 }
651 return accessor->stage_by_logical_stage_id(accessor->user_data, logical_stage_id);
652}
653
654static inline const SimaPluginStageSpec*
655sima_plugin_manifest_stage_lookup(const SimaPluginStaticManifestAccessor* accessor,
656 const gchar* stage_id_or_name,
657 const gchar* element_name_fallback) {
658 const SimaPluginStageSpec* out = NULL;
659 if (stage_id_or_name && *stage_id_or_name) {
660 out = sima_plugin_manifest_stage_by_logical_id(accessor, stage_id_or_name);
661 if (!out) {
662 out = sima_plugin_manifest_stage_by_element_name(accessor, stage_id_or_name);
663 }
664 }
665 if (!out && element_name_fallback && *element_name_fallback) {
666 out = sima_plugin_manifest_stage_by_element_name(accessor, element_name_fallback);
667 }
668 return out;
669}
670
671static inline const SimaPluginStageSpec* sima_plugin_manifest_stage_lookup_typed(
672 const SimaPluginStaticManifestAccessor* accessor, const gchar* stage_id_or_name,
673 const gchar* element_name_fallback, SimaPluginStagePayloadKind expected_payload_kind) {
674 const SimaPluginStageSpec* stage =
675 sima_plugin_manifest_stage_lookup(accessor, stage_id_or_name, element_name_fallback);
676 if (!sima_plugin_manifest_stage_matches_payload_kind(stage, expected_payload_kind)) {
677 return NULL;
678 }
679 return stage;
680}
681
682static inline const SimaPluginStageSpec* sima_plugin_manifest_context_stage_lookup_typed_checked(
683 const GstContext* context, const gchar* stage_id_or_name, const gchar* element_name_fallback,
684 SimaPluginStagePayloadKind expected_payload_kind, SimaPluginManifestLookupStatus* status);
685
686static inline const SimaPluginStageSpec* sima_plugin_manifest_context_stage_lookup_typed(
687 const GstContext* context, const gchar* stage_id_or_name, const gchar* element_name_fallback,
688 SimaPluginStagePayloadKind expected_payload_kind) {
689 return sima_plugin_manifest_context_stage_lookup_typed_checked(
690 context, stage_id_or_name, element_name_fallback, expected_payload_kind, NULL);
691}
692
693static inline const SimaPluginStageSpec* sima_plugin_manifest_context_stage_lookup_typed_checked(
694 const GstContext* context, const gchar* stage_id_or_name, const gchar* element_name_fallback,
695 SimaPluginStagePayloadKind expected_payload_kind, SimaPluginManifestLookupStatus* status) {
696 const SimaPluginStaticManifestAccessor* accessor =
697 sima_plugin_manifest_context_accessor_checked(context, status);
698 if (!accessor) {
699 return NULL;
700 }
701 const SimaPluginStageSpec* stage =
702 sima_plugin_manifest_stage_lookup(accessor, stage_id_or_name, element_name_fallback);
703 if (!stage) {
704 sima_plugin_manifest_set_lookup_status(status,
706 return NULL;
707 }
708 if (!sima_plugin_manifest_stage_matches_payload_kind(stage, expected_payload_kind)) {
709 sima_plugin_manifest_set_lookup_status(
711 return NULL;
712 }
713 sima_plugin_manifest_set_lookup_status(status, SIMA_PLUGIN_MANIFEST_LOOKUP_STATUS_OK);
714 return stage;
715}
716
717static inline const gchar* sima_plugin_manifest_stage_name_from_id(const SimaPluginStageSpec* stage,
718 gint name_id) {
719 if (!stage || !stage->name_table || name_id < 0 ||
720 static_cast<guint>(name_id) >= stage->name_table_len) {
721 return NULL;
722 }
723 return stage->name_table[name_id];
724}
725
726static inline gint sima_plugin_stage_output_route_physical_index(const SimaPluginStageSpec* stage,
727 gint logical_index,
728 gint output_slot) {
729 if (!stage || !stage->logical_outputs || stage->logical_outputs_len == 0U) {
730 return -1;
731 }
732 for (guint i = 0; i < stage->logical_outputs_len; ++i) {
733 const SimaPluginLogicalTensor* logical = &stage->logical_outputs[i];
734 if (logical_index >= 0 && logical->logical_index == logical_index) {
735 return logical->physical_index;
736 }
737 if (output_slot >= 0 && logical->output_slot == output_slot) {
738 return logical->physical_index;
739 }
740 }
741 return -1;
742}
743
744static inline gint sima_plugin_stage_output_route_logical_index(const SimaPluginStageSpec* stage,
745 gint output_slot,
746 const gchar* cm_output_name,
747 const gchar* segment_name) {
748 if (!stage || !stage->logical_outputs || stage->logical_outputs_len == 0U) {
749 return -1;
750 }
751
752 if (cm_output_name && *cm_output_name) {
753 for (guint i = 0; i < stage->logical_outputs_len; ++i) {
754 const SimaPluginLogicalTensor* logical = &stage->logical_outputs[i];
755 if (logical->backend_name && g_strcmp0(logical->backend_name, cm_output_name) == 0) {
756 return logical->logical_index;
757 }
758 }
759 }
760
761 if (segment_name && *segment_name) {
762 for (guint i = 0; i < stage->logical_outputs_len; ++i) {
763 const SimaPluginLogicalTensor* logical = &stage->logical_outputs[i];
764 if (logical->segment_name && g_strcmp0(logical->segment_name, segment_name) == 0) {
765 return logical->logical_index;
766 }
767 }
768 }
769
770 if (output_slot >= 0) {
771 for (guint i = 0; i < stage->logical_outputs_len; ++i) {
772 const SimaPluginLogicalTensor* logical = &stage->logical_outputs[i];
773 if (logical->output_slot == output_slot) {
774 return logical->logical_index;
775 }
776 }
777 }
778
779 return -1;
780}
781
782#ifdef __cplusplus
783} /* extern "C" */
784#endif

Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.9.8.