yobx.tensorflow.ops.padding#

Converters for TF padding ops: Pad, PadV2, MirrorPad.

TensorFlow Pad / PadV2 store padding amounts as a 2-D tensor of shape [N, 2] with layout [[begin0, end0], [begin1, end1], ...]. ONNX Pad (opset ≥ 11) expects a 1-D int64 tensor of shape [2N] with layout [begin0, begin1, ..., beginN-1, end0, end1, ..., endN-1].

The converters transpose the TF paddings tensor from [N, 2] to [2, N] and then flatten it to produce the ONNX-compatible layout.

yobx.tensorflow.ops.padding.convert_mirror_pad(g: GraphBuilderExtendedProtocol, sts: Dict[str, Any], outputs: List[str], op: Operation) str[source]#

Converts TF MirrorPad → ONNX Pad with mode attribute.

TF mode attribute values:

  • "REFLECT" → ONNX mode="reflect" (excludes the border value)

  • "SYMMETRIC" → ONNX mode="edge" (includes the border value)

yobx.tensorflow.ops.padding.convert_pad(g: GraphBuilderExtendedProtocol, sts: Dict[str, Any], outputs: List[str], op: Operation) str[source]#

Converts TF Pad / PadV2 → ONNX Pad.

PadV2 carries an explicit constant_values input (third input) which is forwarded to the ONNX Pad node as the optional constant value. Pad pads with zeros and does not need that input.