ir_pb_converter.h#

Defines

fail_convert(...)#

Throws ConvertError with a formatted message.

namespace ONNX_LIGHT_NAMESPACE

Functions

void ExportModelProto(ModelProto *p_m, const std::shared_ptr<Graph> &g)#

Serializes an IR graph into a ModelProto.

The graph content is appended to p_m as a new graph entry and its opset imports are synchronized with graph opset versions.

Parameters:
  • p_m – Destination model proto.

  • g – Source IR graph.

std::unique_ptr<Graph> ImportModelProto(const ModelProto &mp)#

Converts the first graph in a ModelProto into the internal IR graph.

Throws:

ConvertError – When protobuf content cannot be represented in the internal IR.

Returns:

Imported graph represented as an internal IR graph.

ModelProto PrepareOutput(const ModelProto &mp_in)#

Produces a metadata-preserving model shell used by conversion pipelines.

This helper copies global model-level fields while leaving graphs empty so conversion passes can repopulate the graph with transformed content.

Returns:

ModelProto containing copied model-level metadata and no graph data.

void assertNonNull(const std::shared_ptr<Graph> &g)#

Validates that graph conversion returned a non-null graph pointer.

Triggers ONNX_ASSERTM when g is null.

class ConvertError : public std::runtime_error#
#include <ir_pb_converter.h>

Exception type used by the protobuf <-> IR conversion utilities.

The converter progressively appends context while unwinding nested conversion calls so the final error message points to the failing model location.

Public Functions

inline explicit ConvertError(const std::string &message)#
inline const char *what() const noexcept override#
inline void AppendContext(const std::string &context)#

Private Members

std::string expanded_message_#