Skip to main content

Model Class

Loaded form of an MPK; the simplified entry point to run inference on Modalix. More...

Declaration

class simaai::neat::Model { ... }

Included Headers

#include <Model.h>

Enumerations Index

enum classStage { ... }

Selector for fragment(Stage) and backend_fragment(Stage). More...

Friends Index

structinternal::ModelAccess

Public Constructors Index

Model (const std::string &mpk_path)

Load and validate an MPK at the given path with default options. More...

Model (const std::string &mpk_path, const Options &opt)

Load and validate an MPK with explicit options. More...

Model (Model &&) noexcept

Move-constructible. More...

Public Destructor Index

~Model ()

Destructor; releases the impl and (optionally) cleans up extracted MPK data. More...

Public Operators Index

Model &operator= (Model &&) noexcept

Move-assignable. (Models are not copyable.) More...

Public Member Functions Index

simaai::neat::NodeGrouppreprocess () const

Returns the preprocess portion of the model's pipeline as a NodeGroup. More...

simaai::neat::NodeGroupinference () const

Returns the MLA inference portion of the model's pipeline as a NodeGroup. More...

simaai::neat::NodeGrouppostprocess () const

Returns the postprocess portion of the model's pipeline as a NodeGroup. More...

simaai::neat::NodeGroupsession () const

Returns the model's full pipeline as a single NodeGroup (preprocess + inference + postprocess). More...

simaai::neat::NodeGroupsession (SessionOptions opt) const

Returns the model's full pipeline as a NodeGroup with custom session options. More...

TensorSpecinput_spec () const

Single-input convenience accessor for input_specs().front(). More...

std::vector< TensorSpec >input_specs () const

Returns the expected input tensor specs (one per ingress port for multi-input models). More...

TensorSpecoutput_spec () const

Single-output convenience accessor for output_specs().front(). More...

std::vector< TensorSpec >output_specs () const

Returns the produced output tensor specs (multiple for multi-head models). More...

intcompiled_batch_size () const

Returns the batch size the model was compiled with. More...

ResolvedPreprocessPlanresolved_preprocess_plan () const

Returns the full resolved preprocess plan (intent-driven; richer than preprocess_requirements()). More...

PreprocessRequirementspreprocess_requirements () const

Returns concrete preprocess parameters (resize, color, quant, tess) the model needs. More...

ModelInfoinfo () const

Returns the full diagnostic snapshot of the loaded model and its route. More...

std::unordered_map< std::string, std::string >metadata () const

Returns free-form key/value metadata declared by the model author in the manifest. More...

NodeGroupfragment (Stage stage) const

Returns one specific stage of the pipeline as a NodeGroup. More...

std::stringbackend_fragment (Stage stage) const

Returns the GStreamer launch fragment for one specific stage (debugging / Session::custom() use). More...

simaai::neat::InputOptionsinput_appsrc_options (bool tensor_mode) const

Returns the appsrc input options the planner derived for a given input mode (tensor or media). More...

std::vector< simaai::neat::InputOptions >input_appsrc_options_list (bool tensor_mode) const

Per-input variant of input_appsrc_options for multi-input models. More...

std::stringfind_config_path_by_plugin (const std::string &plugin_id) const

Find the path to a per-stage config file in the extracted MPK by plugin ID. More...

std::stringfind_config_path_by_processor (const std::string &processor) const

Find the path to a per-stage config file in the extracted MPK by processor name (CVU/MLA/APU). More...

std::stringinfer_output_name () const

Returns the canonical output element name for the inference stage (used in pipeline string emission). More...

Runnerbuild ()

Build a long-lived Runner from this Model with default options. More...

Runnerbuild (const SessionOptions &opt)

Build a Runner with explicit session options. More...

Runnerbuild (const simaai::neat::RunOptions &run_opt)

Build a Runner with explicit runtime options. More...

Runnerbuild (const SessionOptions &opt, const simaai::neat::RunOptions &run_opt)

Build a Runner with explicit session and runtime options. More...

Runnerbuild (const simaai::neat::TensorList &inputs, const SessionOptions &opt=default_session_options(), const simaai::neat::RunOptions &run_opt=default_run_options())

Build a Runner and seed the build with sample input(s). More...

Runnerbuild (const simaai::neat::SampleList &inputs, const SessionOptions &opt=default_session_options(), const simaai::neat::RunOptions &run_opt=default_run_options())

Build variant that seeds with full Sample inputs (carrying per-buffer metadata). More...

simaai::neat::TensorListrun (const simaai::neat::TensorList &inputs, int timeout_ms=-1)

One-shot inference: build, push, pull, return — for the simplest applications. More...

simaai::neat::SampleListrun (const simaai::neat::SampleList &inputs, int timeout_ms=-1)

One-shot inference with full Sample inputs. More...

Private Member Attributes Index

std::unique_ptr< Impl >impl_

Private Static Functions Index

static const SessionOptions &default_session_options ()
static const simaai::neat::RunOptions &default_run_options ()

Description

Loaded form of an MPK; the simplified entry point to run inference on Modalix.

A Model owns an extracted MPK directory, the parsed manifest, and the route plan derived from it. Once constructed it exposes:

  • **NodeGroup fragments** — preprocess(), inference(), postprocess(), session() — for composing into a user-built Session.
  • **run(input)** convenience methods that build a one-shot Session, push the input, pull the result, and tear down. The shortest path from "I have a tensor" to "here are detections."
  • **build(...)** that returns a long-lived Runner for streaming use cases (push many inputs over time, pull results asynchronously).
  • Introspection (input_spec(), output_spec(), info(), metadata()) so application code can ask the Model what shape/dtype/topology it expects and produces.
 sima::Model model("/models/yolov8.tar.gz");
 auto result = model.run(input_tensor); // shortest path

For applications that need more control (custom pre/post nodes, multiple cameras, RTSP server output), graduate from Model::run() to composing a Session that includes model.session() plus your own input/output nodes.

See Also

Session

See Also

"Model is a Session in disguise" (§0.12 of the design deep dive)

Definition at line 77 of file Model.h.

Enumerations

Stage

enum class simaai::neat::Model::Stage
strong

Selector for fragment(Stage) and backend_fragment(Stage).

Enumeration values
PreprocessPre-MLA portion only (resize, color-convert, normalize, quant, tess)
InferenceMLA inference stage only
PostprocessPost-MLA portion only (detess, dequant, cast, BoxDecode if applicable)
FullFull pipeline: Preprocess + Inference + Postprocess

Lets advanced users grab one specific portion of the model's pipeline.

Definition at line 315 of file Model.h.

315 enum class Stage {
317 Inference,
319 Full
320 };

Friends

internal::ModelAccess

friend struct internal::ModelAccess

Definition at line 578 of file Model.h.

578 friend struct internal::ModelAccess;

Public Constructors

Model()

simaai::neat::Model::Model (const std::string & mpk_path)
explicit

Load and validate an MPK at the given path with default options.

Equivalent to Model(mpk_path, Options{}). The constructor extracts the tarball, validates the manifest (rejecting malformed or malicious archives), and runs the route planner. Throws SessionError on any failure (with a structured SessionReport).

Parameters
mpk_path

Filesystem path to a .tar.gz / .tgz / .mpk / .tar file.

Exceptions
<a href="/reference/cppapi/classes/simaai-neat-sessionerror">SessionError</a>

on archive validation failure, manifest parse error, or unsupported route.

Definition at line 332 of file Model.h.

Model()

simaai::neat::Model::Model (const std::string & mpk_path, const Options & opt)
explicit

Load and validate an MPK with explicit options.

Parameters
mpk_path

Filesystem path to a .tar.gz / .tgz / .mpk / .tar file.

opt

Options controlling preprocess, postprocess decode, naming, lifecycle, and verbosity.

Exceptions
<a href="/reference/cppapi/classes/simaai-neat-sessionerror">SessionError</a>

on archive validation failure, manifest parse error, or unsupported route.

Definition at line 341 of file Model.h.

Model()

simaai::neat::Model::Model (Model &&)
noexcept

Move-constructible.

Definition at line 343 of file Model.h.

Public Destructor

~Model()

simaai::neat::Model::~Model ()

Destructor; releases the impl and (optionally) cleans up extracted MPK data.

