Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Need clarify the usage of axes=[0,1] for resample2d #624

Open
BruceDai opened this issue Mar 27, 2024 · 1 comment
Open

Need clarify the usage of axes=[0,1] for resample2d #624

BruceDai opened this issue Mar 27, 2024 · 1 comment

Comments

@BruceDai
Copy link
Contributor

This issue was raised as @fdwr's below comment for reviewing Chromium CL-5382118.

axes=[0,1] is an odd one, and I wonder the history behind it (decided before I joined). Some other ML libraries simply treat axes as numbers (no associated semantics to any particular dimensions), but WebNN limits them to [0,1], [1,2], [2,3]; and while the axes=[1,2] and axes=[2,3] uses are obvious (for NHWC and NCHW tensors respectively), the [0,1] scenario makes me go hmm, because if the semantic interpretation of the input tensor is NHWC, then it would mean resampling the batch and height (but not the width 🙃), which wouldn't make any sense; whereas if the semantic layout of the input was NCHW, then it would mean simultaneously resampling the batch dimension (useful for replication) and expanding the channel count, which can make sense. However, if resampling NC in NCHW is useful, then resampling NC in NHWC should be deemed useful too, but axes=[0,3] is currently disallowed by the spec. 🤔

/cc @fdwr @huningxin @a-sully, PTAL, thanks.

@inexorabletash
Copy link
Contributor

Maybe asking the same question in a different way:

If resample2d() is only for use with tensors of NHWC and NCHW layouts, then should it take an MLInputOperandLayout param instead of an axes param?

If not, what are the other use cases, and how can we support them via axes?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants