shape_nn.h#
Shape-inference functions for ONNX operators in the nn family.
-
namespace ONNX_LIGHT_NAMESPACE
-
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_backend_test::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 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 ComputeShapeAveragePool(ShapesContext &ctx, const NodeProto &node, const char *x)#
-
namespace nn#
-
namespace shapes
-
namespace onnx_optim