Definition at line 345 of file Model.h.

Public Operators

operator=()

Model & simaai::neat::Model::operator= (Model &&)
noexcept

Move-assignable. (Models are not copyable.)

Definition at line 344 of file Model.h.

Public Member Functions

backend_fragment()

std::string simaai::neat::Model::backend_fragment (Stage stage)

Returns the GStreamer launch fragment for one specific stage (debugging / Session::custom() use).

Definition at line 396 of file Model.h.

build()

Runner simaai::neat::Model::build ()

Build a long-lived Runner from this Model with default options.

Use this for streaming workloads (push many inputs over time, pull asynchronously). For one-shot inference, prefer run().

Returns

A Runner ready for push/pull.

Exceptions
<a href="/reference/cppapi/classes/simaai-neat-sessionerror">SessionError</a>

on validation or build failure (with structured SessionReport).

Definition at line 523 of file Model.h.

build()

Runner simaai::neat::Model::build (const SessionOptions & opt)

Build a Runner with explicit session options.

Definition at line 525 of file Model.h.

build()

Runner simaai::neat::Model::build (const simaai::neat::RunOptions & run_opt)

Build a Runner with explicit runtime options.

Definition at line 527 of file Model.h.

build()

Runner simaai::neat::Model::build (const SessionOptions & opt, const simaai::neat::RunOptions & run_opt)

Build a Runner with explicit session and runtime options.

Definition at line 529 of file Model.h.

build()

Runner simaai::neat::Model::build (const simaai::neat::TensorList & inputs, const SessionOptions & opt=default_session_options(), const simaai::neat::RunOptions & run_opt=default_run_options())

Build a Runner and seed the build with sample input(s).

Seeding the build with an input lets the planner perform build-time adaptation: tightening caps to match the actual input shape, picking concrete pixel formats, validating that the input is compatible. The BuildAdaptationSummary in the resulting SessionReport records what adaptations were applied.

Parameters
inputs

One Tensor per ingress port. For single-input models pass a single-element list.

opt

Session options (defaults are sensible).

run_opt

Runtime options (queue depth, overflow policy, async/sync mode).

Definition at line 543 of file Model.h.

build()

Runner simaai::neat::Model::build (const simaai::neat::SampleList & inputs, const SessionOptions & opt=default_session_options(), const simaai::neat::RunOptions & run_opt=default_run_options())

Build variant that seeds with full Sample inputs (carrying per-buffer metadata).

Definition at line 547 of file Model.h.

compiled_batch_size()

int simaai::neat::Model::compiled_batch_size ()

Returns the batch size the model was compiled with.

Defaults to 1 when the model is not batched. Callers that drive multiple logical inferences per push/pull cycle should use this to size their input batches. The same value is prepended to input_specs()[i].shape when batch > 1.

Definition at line 380 of file Model.h.

find_config_path_by_plugin()

std::string simaai::neat::Model::find_config_path_by_plugin (const std::string & plugin_id)

Find the path to a per-stage config file in the extracted MPK by plugin ID.

Definition at line 403 of file Model.h.

find_config_path_by_processor()

std::string simaai::neat::Model::find_config_path_by_processor (const std::string & processor)

Find the path to a per-stage config file in the extracted MPK by processor name (CVU/MLA/APU).

Definition at line 405 of file Model.h.

fragment()

NodeGroup simaai::neat::Model::fragment (Stage stage)

Returns one specific stage of the pipeline as a NodeGroup.

Definition at line 393 of file Model.h.

infer_output_name()

std::string simaai::neat::Model::infer_output_name ()

Returns the canonical output element name for the inference stage (used in pipeline string emission).

Definition at line 408 of file Model.h.

inference()

simaai::neat::NodeGroup simaai::neat::Model::inference ()

Returns the MLA inference portion of the model's pipeline as a NodeGroup.

Definition at line 351 of file Model.h.

info()

ModelInfo simaai::neat::Model::info ()

Returns the full diagnostic snapshot of the loaded model and its route.

Definition at line 387 of file Model.h.

input_appsrc_options()

simaai::neat::InputOptions simaai::neat::Model::input_appsrc_options (bool tensor_mode)

