Skip to content

sgns::neoswarm::core::SGProcessingBridge

Constructs GNUS_Schema-compliant JSON and submits inference jobs to SGProcessingManager (Phase 1 direct) or the GNUS network (Phase 2).

#include <sg_processing_bridge.hpp>

Public Classes

Name
struct Config

Public Functions

Name
SGProcessingBridge()
SGProcessingBridge(Config cfg)
~SGProcessingBridge() =default
void SetClient(network::SGClient * client)
Set the SGClient for Phase 2 network dispatch.
outcome::result< std::string > BuildSchemaJson(const std::string & model_uri, const std::string & input_uri, sgns::InputFormat input_format, const std::vector< int64_t > & shape, int64_t total_width =0, int64_t chunk_stride =0) const
Build a GNUS_Schema JSON string from the supplied parameters.
outcome::result< std::vector< uint8_t > > SubmitJob(const std::string & model_uri, const std::string & input_uri, sgns::InputFormat input_format, const std::vector< int64_t > & shape, std::shared_ptr< boost::asio::io_context > ioc, int64_t total_width =0, int64_t chunk_stride =0)
Submit a job and return raw tensor output bytes.
outcome::result< std::vector< uint8_t > > SubmitDirect(const std::string & jsondata, std::shared_ptr< boost::asio::io_context > ioc) const
Run a pre-built GNUS_Schema JSON through the local direct-call path (Phase 13, SGF-01: exposed for tests/integrations that need to inject schema parameters — e.g. the MNN session backend selector — which SubmitJob's schema builder does not emit).

Public Functions Documentation

function SGProcessingBridge

SGProcessingBridge()

function SGProcessingBridge

explicit SGProcessingBridge(
    Config cfg
)

function ~SGProcessingBridge

~SGProcessingBridge() =default

function SetClient

void SetClient(
    network::SGClient * client
)

Set the SGClient for Phase 2 network dispatch.

Parameters:

  • client The SGClient instance (owned by ApiServer).

function BuildSchemaJson

outcome::result< std::string > BuildSchemaJson(
    const std::string & model_uri,
    const std::string & input_uri,
    sgns::InputFormat input_format,
    const std::vector< int64_t > & shape,
    int64_t total_width =0,
    int64_t chunk_stride =0
) const

Build a GNUS_Schema JSON string from the supplied parameters.

Parameters:

  • model_uri IPFS URI or path to the MNN model.
  • input_uri IPFS URI or path to the input data.
  • input_format Tensor element format.
  • shape Tensor shape dimensions (one block/window's shape).
  • total_width Total input element count, for inputs processed as multiple windows over data wider than one block. 0 => derive from shape (product of its dims), i.e. the whole input is one block.
  • chunk_stride Step between window starts. 0 => defaults to shape.back() (the block length), i.e. non-overlapping windows.

Return: JSON string or InvalidArgument.

function SubmitJob

outcome::result< std::vector< uint8_t > > SubmitJob(
    const std::string & model_uri,
    const std::string & input_uri,
    sgns::InputFormat input_format,
    const std::vector< int64_t > & shape,
    std::shared_ptr< boost::asio::io_context > ioc,
    int64_t total_width =0,
    int64_t chunk_stride =0
)

Submit a job and return raw tensor output bytes.

Parameters:

  • model_uri IPFS URI or path to the MNN model.
  • input_uri IPFS URI or path to the input data.
  • input_format Tensor element format.
  • shape Tensor shape dimensions (one block/window's shape).
  • ioc Boost ASIO io_context for async operations.
  • total_width Total input element count; see BuildSchemaJson().
  • chunk_stride Step between window starts; see BuildSchemaJson().

Return: Raw output bytes or InferenceFailed / NotImplemented.

Phase 1 (m_networkMode=false): calls ProcessingManager::Create + Process. Phase 2 (m_networkMode=true): dispatches via gRPCForSuperGenius (stub).

function SubmitDirect

outcome::result< std::vector< uint8_t > > SubmitDirect(
    const std::string & jsondata,
    std::shared_ptr< boost::asio::io_context > ioc
) const

Run a pre-built GNUS_Schema JSON through the local direct-call path (Phase 13, SGF-01: exposed for tests/integrations that need to inject schema parameters — e.g. the MNN session backend selector — which SubmitJob's schema builder does not emit).

Parameters:

  • jsondata GNUS_Schema JSON (e.g. from BuildSchemaJson, patched).
  • ioc Boost ASIO io_context for async operations.

Return: Raw output bytes or InferenceFailed.

Calls ProcessingManager::Create() + Process() directly — the exact same body SubmitJob() reaches when m_networkMode is false.


Updated on 2026-10-09 at 03:59:42 +0000