shape_optional.h#
Shape-inference functions for ONNX operators in the optional family.
-
namespace ONNX_LIGHT_NAMESPACE
-
namespace onnx_optim
-
namespace shapes
-
namespace optional#
Functions
-
void ComputeShapeOptional(ShapesContext &ctx, const NodeProto &node)#
Computes the output :cpp:class:
OptimTensorof anOptionalnode and stores it inctx.Optional(since opset 15) wraps a value into an optional-type output. The wrapped element type is determined either by the input value (when an input is provided) or by thetypeTypeProtoattribute (when no input is provided). Since :cpp:class:OptimTensordoes not model optional or sequence types, this implementation only supports the tensor-element path: the output descriptor mirrors the dtype and shape of the wrapped tensor.Supported cases:
nodehas one input: the output dtype and shape are copied from the input descriptor stored inctx.nodehas no input and thetypeattribute wraps a tensor type (either directly or as theelem_typeof anoptional_type): the output dtype and shape are taken from the attribute.
- Parameters:
ctx – In/out context. When the node has an input,
ctxmust already contain an entry for it; on returnctxcontains an entry fornode.output(0).node – The
OptionalNodeProtowhose output should be described.node.op_type()must be"Optional"andnodemust declare exactly one output.
- Throws:
-
void ComputeShapeOptional(ShapesContext &ctx, const NodeProto &node)#
-
namespace optional#
-
namespace shapes
-
namespace onnx_optim