Returns the appsrc input options the planner derived for a given input mode (tensor or media).

Definition at line 399 of file Model.h.

input_appsrc_options_list()

std::vector< simaai::neat::InputOptions > simaai::neat::Model::input_appsrc_options_list (bool tensor_mode)

Per-input variant of input_appsrc_options for multi-input models.

Definition at line 401 of file Model.h.

input_spec()

TensorSpec simaai::neat::Model::input_spec ()

Single-input convenience accessor for input_specs().front().

Definition at line 366 of file Model.h.

input_specs()

std::vector< TensorSpec > simaai::neat::Model::input_specs ()

Returns the expected input tensor specs (one per ingress port for multi-input models).

Definition at line 368 of file Model.h.

metadata()

std::unordered_map< std::string, std::string > simaai::neat::Model::metadata ()

Returns free-form key/value metadata declared by the model author in the manifest.

Definition at line 389 of file Model.h.

output_spec()

TensorSpec simaai::neat::Model::output_spec ()

Single-output convenience accessor for output_specs().front().

Definition at line 370 of file Model.h.

output_specs()

std::vector< TensorSpec > simaai::neat::Model::output_specs ()

Returns the produced output tensor specs (multiple for multi-head models).

Definition at line 372 of file Model.h.

postprocess()

simaai::neat::NodeGroup simaai::neat::Model::postprocess ()

Returns the postprocess portion of the model's pipeline as a NodeGroup.

Definition at line 353 of file Model.h.

preprocess()

simaai::neat::NodeGroup simaai::neat::Model::preprocess ()

Returns the preprocess portion of the model's pipeline as a NodeGroup.

Definition at line 349 of file Model.h.

preprocess_requirements()

PreprocessRequirements simaai::neat::Model::preprocess_requirements ()

Returns concrete preprocess parameters (resize, color, quant, tess) the model needs.

Definition at line 385 of file Model.h.

resolved_preprocess_plan()

ResolvedPreprocessPlan simaai::neat::Model::resolved_preprocess_plan ()

Returns the full resolved preprocess plan (intent-driven; richer than preprocess_requirements()).

Definition at line 383 of file Model.h.

run()

simaai::neat::TensorList simaai::neat::Model::run (const simaai::neat::TensorList & inputs, int timeout_ms=-1)

One-shot inference: build, push, pull, return — for the simplest applications.

Equivalent to build(inputs).run(inputs, timeout_ms) but cheaper because the Runner is scoped to the call. Use this for unit tests, single-image inference, batch processing.

Parameters
inputs

Input tensors (one per ingress port).

timeout_ms

Maximum wait for the result, in milliseconds; -1 waits forever.

Returns

The output tensor list.

Exceptions
<a href="/reference/cppapi/classes/simaai-neat-sessionerror">SessionError</a>

on build failure or pull timeout/error.

Definition at line 569 of file Model.h.

run()

simaai::neat::SampleList simaai::neat::Model::run (const simaai::neat::SampleList & inputs, int timeout_ms=-1)

One-shot inference with full Sample inputs.

Definition at line 571 of file Model.h.

session()

simaai::neat::NodeGroup simaai::neat::Model::session ()

Returns the model's full pipeline as a single NodeGroup (preprocess + inference + postprocess).

Definition at line 356 of file Model.h.

session()

simaai::neat::NodeGroup simaai::neat::Model::session (SessionOptions opt)

Returns the model's full pipeline as a NodeGroup with custom session options.

Parameters
opt

Per-call overrides for appsrc/appsink inclusion, naming, and CVU run-target preference.

Definition at line 362 of file Model.h.

Private Member Attributes

impl_

std::unique_ptr<Impl> simaai::neat::Model::impl_

Definition at line 580 of file Model.h.

580 std::unique_ptr<Impl> impl_;

Private Static Functions

default_run_options()

const simaai::neat::RunOptions & simaai::neat::Model::default_run_options ()
static

Definition at line 511 of file Model.h.

default_session_options()

const SessionOptions & simaai::neat::Model::default_session_options ()
static

Definition at line 510 of file Model.h.


The documentation for this class was generated from the following file:


Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.9.8.