shape_reduction.h#
Shape-inference functions for ONNX operators in the reduction family.
-
namespace ONNX_LIGHT_NAMESPACE
-
namespace onnx_optim
-
namespace shapes
-
namespace reduction#
Functions
-
void ComputeShapeReduceSum(ShapesContext &ctx, const NodeProto &node, const char *data, const char *axes)#
Computes the output :cpp:class:
OptimTensorof aReduceSumnode and stores it inctx.ReduceSumreduces the input tensor along a set of axes. The output dtype always matches the input dtype (type constraintT); the output shape is the input shape with the reduced axes either dropped (keepdims=0) or replaced by1(keepdims=1, the default).The way axes are specified depends on the opset:
opset < 13:
axesis a repeated INTS attribute. If absent every dimension is reduced.opset >= 13:
axesis an optional second input. When the input is missing or empty the behaviour is controlled by thenoop_with_empty_axesattribute (default0):0means reduce all axes,1means identity (no axes reduced).When the
axesinput is provided this function looks at the :cpp:func:OptimTensor::ValueAsShapeannotation ofaxesto identify the reduced axes. If the annotation is missing the output rank can still be inferred whenkeepdims=1(same rank as the input, with each previously-known dimension kept as is and reduced positions left symbolic) or when the number of axes is known via the shape ofaxes(keepdims=0: output rank = input rank − number of axes, with every dimension marked symbolic).
- Parameters:
ctx – In/out context. Must already contain an entry for
dataand, when provided and non-empty,axes. On return it also contains an entry fornode.output(0).node – The
ReduceSumNodeProtowhose output should be described.node.op_type()must be"ReduceSum"andnodemust declare at least one output.data – Name of the data input value to read from
ctx. Must be present inctx.axes – Name of the axes input value to read from
ctxfor opset >= 13, ornullptr/ empty string when the axes input is omitted (use the attribute / default “reduce all” behaviour). For opset < 13 the value is ignored and theaxesattribute is consulted.
- Throws:
-
void ComputeShapeReduceSum(ShapesContext &ctx, const NodeProto &node, const char *data, const char *axes)#
-
namespace reduction#
-
namespace shapes
-
namespace onnx_optim