shape_image.h#

Shape-inference functions for ONNX operators in the image family.

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.

namespace onnx_optim
namespace shapes
namespace image#

Functions

void ComputeShapeImageDecoder(ShapesContext &ctx, const NodeProto &node, const char *a)#

Computes the output :cpp:class:OptimTensor of an ImageDecoder node and stores it in ctx.

ImageDecoder (since opset 20 in the ai.onnx domain) takes a 1-D tensor(uint8) carrying an encoded image bytestream and returns the decoded image as a 3-D tensor(uint8) laid out as (Height, Width, Channels). The spatial extent of the decoded image only becomes known at runtime, so the output’s H and W dimensions are produced as symbolic dims; the channel count is derived from the pixel_format attribute ("Grayscale" ⇒ 1, "RGB"/"BGR" ⇒ 3, defaulting to "RGB" when omitted).

Parameters:
  • ctx – In/out context. Must already contain an :cpp:class:OptimTensor entry for a; on return it also contains an entry for node.output(0).

  • node – The ImageDecoder NodeProto whose output should be described. node.op_type() must be "ImageDecoder" and node must declare at least one output.

  • a – Name of the input value to read from ctx.

Throws:
  • std::invalid_argument – if node.op_type() is not "ImageDecoder", if node has no output, if the input tensor is not 1-dimensional, or if pixel_format is not one of "RGB", "BGR" or "Grayscale".

  • std::out_of_range – if a is missing from ctx.