printer.h#

Printing helpers for ONNX protobuf objects, including operator<< overloads for graphs, nodes, attributes, and tensors, as well as onnx_light::ProtoToString().

Declares stream-formatting helpers for ONNX protobuf structures.

This header exposes ostream operator overloads that render ONNX protobuf objects in a compact textual form for diagnostics and debugging, plus a helper template to convert supported protobuf objects to std::string.

namespace onnx_light

Alias that makes onnx-light headers compatible with code that references ONNX_LIGHT_NAMESPACE (the macro used in the standard onnx package).

Set to ONNX_LIGHT_NAMESPACE so both names resolve to the same namespace.

Symbol-visibility attribute for the public onnx-light C++ API.

Defined as empty because onnx-light does not require explicit __declspec(dllexport) or __attribute__((visibility("default"))) annotations — visibility is controlled at the shared-library level. The macro is provided so that vendored ONNX headers that decorate their declarations with ONNX_API compile without modification.

Namespace alias so that ONNX C++ code (and consumers such as onnxruntime) that refers to the literal onnx namespace — rather than the ONNX_NAMESPACE macro — resolves to the onnx-light namespace. The standard onnx package lives in namespace onnx; onnx-light uses onnx_light (via ONNX_LIGHT_NAMESPACE), so this alias keeps onnx-light a true drop-in. It is only introduced when the onnx-light namespace differs from onnx.

Functions

std::ostream &operator<<(std::ostream &os, const TensorShapeProto_Dimension &dim)#

Formats and writes a TensorShapeProto_Dimension to an output stream.

Parameters:
  • os – The destination stream.

  • dimDimension to format.

Returns:

A reference to os.

std::ostream &operator<<(std::ostream &os, const TensorShapeProto &shape)#

Formats and writes a TensorShapeProto to an output stream.

Parameters:
  • os – The destination stream.

  • shape – Shape to format.

Returns:

A reference to os.

std::ostream &operator<<(std::ostream &os, const TypeProto_Tensor &tensortype)#

Formats and writes a TypeProto_Tensor to an output stream.

Parameters:
  • os – The destination stream.

  • tensortypeTensor type to format.

Returns:

A reference to os.

std::ostream &operator<<(std::ostream &os, const TypeProto &type)#

Formats and writes a TypeProto to an output stream.

Parameters:
  • os – The destination stream.

  • type – Type to format.

Returns:

A reference to os.

std::ostream &operator<<(std::ostream &os, const TensorProto &tensor)#

Formats and writes a TensorProto to an output stream.

Parameters:
  • os – The destination stream.

  • tensorTensor to format.

Returns:

A reference to os.

std::ostream &operator<<(std::ostream &os, const ValueInfoProto &value_info)#

Formats and writes a ValueInfoProto to an output stream.

Parameters:
  • os – The destination stream.

  • value_infoValue info to format.

Returns:

A reference to os.

std::ostream &operator<<(std::ostream &os, const ValueInfoList &vilist)#

Formats and writes a ValueInfoList to an output stream.

Parameters:
  • os – The destination stream.

  • vilistValue info list to format.

Returns:

A reference to os.

std::ostream &operator<<(std::ostream &os, const AttributeProto &attr)#

Formats and writes an AttributeProto to an output stream.

Parameters:
  • os – The destination stream.

  • attr – Attribute to format.

Returns:

A reference to os.

std::ostream &operator<<(std::ostream &os, const AttrList &attrlist)#

Formats and writes an AttrList to an output stream.

Parameters:
  • os – The destination stream.

  • attrlist – Attribute list to format.

Returns:

A reference to os.

std::ostream &operator<<(std::ostream &os, const NodeProto &node)#

Formats and writes a NodeProto to an output stream.

Parameters:
  • os – The destination stream.

  • nodeNode to format.

Returns:

A reference to os.

std::ostream &operator<<(std::ostream &os, const NodeList &nodelist)#

Formats and writes a NodeList to an output stream.

Parameters:
  • os – The destination stream.

  • nodelistNode list to format.

Returns:

A reference to os.

std::ostream &operator<<(std::ostream &os, const GraphProto &graph)#

Formats and writes a GraphProto to an output stream.

Parameters:
  • os – The destination stream.

  • graphGraph to format.

Returns:

A reference to os.

std::ostream &operator<<(std::ostream &os, const FunctionProto &fn)#

Formats and writes a FunctionProto to an output stream.

Parameters:
  • os – The destination stream.

  • fn – Function to format.

Returns:

A reference to os.

std::ostream &operator<<(std::ostream &os, const ModelProto &model)#

Formats and writes a ModelProto to an output stream.

Parameters:
  • os – The destination stream.

  • model – Model to format.

Returns:

A reference to os.

template<typename ProtoType>
std::string ProtoToString(const ProtoType &proto)#

Converts a streamable ONNX protobuf object to its textual representation.

Template Parameters:

ProtoType – Type supporting the corresponding stream operator.

Parameters:

proto – Object to format.

Returns:

The formatted textual representation of proto.