-
Notifications
You must be signed in to change notification settings - Fork 59
Description
pad is implemented on CoreML backend but with lots of constraints.
On CoreML (See doc), three modes are supported - constant, reflect, replicate(maps to edge mode).
- symmetric mode is not supported (On tflite backend,
edgemode is not supported.) - padding for more than the last two dimensions only supports 'constant' mode. (not documented, but it errors out with this message). One of the webnn samples - Fast style transfer need to use >2D padding for reflect mode.
- If mode is “reflect” then beginning and ending paddings can be at most input size-1 (same as tensorflow).
- If mode is “replicate” (aka
edge) then beginning and ending paddings can be at most input size.
For the third constraint, we can probably update the spec to add such constraint? #377
For the others, my first question is - @fdwr @huningxin are there reasonable emulations for these unsupported modes and rank limits?
Further questions are - @mwyrzykowski do you think if CoreML can improve pad support with:
- Add support for
symmetricmode - Support padding for more than two dimensions for none
constantmode. - Remove the padding value constraints for 'replicate' modes since it doesn't make much sense, it only uses the edge values to replicate.
If none of the restrictions can be emulated / nor supported by CoreML, we will need to either:
a. Add these constraints to WebNN API.
b. Expose the modes limits through opSupportLimits. The rank constraints are tricky to expose - as it varies by mode.
c. Just let them fail on CoreML with async error messages.. - Not ideal for browser compatibility.