MaxRoiPool#
Domain:
ai.onnxSince version: 22
ROI max pool consumes an input tensor X and regions of interest (RoIs) to apply max pooling across each RoI, to produce output 4-D tensor of shape (num_rois, channels, pooled_shape[0], pooled_shape[1]).
Inputs
X (T): Input data tensor from the previous operator; dimensions for image case are (N x C x H x W), where N is the batch size, C is the number of channels, and H and W are the height and the width of the data.
rois (T): RoIs (Regions of Interest) to pool over. Should be a 2-D tensor of shape (num_rois, 5) given as [[batch_id, x1, y1, x2, y2], …].
Outputs
Y (T): RoI pooled output 4-D tensor of shape (num_rois, channels, pooled_shape[0], pooled_shape[1]).
Attributes
pooled_shape (int[]): ROI pool output shape (height, width).
spatial_scale (float): Multiplicative spatial scale factor to translate ROI coordinates from their input scale to the scale used when pooling.
Type Constraints
T: Constrain input and output types to float tensors. Allowed types: tensor(bfloat16), tensor(double), tensor(float), tensor(float16).
Examples#
test_cc_maxroipool_default
Node:
MaxRoiPool(X, rois) -> (Y)
Attributes:
pooled_shape = [2, 2]
Inputs:
X: shape=(1, 2, 6, 6), dtype=float32
[[[[0. , 0.02777778, 0.05555556, 0.08333334, 0.11111111, 0.1388889 ],
[0.16666667, 0.19444445, 0.22222222, 0.25 , 0.2777778 , 0.30555555],
[0.33333334, 0.3611111 , 0.3888889 , 0.41666666, 0.44444445, 0.4722222 ],
[0.5 , 0.5277778 , 0.5555556 , 0.5833333 , 0.6111111 , 0.6388889 ],
[0.6666667 , 0.6944444 , 0.7222222 , 0.75 , 0.7777778 , 0.8055556 ],
[0.8333333 , 0.8611111 , 0.8888889 , 0.9166667 , 0.9444444 , 0.9722222 ]],
[[1. , 1.0277778 , 1.0555556 , 1.0833334 , 1.1111112 , 1.1388888 ],
[1.1666666 , 1.1944444 , 1.2222222 , 1.25 , 1.2777778 , 1.3055556 ],
[1.3333334 , 1.3611112 , 1.3888888 , 1.4166666 , 1.4444444 , 1.4722222 ],
[1.5 , 1.5277778 , 1.5555556 , 1.5833334 , 1.6111112 , 1.6388888 ],
[1.6666666 , 1.6944444 , 1.7222222 , 1.75 , 1.7777778 , 1.8055556 ],
[1.8333334 , 1.8611112 , 1.8888888 , 1.9166666 , 1.9444444 , 1.9722222 ]]]]
rois: shape=(2, 5), dtype=float32
[[0., 0., 0., 5., 5.],
[0., 1., 1., 4., 4.]]
Outputs:
Y: shape=(2, 2, 2, 2), dtype=float32
[[[[0.3888889 , 0.4722222 ],
[0.8888889 , 0.9722222 ]],
[[1.3888888 , 1.4722222 ],
[1.8888888 , 1.9722222 ]]],
[[[0.3888889 , 0.44444445],
[0.7222222 , 0.7777778 ]],
[[1.3888888 , 1.4444444 ],
[1.7222222 , 1.7777778 ]]]]
test_cc_maxroipool_spatial_scale
Node:
MaxRoiPool(X, rois) -> (Y)
Attributes:
pooled_shape = [3, 3]
spatial_scale = 0.5
Inputs:
X: shape=(1, 2, 6, 6), dtype=float32
[[[[0. , 0.02777778, 0.05555556, 0.08333334, 0.11111111, 0.1388889 ],
[0.16666667, 0.19444445, 0.22222222, 0.25 , 0.2777778 , 0.30555555],
[0.33333334, 0.3611111 , 0.3888889 , 0.41666666, 0.44444445, 0.4722222 ],
[0.5 , 0.5277778 , 0.5555556 , 0.5833333 , 0.6111111 , 0.6388889 ],
[0.6666667 , 0.6944444 , 0.7222222 , 0.75 , 0.7777778 , 0.8055556 ],
[0.8333333 , 0.8611111 , 0.8888889 , 0.9166667 , 0.9444444 , 0.9722222 ]],
[[1. , 1.0277778 , 1.0555556 , 1.0833334 , 1.1111112 , 1.1388888 ],
[1.1666666 , 1.1944444 , 1.2222222 , 1.25 , 1.2777778 , 1.3055556 ],
[1.3333334 , 1.3611112 , 1.3888888 , 1.4166666 , 1.4444444 , 1.4722222 ],
[1.5 , 1.5277778 , 1.5555556 , 1.5833334 , 1.6111112 , 1.6388888 ],
[1.6666666 , 1.6944444 , 1.7222222 , 1.75 , 1.7777778 , 1.8055556 ],
[1.8333334 , 1.8611112 , 1.8888888 , 1.9166666 , 1.9444444 , 1.9722222 ]]]]
rois: shape=(1, 5), dtype=float32
[[ 0., 0., 0., 10., 10.]]
Outputs:
Y: shape=(1, 2, 3, 3), dtype=float32
[[[[0.19444445, 0.25 , 0.30555555],
[0.5277778 , 0.5833333 , 0.6388889 ],
[0.8611111 , 0.9166667 , 0.9722222 ]],
[[1.1944444 , 1.25 , 1.3055556 ],
[1.5277778 , 1.5833334 , 1.6388888 ],
[1.8611112 , 1.9166666 , 1.9722222 ]]]]
Differences with previous version (1)#
SchemaDiff: MaxRoiPool (domain 'ai.onnx')
old version: 1
new version: 22
breaking: no
Type constraints:
changed ‘T’: added types: [‘tensor(bfloat16)’]