Skip to content

"Unidirectionally broadcast the shapes" steps have issues #662

Description

@huningxin

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].

Activity

  1. changed the title [-]"Unidirectionally broadcast the shapes" steps should allow smaller shapeA be broadcasted to larger shapeB[/-] [+]"Unidirectionally broadcast the shapes" steps have issues[/+] on Apr 29, 2024
  2. inexorabletash commented on Apr 29, 2024

    @inexorabletash
    Contributor

    Did I just get the inputs reversed?

  3. huningxin commented on Apr 29, 2024

    @huningxin
    ContributorAuthor

    @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.

  4. added a commit that references this issue on Apr 29, 2024
    eb08f9a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions