shape_nn.h#
Shape-inference functions for ONNX operators in the nn 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_NAMESPACEso 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 withONNX_APIcompile without modification.Namespace alias so that ONNX C++ code (and consumers such as onnxruntime) that refers to the literal
onnxnamespace — rather than theONNX_NAMESPACEmacro — resolves to the onnx-light namespace. The standard onnx package lives innamespace onnx; onnx-light usesonnx_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 fromonnx.-
namespace onnx_optim
-
namespace shapes
-
namespace nn#
Functions
-
void ComputeShapeAveragePool(ShapesContext &ctx, const NodeProto &node, const char *x)#
Computes the output :cpp:class:
OptimTensorof anAveragePoolnode and stores it inctx.The output dtype matches the input dtype. The output rank is the input rank (
[N, C, D1, ..., Dk]). The first two output dimensions (NandC) are copied from the input. For each spatial axisithe output dimension is computed from thekernel_shape,strides,pads, andceil_modeattributes using the same rule as :cpp:func:onnx_kernels::kernel::AveragePooland ONNX Runtime: whenceil_mode=1and the last sliding window would start entirely in the right padded region, it is dropped.auto_padother than the default"NOTSET"(or"VALID") is not supported, and symbolic spatial dimensions propagate symbolically.- Parameters:
ctx – In/out context. Must already contain an entry for
x; on return it also contains an entry fornode.output(0).node – The
AveragePoolNodeProtowhose output should be described.node.op_type()must be"AveragePool"andnodemust declare at least one output.x – Name of the input value to read from
ctx. Must be present inctx.
- Throws:
std::invalid_argument – if
node.op_type()is not"AveragePool", ifnodehas no output, if the input rank is inconsistent with the (required)kernel_shapeattribute, or ifauto_padis set to a value other than"NOTSET"/"VALID"(only explicitpadsare supported).std::out_of_range – if
xis not present inctx.
-
void ComputeShapeLpPool(ShapesContext &ctx, const NodeProto &node, const char *x)#
Computes the output :cpp:class:
OptimTensorof anLpPoolnode and stores it inctx.The output dtype matches the input dtype and the output shape is computed identically to :cpp:func:
ComputeShapeAveragePool(the two operators share the samekernel_shape/strides/pads/dilations/ceil_mode/auto_padattribute schema;LpPoolhas an extrapattribute that does not affect the output shape).- Parameters:
ctx – In/out context. Must already contain an entry for
x; on return it also contains an entry fornode.output(0).node – The
LpPoolNodeProtowhose output should be described.node.op_type()must be"LpPool"andnodemust declare at least one output.x – Name of the input value to read from
ctx. Must be present inctx.
- Throws:
-
void ComputeShapeGlobalPool(ShapesContext &ctx, const NodeProto &node, const char *x)#
Computes the output :cpp:class:
OptimTensorof a global pooling node (GlobalAveragePool,GlobalMaxPool, orGlobalLpPool) and stores it inctx.The output dtype matches the input dtype. The output rank equals the input rank. The first two output dimensions (
NandC) are copied from the input; all remaining spatial dimensions are set to1.- Parameters:
ctx – In/out context. Must already contain an entry for
x; on return it also contains an entry fornode.output(0).node – The global pooling
NodeProtowhose output should be described.node.op_type()must be one of"GlobalAveragePool","GlobalMaxPool"or"GlobalLpPool"andnodemust declare at least one output.x – Name of the input value to read from
ctx. Must be present inctx.
- Throws:
-
void ComputeShapeFlatten(ShapesContext &ctx, const NodeProto &node, const char *x)#
Computes the output :cpp:class:
OptimTensorof aFlattennode and stores it inctx.The output dtype matches the input dtype. The output shape is always rank 2:
(prod(input.shape[0:axis]), prod(input.shape[axis:rank])), whereaxisis the integer attribute (default1) and may be negative (counted from the back). Symbolic dimensions propagate symbolically — when any contributing dim is symbolic the corresponding output dim becomes a fresh symbolic expression.- Parameters:
ctx – In/out context. Must already contain an entry for
x; on return it also contains an entry fornode.output(0).node – The
FlattenNodeProtowhose output should be described.node.op_type()must be"Flatten"andnodemust declare at least one output.x – Name of the input value to read from
ctx. Must be present inctx.
- Throws:
-
void ComputeShapeLRN(ShapesContext &ctx, const NodeProto &node, const char *x)#
Computes the output :cpp:class:
OptimTensorof anLRN(Local Response Normalization) node and stores it inctx.The output dtype and shape match the input dtype and shape. The input must have rank
>= 2(N,C,D1, …,Dk).- Parameters:
ctx – In/out context. Must already contain an entry for
x; on return it also contains an entry fornode.output(0).node – The
LRNNodeProtowhose output should be described.node.op_type()must be"LRN"andnodemust declare at least one output.x – Name of the input value to read from
ctx. Must be present inctx.
- Throws:
-
void ComputeShapeLpNormalization(ShapesContext &ctx, const NodeProto &node, const char *x)#
Computes the output :cpp:class:
OptimTensorof anLpNormalizationnode and stores it inctx.The output dtype and shape match the input dtype and shape. The input must have rank
>= 1.- Parameters:
ctx – In/out context. Must already contain an entry for
x; on return it also contains an entry fornode.output(0).node – The
LpNormalizationNodeProtowhose output should be described.node.op_type()must be"LpNormalization"andnodemust declare at least one output.x – Name of the input value to read from
ctx. Must be present inctx.
- Throws:
-
void ComputeShapeBatchNormalization(ShapesContext &ctx, const NodeProto &node, const char *x, const char *input_mean)#
Computes the output :cpp:class:
OptimTensorof aBatchNormalizationnode and stores it inctx.The op has between 1 and 5 outputs depending on opset / mode. The first output
Yalways has the same dtype and shape asX. The additional outputs are 1-D tensors of size equal to the channel dimensionC(the dim at index 1 ofXwhenXhas rank >= 2;1otherwise, per the opset-9+ rule). Output dtypes follow the upstream spec:opset 1..9: every extra output uses the same dtype as
X(typeT).opset 14: outputs 1/2 (
running_mean/running_var) take the dtype ofinput_mean/input_var(typeU).opset 15+: outputs 1/2 (
running_mean/running_var) take the dtype ofinput_mean/input_var(typeT2).
The
training_modeattribute (opset 14+) and the legacyis_testattribute (opset 1, 6) are honored to decide whether extra outputs are required. Only the channel-dim of the secondary outputs is inferred; for a symbolic channel dim a fresh symbolic expressionBatchNormalization.C(<expr>)is propagated.- Parameters:
ctx – In/out context. Must already contain an entry for
x; on return it also contains an entry for each declared output ofnode.node – The
BatchNormalizationNodeProto.node.op_type()must be"BatchNormalization"and at least one output must be declared.x – Name of the data input value to read from
ctx.input_mean – Name of the mean input value (used to obtain the dtype of the secondary outputs from opset 14 onward). May be
nullptrif not needed (opset < 14 fallback).
- Throws:
-
void ComputeShapeInstanceNormalization(ShapesContext &ctx, const NodeProto &node, const char *x)#
Computes the output :cpp:class:
OptimTensorof anInstanceNormalizationnode and stores it inctx.The output dtype and shape are always inherited from input
X.scaleandBinputs are not read for shape inference.- Parameters:
ctx – In/out context. Must already contain an entry for
x; on return it also contains an entry fornode.output(0).node – The
InstanceNormalizationNodeProto.node.op_type()must be"InstanceNormalization"andnodemust declare at least one output.x – Name of the data input value to read from
ctx.
- Throws:
-
void ComputeShapeGroupNormalization(ShapesContext &ctx, const NodeProto &node, const char *x)#
Computes the output :cpp:class:
OptimTensorof aGroupNormalizationnode and stores it inctx.The output dtype and shape are always inherited from input
X.scaleandbiasinputs are not read for shape inference.- Parameters:
ctx – In/out context. Must already contain an entry for
x; on return it also contains an entry fornode.output(0).node – The
GroupNormalizationNodeProto.node.op_type()must be"GroupNormalization"andnodemust declare at least one output.x – Name of the data input value to read from
ctx.
- Throws:
-
void ComputeShapeMeanVarianceNormalization(ShapesContext &ctx, const NodeProto &node, const char *x)#
Computes the output :cpp:class:
OptimTensorof aMeanVarianceNormalizationnode and stores it inctx.The output dtype and shape are always inherited from input
X.- Parameters:
ctx – In/out context. Must already contain an entry for
x; on return it also contains an entry fornode.output(0).node – The
MeanVarianceNormalizationNodeProto.x – Name of the data input value to read from
ctx.
- Throws:
-
void ComputeShapeRMSNormalization(ShapesContext &ctx, const NodeProto &node, const char *x)#
Computes the output :cpp:class:
OptimTensorof anRMSNormalizationnode and stores it inctx.The output dtype and shape are always inherited from input
X. Thescaleinput is not read for shape inference.- Parameters:
ctx – In/out context. Must already contain an entry for
x; on return it also contains an entry fornode.output(0).node – The
RMSNormalizationNodeProto.node.op_type()must be"RMSNormalization"andnodemust declare at least one output.x – Name of the data input value to read from
ctx.
- Throws:
-
void ComputeShapeLayerNormalization(ShapesContext &ctx, const NodeProto &node, const char *x)#
Computes the output :cpp:class:
OptimTensorof aLayerNormalizationnode and stores it inctx.Output 0 (
Y) always inheritsX’s dtype and shape. The optional outputsMean(output 1) andInvStdDev(output 2) have dtypestash_type(defaultFLOAT) and shape[d[0], ..., d[axis-1], 1, ..., 1](rank == rank(X)).- Parameters:
ctx – In/out context. Must already contain an entry for
x; on return it also contains an entry for every non-emptynode.output(i)(i = 0, 1, 2).node – The
LayerNormalizationNodeProto.node.op_type()must be"LayerNormalization"andnodemust declare at least one output.x – Name of the data input value to read from
ctx.
- Throws:
-
void ComputeShapeDropout(ShapesContext &ctx, const NodeProto &node, const char *data, const char *ratio = nullptr, const char *training_mode = nullptr)#
Computes the output :cpp:class:
OptimTensor(s) of aDropoutnode and stores them inctx.outputalways has the same dtype and shape asdata. If the optional second outputmaskis present and non-empty, it has dtypeTensorType::kBooland the same shape asdata. Optional inputsratioandtraining_modemust be scalars when present.
-
void ComputeShapeRoiAlign(ShapesContext &ctx, const NodeProto &node, const char *x, const char *rois, const char *batch_indices)#
Computes the output :cpp:class:
OptimTensorof aRoiAlignnode and stores it inctx.The output dtype matches the input feature-map dtype. The output shape is
(num_rois, C, output_height, output_width)wherenum_roisis taken from dim 0 ofrois(or, when that dim is symbolic andbatch_indicesdim 0 is static, frombatch_indices);Cis taken from dim 1 ofx; and the spatial sizes come from theoutput_height/output_widthattributes (default 1).- Parameters:
ctx – In/out context. Must already contain entries for
x,rois, andbatch_indices; on return it also contains an entry fornode.output(0).node – The
RoiAlignNodeProtowhose output should be described.node.op_type()must be"RoiAlign"andnodemust declare at least one output.x – Name of the feature-map input value (rank 4) to read from
ctx. Must be present inctx.rois – Name of the RoIs input value (rank 2) to read from
ctx. Must be present inctx.batch_indices – Name of the batch-indices input value (rank 1) to read from
ctx. Must be present inctx.
- Throws:
-
void ComputeShapeNonMaxSuppression(ShapesContext &ctx, const NodeProto &node, const char *boxes, const char *scores)#
Computes the output :cpp:class:
OptimTensorof aNonMaxSuppressionnode and stores it inctx.The output dtype is always
TensorType::kInt64. The output shape is always rank 2:(num_selected_indices, 3)wherenum_selected_indicesis a fresh symbolic expression because it depends on the runtime values of the inputs. The optionalmax_output_boxes_per_class,iou_thresholdandscore_thresholdinputs are not read by shape inference and may be omitted fromctx.- Parameters:
ctx – In/out context. Must already contain entries for
boxesandscores; on return it also contains an entry fornode.output(0).node – The
NonMaxSuppressionNodeProtowhose output should be described.node.op_type()must be"NonMaxSuppression"andnodemust declare at least one output.boxes – Name of the boxes input (rank 3, last dim == 4) in
ctx.scores – Name of the scores input (rank 3) in
ctx.
- Throws:
-
void ComputeShapeRNN(ShapesContext &ctx, const NodeProto &node, const char *x, const char *r)#
Computes the output :cpp:class:
OptimTensor(s) of anRNN,GRUorLSTMnode and stores them inctx. The three operators share the same output-shape semantics — only the number of outputs differs (RNN/GRUexposeYandY_h;LSTMalso exposesY_c).The output dtypes are inherited from
X. Shapes follow the upstreamRNNShapeInferencerules:Read
direction("forward"(default),"reverse"or"bidirectional") to derivenum_directions(1 or 2). Unknown values leavenum_directionssymbolic.Read
hidden_size; when missing or non-positive, fall back toR.shape[2](the recurrence weight’s last dim) when known.Read
layout(default 0). Forlayout=0deriveseq_lengthandbatch_sizefromX.shape[0]andX.shape[1]; forlayout=1the order is reversed.
Yhas rank 4 ([seq_length, num_directions, batch_size, hidden_size]forlayout=0;[batch_size, seq_length, num_directions, hidden_size]forlayout=1).Y_h(andY_c, forLSTM) has rank 3 ([num_directions, batch_size, hidden_size]forlayout=0;[batch_size, num_directions, hidden_size]forlayout=1). Missing output dims propagate as a fresh symbolic expression labeled with the operator and field name.- Parameters:
ctx – In/out context. Must already contain an entry for
x;ris consulted only as a fallback forhidden_sizeand may benullptror missing fromctx. On returnctxalso contains an entry for each declared (non-empty) output ofnode.node – The
RNN/GRU/LSTMNodeProto.node.op_type()must be one of"RNN","GRU"or"LSTM"and at least one output must be declared.x – Name of the data input value to read from
ctx. Must be present inctxand have rank 3.r – Name of the recurrence-weight input value (used as a fallback source of
hidden_size). May benullptror absent fromctx.
- Throws:
-
void ComputeShapeAttention(ShapesContext &ctx, const NodeProto &node, const char *q, const char *k, const char *v, const char *past_key = nullptr, const char *past_value = nullptr)#
Computes the output :cpp:class:
OptimTensor(s) of anAttentionnode (since opset 23 in theai.onnxdomain) and stores them inctx.Attentionaccepts 3 to 7 inputs (Q,K,Vand the optionalattn_mask,past_key,past_value,nonpad_kv_seqlen) and exposes between 1 and 4 outputs (Yplus the optionalpresent_key,present_valueandqk_matmul_output). Only the rank-4 input form is described here; the rank-3 form (whereq_num_heads/kv_num_headsare read from attributes) defers shape inference to the dispatcher.For rank-4 inputs the function infers:
Y:(batch_size, q_num_heads, q_sequence_length, v_head_size)with dtype matchingQ.present_key:(batch_size, kv_num_heads, total_sequence_length, head_size)wheretotal_sequence_length = past_sequence_length + kv_sequence_length(or justkv_sequence_lengthwhen no past state is provided).present_value:(batch_size, kv_num_heads, total_sequence_length, v_head_size)with dtype matchingV.qk_matmul_output:(batch_size, q_num_heads, q_sequence_length, total_sequence_length)with dtype matchingQ.
q_num_headsmust be a multiple ofkv_num_headswhen both are static (Grouped Query Attention). Symbolic dimensions propagate symbolically.- Parameters:
ctx – In/out context. Must already contain entries for
q,kandv; on return it also contains an entry for each declared output ofnode.node – The
AttentionNodeProtowhose outputs should be described.node.op_type()must be"Attention"andnodemust declare at least one output.q – Name of the query input value (rank 4).
k – Name of the key input value (rank 4).
v – Name of the value input value (rank 4).
past_key – Optional name of the past_key input (rank 4). When not
nullptrand present inctx, contributespast_sequence_lengthto the present_* outputs.past_value – Optional name of the past_value input (rank 4).
- Throws:
std::invalid_argument – if
node.op_type()is not"Attention", ifnodehas no output, if any ofQ/K/Vhas rank other than 4, or if static shapes are inconsistent (mismatched batch size, mismatched head dim, mismatched kv_sequence_length, orq_num_headsnot a multiple ofkv_num_heads).std::out_of_range – if
q/k/vis not present inctx.
-
void ComputeShapeLinearAttention(ShapesContext &ctx, const NodeProto &node, const char *query, const char *key, const char *value, const char *past_state = nullptr)#
Computes the output :cpp:class:
OptimTensor(s) of aLinearAttentionnode (since opset 27 in theai.onnxdomain) and stores them inctx.LinearAttentiontakes 3 to 6 inputs (query,key,valueand the optionalpast_state,decay,beta) in rank-3 packed format(batch_size, sequence_length, num_heads * head_size), plus the required attributesq_num_headsandkv_num_heads. It produces one or two outputs (outputand the optionalpresent_state).Inferred shapes are:
output:(batch_size, sequence_length, q_num_heads * d_v)with dtype matchingquery, whered_v = value.shape[-1] / kv_num_heads.present_state:(batch_size, kv_num_heads, d_k, d_v)whered_k = key.shape[-1] / kv_num_heads. The dtype matchespast_statewhen provided, otherwisequery.
q_num_headsmust be a positive multiple ofkv_num_heads(Grouped Query Attention). Symbolic dimensions propagate symbolically.- Parameters:
ctx – In/out context. Must already contain entries for
query,keyandvalue; on return it also contains an entry for each declared output ofnode.node – The
LinearAttentionNodeProtowhose outputs should be described.node.op_type()must be"LinearAttention"andnodemust declare at least one output and theq_num_heads/kv_num_headsattributes.query – Name of the query input value (rank 3).
key – Name of the key input value (rank 3).
value – Name of the value input value (rank 3).
past_state – Optional name of the past_state input (rank 4). When not
nullptrand present inctx, refines the inferredd_k/d_vdimensions and sets the dtype ofpresent_state.
- Throws:
-
void ComputeShapeRotaryEmbedding(ShapesContext &ctx, const NodeProto &node, const char *x)#
Computes the output :cpp:class:
OptimTensorof aRotaryEmbeddingnode (since opset 23 in theai.onnxdomain) and stores it inctx.The output has the same shape and dtype as the input
X.Xmay be either rank-4(batch_size, num_heads, sequence_length, head_size)or rank-3(batch_size, sequence_length, hidden_size); in the latter case thenum_headsattribute must be set.- Parameters:
ctx – In/out context. Must already contain an entry for
x; on return it also contains an entry fornode.output(0).node – The
RotaryEmbeddingNodeProtowhose output should be described.node.op_type()must be"RotaryEmbedding"andnodemust declare at least one output.x – Name of the input value to read from
ctx. Must be present inctx.
- Throws:
-
void ComputeShapeCausalConvWithState(ShapesContext &ctx, const NodeProto &node, const char *input, const char *weight)#
Computes the output :cpp:class:
OptimTensors of aCausalConvWithStatenode (since opset 27 in theai.onnxdomain) and stores them inctx.The first output has the same shape and dtype as the input. The second output
present_statehas shape(batch_size, channels, k - 1)wherekis the kernel size (weight.shape[2]).- Parameters:
ctx – In/out context. Must already contain entries for
inputandweight; on return it also contains entries fornode.output(0)andnode.output(1).node – The
CausalConvWithStateNodeProto.node.op_type()must be"CausalConvWithState"andnodemust declare two outputs.input – Name of the input data value (rank-3) to read from
ctx.weight – Name of the weight value (rank-3) to read from
ctx.
- Throws:
-
void ComputeShapeDeformConv(ShapesContext &ctx, const NodeProto &node, const char *x, const char *w)#
Computes the output :cpp:class:
OptimTensorof aDeformConvnode and stores it inctx.The output dtype matches the input
Xdtype. The output shape is(N, oC, o1, ..., on)whereNisX.shape[0],oCisW.shape[0], and each spatial dimoiis computed from the input spatial dim, the (effective) kernel shape,strides,padsanddilationsattributes — matching the upstreamconvPoolShapeInferencerule shared withConv. When thekernel_shapeattribute is missing, the kernel shape is taken fromW.shape[2..]. Symbolic spatial dimensions are propagated symbolically.- Parameters:
ctx – In/out context. Must already contain entries for
xandw; on return it also contains an entry fornode.output(0).node – The
DeformConvNodeProtowhose output should be described.node.op_type()must be"DeformConv"andnodemust declare at least one output.x – Name of the input data value (rank >= 3) to read from
ctx. Must be present inctx.w – Name of the weight value (rank >= 3) to read from
ctx. Must be present inctx.
- Throws:
-
void ComputeShapeCol2Im(ShapesContext &ctx, const NodeProto &node, const char *input, const char *image_shape, const char *block_shape)#
Computes the output :cpp:class:
OptimTensorof aCol2Imnode and stores it inctx.The output dtype matches the input
inputdtype. The output shape is(N, C, dim_i1, ..., dim_iN)whereNisinput.shape[0],Cisinput.shape[1] / product(block_shape)(when theblock_shapeinitializer is known), and the spatial dimensions are taken from theimage_shapeinitializer when known. When either initializer is missing or the corresponding input shape is symbolic, the affected dimensions are propagated symbolically.- Parameters:
ctx – In/out context. Must already contain entries for
input,image_shapeandblock_shape; on return it also contains an entry fornode.output(0).node – The
Col2ImNodeProtowhose output should be described.node.op_type()must be"Col2Im"andnodemust declare at least one output.input – Name of the data input value (rank 3) in
ctx.image_shape – Name of the
image_shape1-Dtensor(int64)value inctx.block_shape – Name of the
block_shape1-Dtensor(int64)value inctx.
- Throws:
-
void ComputeShapeConv(ShapesContext &ctx, const NodeProto &node, const char *x, const char *w)#
Computes the output :cpp:class:
OptimTensorof aConvnode and stores it inctx.The output dtype matches
X. The output shape is(N, M, o1, ..., on)whereNisX.shape[0],MisW.shape[0], and each spatial dim is derived fromkernel_shape,strides,pads,dilationsandauto_padfollowing the upstreamconvPoolShapeInferencerule.
-
void ComputeShapeConvInteger(ShapesContext &ctx, const NodeProto &node, const char *x, const char *w)#
Computes the output :cpp:class:
OptimTensorof aConvIntegernode and stores it inctx. The shape rule matches :cpp:func:ComputeShapeConv; the output dtype is alwaysTensorType::kInt32.
-
void ComputeShapeConvTranspose(ShapesContext &ctx, const NodeProto &node, const char *x, const char *w)#
Computes the output :cpp:class:
OptimTensorof aConvTransposenode and stores it inctx.The output dtype matches
X. The output shape is(N, M, o1, ..., on)whereMisW.shape[1] * group. Each spatial dim is derived fromkernel_shape,strides,pads,dilations,output_padding,output_shapeandauto_padfollowing the upstreamconvTransposeShapeInferencerule.
-
void ComputeShapeMaxPool(ShapesContext &ctx, const NodeProto &node, const char *x)#
Computes the output :cpp:class:
OptimTensorof aMaxPoolnode.Mirrors :cpp:func:
ComputeShapeAveragePool. The first outputYhas the same dtype asXand a shape derived fromkernel_shape,strides,pads,dilations,ceil_modeandauto_pad. If the node declares a second output (Indices) and that output’s name is non-empty, an entry is also added toctxwith dtypeint64and the same shape asY.
-
void ComputeShapeMaxUnpool(ShapesContext &ctx, const NodeProto &node, const char *x, const char *I, const char *output_shape)#
Computes the output :cpp:class:
OptimTensorof aMaxUnpoolnode.The output dtype matches
X. Whenoutput_shapeis provided and is a rank-1int64tensor with a known value, the output shape is taken directly from those values; otherwise the output shape is computed fromkernel_shape,stridesandpadsaccording to the formulaout_dim[i] = strides[i] * (in_dim[i] - 1) + kernel_shape[i] - pads[i] - pads[i + k].output_shapemay benullptrfor the two-input form.
-
void ComputeShapeMaxRoiPool(ShapesContext &ctx, const NodeProto &node, const char *x, const char *rois)#
Computes the output :cpp:class:
OptimTensorof aMaxRoiPoolnode and stores it inctx.The output dtype matches the input feature-map dtype. The output shape is
(num_rois, C, pooled_shape[0], pooled_shape[1])wherenum_roisis taken from dim 0 ofrois(which may be symbolic);Cis taken from dim 1 ofx; and the spatial sizes come from the requiredpooled_shapeattribute.- Parameters:
ctx – In/out context. Must already contain entries for
xandrois; on return it also contains an entry fornode.output(0).node – The
MaxRoiPoolNodeProtowhose output should be described.node.op_type()must be"MaxRoiPool"andnodemust declare at least one output.x – Name of the feature-map input value (rank 4) in
ctx.rois – Name of the RoIs input value (rank 2 with last dim 5) in
ctx.
- Throws:
-
void ComputeShapeAveragePool(ShapesContext &ctx, const NodeProto &node, const char *x)#
-
namespace nn#
-
namespace shapes
-
namespace onnx_optim