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)18)
#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 332 of file SimaPluginStaticManifestAbi.h.

SimaPluginDetessDequantStagePayload

typedef struct SimaPluginDetessDequantStagePayload SimaPluginDetessDequantStagePayload

Definition at line 336 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 305 of file SimaPluginStaticManifestAbi.h.

SimaPluginProcessMlaStagePayload

typedef struct SimaPluginProcessMlaStagePayload SimaPluginProcessMlaStagePayload

Definition at line 315 of file SimaPluginStaticManifestAbi.h.

SimaPluginQuantLikeStagePayload

typedef struct SimaPluginQuantLikeStagePayload SimaPluginQuantLikeStagePayload

Definition at line 340 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 380 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 607 of file SimaPluginStaticManifestAbi.h.

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

sima_plugin_manifest_context_accessor_checked()

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

Definition at line 544 of file SimaPluginStaticManifestAbi.h.

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

sima_plugin_manifest_context_handle()

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

Definition at line 525 of file SimaPluginStaticManifestAbi.h.

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

sima_plugin_manifest_context_matches()

gboolean sima_plugin_manifest_context_matches (const GstContext * context)
inline static

Definition at line 508 of file SimaPluginStaticManifestAbi.h.

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

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 685 of file SimaPluginStaticManifestAbi.h.

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

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 692 of file SimaPluginStaticManifestAbi.h.

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

sima_plugin_manifest_context_structure()

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

Definition at line 517 of file SimaPluginStaticManifestAbi.h.

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

sima_plugin_manifest_lookup_status_error_message()

const gchar * sima_plugin_manifest_lookup_status_error_message (SimaPluginManifestLookupStatus status)
inline static

Definition at line 431 of file SimaPluginStaticManifestAbi.h.

431sima_plugin_manifest_lookup_status_error_message(SimaPluginManifestLookupStatus status) {
432 switch (status) {
434 return "Missing sima.model.manifest context";
436 return "Wrong sima.model.manifest context type";
438 return "Missing manifest handle in manifest context";
440 return "Manifest handle ABI mismatch";
443 return "Manifest accessor unavailable";
445 return "Missing stage entry in manifest context";
447 return "Manifest payload kind mismatch";
449 default:
450 return "Manifest lookup status OK";
451 }
452}

sima_plugin_manifest_lookup_status_missing_field()

const gchar * sima_plugin_manifest_lookup_status_missing_field (SimaPluginManifestLookupStatus status)
inline static

Definition at line 455 of file SimaPluginStaticManifestAbi.h.

455sima_plugin_manifest_lookup_status_missing_field(SimaPluginManifestLookupStatus status) {
456 switch (status) {
459 return "manifest_context";
462 return "manifest_handle";
465 return "manifest_accessor";
467 return "stage_spec";
469 return "typed_stage_payload";
471 default:
472 return "none";
473 }
474}

sima_plugin_manifest_lookup_status_name()

const gchar * sima_plugin_manifest_lookup_status_name (SimaPluginManifestLookupStatus status)
inline static

Definition at line 405 of file SimaPluginStaticManifestAbi.h.

405sima_plugin_manifest_lookup_status_name(SimaPluginManifestLookupStatus status) {
406 switch (status) {
408 return "ok";
410 return "no_context";
412 return "wrong_context_type";
414 return "missing_handle";
416 return "handle_abi_mismatch";
418 return "handle_accessor_null";
420 return "handle_callback_missing";
422 return "stage_not_found";
424 return "payload_kind_mismatch";
425 default:
426 return "unknown";
427 }
428}

sima_plugin_manifest_set_lookup_status()

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

Definition at line 501 of file SimaPluginStaticManifestAbi.h.

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

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 635 of file SimaPluginStaticManifestAbi.h.

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

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 644 of file SimaPluginStaticManifestAbi.h.

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

sima_plugin_manifest_stage_key()

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

Definition at line 611 of file SimaPluginStaticManifestAbi.h.

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

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 654 of file SimaPluginStaticManifestAbi.h.

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

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 670 of file SimaPluginStaticManifestAbi.h.

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

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 625 of file SimaPluginStaticManifestAbi.h.

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

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 716 of file SimaPluginStaticManifestAbi.h.

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

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 743 of file SimaPluginStaticManifestAbi.h.

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

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 725 of file SimaPluginStaticManifestAbi.h.

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

sima_plugin_static_manifest_handle_boxed_copy()

gpointer sima_plugin_static_manifest_handle_boxed_copy (gpointer boxed)
inline static

Definition at line 476 of file SimaPluginStaticManifestAbi.h.

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

sima_plugin_static_manifest_handle_boxed_free()

void sima_plugin_static_manifest_handle_boxed_free (gpointer boxed)
inline static

Definition at line 484 of file SimaPluginStaticManifestAbi.h.

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

sima_plugin_static_manifest_handle_get_type()

GType sima_plugin_static_manifest_handle_get_type (void)
inline static

Definition at line 491 of file SimaPluginStaticManifestAbi.h.

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

Macro Definitions

SIMA_PLUGIN_STATIC_MANIFEST_ABI_VERSION

#define SIMA_PLUGIN_STATIC_MANIFEST_ABI_VERSION   ((guint)18)

Definition at line 30 of file SimaPluginStaticManifestAbi.h.

30#define SIMA_PLUGIN_STATIC_MANIFEST_ABI_VERSION ((guint)18)

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)18)
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
262 guint32 opt_flags;
265
266 /* tri-state values: -1 unset, 0 false, 1 true */
270
271 gdouble q_scale;
272 gint q_zp;
273 gboolean has_q_scale;
274 gboolean has_q_zp;
275 const gdouble* q_scale_array;
277 const gint* q_zp_array;
290 const gchar* const* runtime_output_dtype_array;
296 const gdouble* dq_scale_array;
298 const gint* dq_zp_array;
300
301 const gdouble* channel_mean;
303 const gdouble* channel_stddev;
306
308 const gchar* model_path;
311 const gchar* const* dispatcher_output_names;
316
318 const gchar* decode_type;
319 const gchar* decode_type_option;
322 gint topk;
324 const struct sima_ev_shape_desc* slice_shapes;
326 const gchar* input_dtype;
333
337
341
342typedef struct SimaPluginStageSpec {
343 const gchar* element_name;
344 const gchar* logical_stage_id;
345 const gchar* plugin_kind;
346 const gchar* kernel_kind;
347
348 const gchar* const* name_table;
362
365
368
370 union {
381
382/*
383 * ABI-safe accessor table carried via GstContext as a pointer.
384 *
385 * Lifetime:
386 * - The owner of this table must outlive pipeline/plugin usage.
387 * - Plugins must treat returned pointers as borrowed; copy if needed.
388 */
391 gpointer user_data;
392
393 const gchar* (*session_id)(gpointer user_data);
394 const gchar* (*model_id)(gpointer user_data);
395
396 guint (*stage_count)(gpointer user_data);
397 const SimaPluginStageSpec* (*stage_by_index)(gpointer user_data, guint index);
398 const SimaPluginStageSpec* (*stage_by_element_name)(gpointer user_data,
399 const gchar* element_name);
400 const SimaPluginStageSpec* (*stage_by_logical_stage_id)(gpointer user_data,
401 const gchar* logical_stage_id);
402};
403
404static inline const gchar*
405sima_plugin_manifest_lookup_status_name(SimaPluginManifestLookupStatus status) {
406 switch (status) {
408 return "ok";
410 return "no_context";
412 return "wrong_context_type";
414 return "missing_handle";
416 return "handle_abi_mismatch";
418 return "handle_accessor_null";
420 return "handle_callback_missing";
422 return "stage_not_found";
424 return "payload_kind_mismatch";
425 default:
426 return "unknown";
427 }
428}
429
430static inline const gchar*
431sima_plugin_manifest_lookup_status_error_message(SimaPluginManifestLookupStatus status) {
432 switch (status) {
434 return "Missing sima.model.manifest context";
436 return "Wrong sima.model.manifest context type";
438 return "Missing manifest handle in manifest context";
440 return "Manifest handle ABI mismatch";
443 return "Manifest accessor unavailable";
445 return "Missing stage entry in manifest context";
447 return "Manifest payload kind mismatch";
449 default:
450 return "Manifest lookup status OK";
451 }
452}
453
454static inline const gchar*
455sima_plugin_manifest_lookup_status_missing_field(SimaPluginManifestLookupStatus status) {
456 switch (status) {
459 return "manifest_context";
462 return "manifest_handle";
465 return "manifest_accessor";
467 return "stage_spec";
469 return "typed_stage_payload";
471 default:
472 return "none";
473 }
474}
475
476static inline gpointer sima_plugin_static_manifest_handle_boxed_copy(gpointer boxed) {
477 auto* handle = static_cast<SimaPluginStaticManifestHandle*>(boxed);
478 if (handle && handle->ref) {
479 handle->ref(handle->user_data);
480 }
481 return boxed;
482}
483
484static inline void sima_plugin_static_manifest_handle_boxed_free(gpointer boxed) {
485 auto* handle = static_cast<SimaPluginStaticManifestHandle*>(boxed);
486 if (handle && handle->unref) {
487 handle->unref(handle->user_data);
488 }
489}
490
491static inline GType sima_plugin_static_manifest_handle_get_type(void) {
492 static const gchar* kTypeName = "SimaPluginStaticManifestHandle";
493 GType type = g_type_from_name(kTypeName);
494 if (type != 0) {
495 return type;
496 }
497 return g_boxed_type_register_static(kTypeName, sima_plugin_static_manifest_handle_boxed_copy,
498 sima_plugin_static_manifest_handle_boxed_free);
499}
500
501static inline void sima_plugin_manifest_set_lookup_status(SimaPluginManifestLookupStatus* status,
503 if (status) {
504 *status = value;
505 }
506}
507
508static inline gboolean sima_plugin_manifest_context_matches(const GstContext* context) {
509 if (!context) {
510 return FALSE;
511 }
512 return g_strcmp0(gst_context_get_context_type(context),
514}
515
516static inline const GstStructure*
517sima_plugin_manifest_context_structure(const GstContext* context) {
518 if (!sima_plugin_manifest_context_matches(context)) {
519 return NULL;
520 }
521 return gst_context_get_structure(context);
522}
523
524static inline const SimaPluginStaticManifestHandle*
525sima_plugin_manifest_context_handle(const GstContext* context) {
526 const GstStructure* structure = sima_plugin_manifest_context_structure(context);
527 if (!structure) {
528 return NULL;
529 }
530 const GValue* handle_val =
531 gst_structure_get_value(structure, SIMA_PLUGIN_STATIC_MANIFEST_KEY_HANDLE);
532 if (!handle_val || G_VALUE_TYPE(handle_val) != sima_plugin_static_manifest_handle_get_type()) {
533 return NULL;
534 }
535 const auto* handle =
536 static_cast<const SimaPluginStaticManifestHandle*>(g_value_get_boxed(handle_val));
537 if (!handle) {
538 return NULL;
539 }
540 return handle;
541}
542
543static inline const SimaPluginStaticManifestAccessor*
544sima_plugin_manifest_context_accessor_checked(const GstContext* context,
546 const bool debug_manifest_context = ([]() -> bool {
547 const char* raw = getenv("SIMA_MANIFEST_CONTEXT_DEBUG");
548 return raw && *raw && strcmp(raw, "0") != 0;
549 })();
550 if (!context) {
551 sima_plugin_manifest_set_lookup_status(status, SIMA_PLUGIN_MANIFEST_LOOKUP_STATUS_NO_CONTEXT);
552 return NULL;
553 }
554 if (!sima_plugin_manifest_context_matches(context)) {
555 sima_plugin_manifest_set_lookup_status(status,
557 return NULL;
558 }
559 const auto* handle = sima_plugin_manifest_context_handle(context);
560 if (!handle) {
561 sima_plugin_manifest_set_lookup_status(status,
563 return NULL;
564 }
565 if (handle->abi_version != SIMA_PLUGIN_STATIC_MANIFEST_ABI_VERSION) {
566 if (debug_manifest_context) {
567 fprintf(stderr,
568 "[manifest-context-debug] lookup=handle_abi_mismatch context=%p "
569 "handle=%p handle_abi=%u expected_abi=%u user_data=%p\n",
570 static_cast<const void*>(context), static_cast<const void*>(handle),
571 static_cast<unsigned>(handle->abi_version),
572 static_cast<unsigned>(SIMA_PLUGIN_STATIC_MANIFEST_ABI_VERSION), handle->user_data);
573 }
574 sima_plugin_manifest_set_lookup_status(status,
576 return NULL;
577 }
578 if (!handle->ref || !handle->unref || !handle->accessor) {
579 sima_plugin_manifest_set_lookup_status(
581 return NULL;
582 }
583 const auto* accessor = handle->accessor(handle->user_data);
584 if (!accessor) {
585 sima_plugin_manifest_set_lookup_status(status,
587 return NULL;
588 }
589 if (accessor->abi_version != SIMA_PLUGIN_STATIC_MANIFEST_ABI_VERSION) {
590 if (debug_manifest_context) {
591 fprintf(stderr,
592 "[manifest-context-debug] lookup=accessor_abi_mismatch context=%p "
593 "handle=%p accessor=%p accessor_abi=%u expected_abi=%u user_data=%p\n",
594 static_cast<const void*>(context), static_cast<const void*>(handle),
595 static_cast<const void*>(accessor), static_cast<unsigned>(accessor->abi_version),
596 static_cast<unsigned>(SIMA_PLUGIN_STATIC_MANIFEST_ABI_VERSION), accessor->user_data);
597 }
598 sima_plugin_manifest_set_lookup_status(status,
600 return NULL;
601 }
602 sima_plugin_manifest_set_lookup_status(status, SIMA_PLUGIN_MANIFEST_LOOKUP_STATUS_OK);
603 return accessor;
604}
605
606static inline const SimaPluginStaticManifestAccessor*
607sima_plugin_manifest_context_accessor(const GstContext* context) {
608 return sima_plugin_manifest_context_accessor_checked(context, NULL);
609}
610
611static inline const gchar* sima_plugin_manifest_stage_key(const SimaPluginStageSpec* stage) {
612 if (!stage) {
613 return NULL;
614 }
615 if (stage->logical_stage_id && *stage->logical_stage_id) {
616 return stage->logical_stage_id;
617 }
618 if (stage->element_name && *stage->element_name) {
619 return stage->element_name;
620 }
621 return NULL;
622}
623
624static inline gboolean
625sima_plugin_manifest_stage_matches_payload_kind(const SimaPluginStageSpec* stage,
626 SimaPluginStagePayloadKind expected_payload_kind) {
627 if (!stage) {
628 return FALSE;
629 }
630 return expected_payload_kind == SIMA_PLUGIN_STAGE_PAYLOAD_NONE ||
631 stage->payload_kind == expected_payload_kind;
632}
633
634static inline const SimaPluginStageSpec*
635sima_plugin_manifest_stage_by_element_name(const SimaPluginStaticManifestAccessor* accessor,
636 const gchar* element_name) {
637 if (!accessor || !accessor->stage_by_element_name || !element_name || !*element_name) {
638 return NULL;
639 }
640 return accessor->stage_by_element_name(accessor->user_data, element_name);
641}
642
643static inline const SimaPluginStageSpec*
644sima_plugin_manifest_stage_by_logical_id(const SimaPluginStaticManifestAccessor* accessor,
645 const gchar* logical_stage_id) {
646 if (!accessor || !accessor->stage_by_logical_stage_id || !logical_stage_id ||
647 !*logical_stage_id) {
648 return NULL;
649 }
650 return accessor->stage_by_logical_stage_id(accessor->user_data, logical_stage_id);
651}
652
653static inline const SimaPluginStageSpec*
654sima_plugin_manifest_stage_lookup(const SimaPluginStaticManifestAccessor* accessor,
655 const gchar* stage_id_or_name,
656 const gchar* element_name_fallback) {
657 const SimaPluginStageSpec* out = NULL;
658 if (stage_id_or_name && *stage_id_or_name) {
659 out = sima_plugin_manifest_stage_by_logical_id(accessor, stage_id_or_name);
660 if (!out) {
661 out = sima_plugin_manifest_stage_by_element_name(accessor, stage_id_or_name);
662 }
663 }
664 if (!out && element_name_fallback && *element_name_fallback) {
665 out = sima_plugin_manifest_stage_by_element_name(accessor, element_name_fallback);
666 }
667 return out;
668}
669
670static inline const SimaPluginStageSpec* sima_plugin_manifest_stage_lookup_typed(
671 const SimaPluginStaticManifestAccessor* accessor, const gchar* stage_id_or_name,
672 const gchar* element_name_fallback, SimaPluginStagePayloadKind expected_payload_kind) {
673 const SimaPluginStageSpec* stage =
674 sima_plugin_manifest_stage_lookup(accessor, stage_id_or_name, element_name_fallback);
675 if (!sima_plugin_manifest_stage_matches_payload_kind(stage, expected_payload_kind)) {
676 return NULL;
677 }
678 return stage;
679}
680
681static inline const SimaPluginStageSpec* sima_plugin_manifest_context_stage_lookup_typed_checked(
682 const GstContext* context, const gchar* stage_id_or_name, const gchar* element_name_fallback,
683 SimaPluginStagePayloadKind expected_payload_kind, SimaPluginManifestLookupStatus* status);
684
685static inline const SimaPluginStageSpec* sima_plugin_manifest_context_stage_lookup_typed(
686 const GstContext* context, const gchar* stage_id_or_name, const gchar* element_name_fallback,
687 SimaPluginStagePayloadKind expected_payload_kind) {
688 return sima_plugin_manifest_context_stage_lookup_typed_checked(
689 context, stage_id_or_name, element_name_fallback, expected_payload_kind, NULL);
690}
691
692static inline const SimaPluginStageSpec* sima_plugin_manifest_context_stage_lookup_typed_checked(
693 const GstContext* context, const gchar* stage_id_or_name, const gchar* element_name_fallback,
694 SimaPluginStagePayloadKind expected_payload_kind, SimaPluginManifestLookupStatus* status) {
695 const SimaPluginStaticManifestAccessor* accessor =
696 sima_plugin_manifest_context_accessor_checked(context, status);
697 if (!accessor) {
698 return NULL;
699 }
700 const SimaPluginStageSpec* stage =
701 sima_plugin_manifest_stage_lookup(accessor, stage_id_or_name, element_name_fallback);
702 if (!stage) {
703 sima_plugin_manifest_set_lookup_status(status,
705 return NULL;
706 }
707 if (!sima_plugin_manifest_stage_matches_payload_kind(stage, expected_payload_kind)) {
708 sima_plugin_manifest_set_lookup_status(
710 return NULL;
711 }
712 sima_plugin_manifest_set_lookup_status(status, SIMA_PLUGIN_MANIFEST_LOOKUP_STATUS_OK);
713 return stage;
714}
715
716static inline const gchar* sima_plugin_manifest_stage_name_from_id(const SimaPluginStageSpec* stage,
717 gint name_id) {
718 if (!stage || !stage->name_table || name_id < 0 ||
719 static_cast<guint>(name_id) >= stage->name_table_len) {
720 return NULL;
721 }
722 return stage->name_table[name_id];
723}
724
725static inline gint sima_plugin_stage_output_route_physical_index(const SimaPluginStageSpec* stage,
726 gint logical_index,
727 gint output_slot) {
728 if (!stage || !stage->logical_outputs || stage->logical_outputs_len == 0U) {
729 return -1;
730 }
731 for (guint i = 0; i < stage->logical_outputs_len; ++i) {
732 const SimaPluginLogicalTensor* logical = &stage->logical_outputs[i];
733 if (logical_index >= 0 && logical->logical_index == logical_index) {
734 return logical->physical_index;
735 }
736 if (output_slot >= 0 && logical->output_slot == output_slot) {
737 return logical->physical_index;
738 }
739 }
740 return -1;
741}
742
743static inline gint sima_plugin_stage_output_route_logical_index(const SimaPluginStageSpec* stage,
744 gint output_slot,
745 const gchar* cm_output_name,
746 const gchar* segment_name) {
747 if (!stage || !stage->logical_outputs || stage->logical_outputs_len == 0U) {
748 return -1;
749 }
750
751 if (cm_output_name && *cm_output_name) {
752 for (guint i = 0; i < stage->logical_outputs_len; ++i) {
753 const SimaPluginLogicalTensor* logical = &stage->logical_outputs[i];
754 if (logical->backend_name && g_strcmp0(logical->backend_name, cm_output_name) == 0) {
755 return logical->logical_index;
756 }
757 }
758 }
759
760 if (segment_name && *segment_name) {
761 for (guint i = 0; i < stage->logical_outputs_len; ++i) {
762 const SimaPluginLogicalTensor* logical = &stage->logical_outputs[i];
763 if (logical->segment_name && g_strcmp0(logical->segment_name, segment_name) == 0) {
764 return logical->logical_index;
765 }
766 }
767 }
768
769 if (output_slot >= 0) {
770 for (guint i = 0; i < stage->logical_outputs_len; ++i) {
771 const SimaPluginLogicalTensor* logical = &stage->logical_outputs[i];
772 if (logical->output_slot == output_slot) {
773 return logical->logical_index;
774 }
775 }
776 }
777
778 return -1;
779}
780
781#ifdef __cplusplus
782} /* extern "C" */
783#endif

Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.9.8.