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

"Unidirectionally broadcast the shapes" steps have issues #662

Open
huningxin opened this issue Apr 29, 2024 · 2 comments · May be fixed by #663
Open

"Unidirectionally broadcast the shapes" steps have issues #662

huningxin opened this issue Apr 29, 2024 · 2 comments · May be fixed by #663
Labels

Comments

@huningxin
Copy link
Contributor

huningxin commented Apr 29, 2024

The current unidirectionally broadcasting the shapes steps don't allow sizeA < sizeB according to the following step

If sizeB > sizeA, then return failure.

And the steps should pad shapeA, the current steps pad shapeB instead

Let paddedB be a clone of shapeB.
While paddedB’s size is less than sizeA, prepend 1 to paddedB.

This would cause the following examples to fail

  1. ShapeA [], ShapeB [3, 4, 5]
  2. shapeA [5], shapeB [3, 4, 5]

When creating the output shape, the steps should use dimB. The current step uses dimA:

Append dimA to outputShape.

This would produce incorrect output shape. For example, assume ShapeA [3, 1, 5], ShapeB [3, 4, 5], the output shape should be [3, 4, 5], the current steps produce [3, 1, 5].

@huningxin huningxin added the bug label Apr 29, 2024
@huningxin huningxin changed the title "Unidirectionally broadcast the shapes" steps should allow smaller shapeA be broadcasted to larger shapeB "Unidirectionally broadcast the shapes" steps have issues Apr 29, 2024
@inexorabletash
Copy link
Contributor

inexorabletash commented Apr 29, 2024

Did I just get the inputs reversed?

@huningxin
Copy link
Contributor Author

@inexorabletash

Did I just get the inputs inverted?

It seems. But the following step is correct:

If dimA is not equal to dimB and dimA is not equal to 1, then return failure.

I am making a PR to fix it, will upload soon.

huningxin added a commit to huningxin/webnn that referenced this issue Apr 29, 2024
@huningxin huningxin linked a pull request Apr 29, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants