Skip to content

Support coordinate transformation modes for Resample2d #270

@Honry

Description

@Honry

Issue: DeepLabV3 contains Resize node in ONNX model and ResizeBilinear in TFLite model. It's corresponding op in WebNN is Resample2d. Resize node contains coordinate_transformation_mode=align_corners, ResizeBilinear node contains align_corners=true and half_pixel_centers=false. While WebNN doesn't support such coordinate transformation modes and its default behavior equals to align_corners=false and half_pixel_centers=true.

Compares all the behaviors in different backends and frameworks as follows:

TFLite (half_pixel_centers, align_corners) ONNX (coordinate_transformation_mode enum) OpenVINO (coordinate_transformation_mode enum) DML WebNN
half_pixel_centers=true half_pixel half_pixel Supported Default behavior
N/A pytorch_half_pixel pytorch_half_pixel Supported N/A
half_pixel_centers=false align_corners=false asymmetric asymmetric Supported N/A
N/A N/A tf_half_pixel_for_nn N/A N/A
align_corners=true align_corners align_corners Supported N/A
N/A tf_crop_and_resize N/A Supported N/A

Note: DML backend can support these modes by calculating its InputPixelOffsets and outputPixelOffsets members.
You can refer to its implementation in ONNXRumtime DML backend.

Open: Can we support these coordinate transformation modes in WebNN? At least for asymmetric, half_pixel_centers and align_corners. Or maybe we could refer to DML by defining InputPixelOffsets and outputPixelOffsets options in Resample2d to implement various coordinate transformation modes.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions