yobx.tensorflow.ops.pooling#
Converters for TF 2-D pooling ops: MaxPool, AvgPool.
TensorFlow uses NHWC (batch, height, width, channels) data format by
default. ONNX MaxPool and AveragePool expect NCHW input. The
converters therefore insert Transpose nodes:
Before pooling: NHWC → NCHW (
perm=[0, 3, 1, 2])After pooling: NCHW → NHWC (
perm=[0, 2, 3, 1])
Padding is always expressed as explicit pads rather than auto_pad so
that ONNX shape inference can propagate output shapes even when the batch
dimension is dynamic.
- yobx.tensorflow.ops.pooling.convert_avg_pool(g: GraphBuilderExtendedProtocol, sts: Dict[str, Any], outputs: List[str], op: Operation) str[source]#
Converts TF
AvgPool(NHWC) → ONNXAveragePool(NCHW).TF
ksize/stridesattributes are 4-element lists in NHWC order[batch, H, W, C]; only the spatial dimensions[H, W]are forwarded to the ONNX node. Padding is represented as explicitpadsto enable ONNX shape inference regardless of whether the batch dimension is dynamic.
- yobx.tensorflow.ops.pooling.convert_max_pool(g: GraphBuilderExtendedProtocol, sts: Dict[str, Any], outputs: List[str], op: Operation) str[source]#
Converts TF
MaxPool(NHWC) → ONNXMaxPool(NCHW).TF
ksize/stridesattributes are 4-element lists in NHWC order[batch, H, W, C]; only the spatial dimensions[H, W]are forwarded to the ONNX node. Padding is represented as explicitpadsto enable ONNX shape inference regardless of whether the batch dimension is dynamic.