Skip to content
This repository has been archived by the owner on Nov 17, 2023. It is now read-only.

[WIP] Add broadcast_like backend tensor operator #11443

Closed
wants to merge 7 commits into from
Closed

[WIP] Add broadcast_like backend tensor operator #11443

wants to merge 7 commits into from

Conversation

rondogency
Copy link
Contributor

Description

This PR adds broadcast_lilke tensor operator which works similar to existing broadcast_to operator.
We followed the basic steps for adding new tensor operator and made necessary definitions on broadcast_reduce_op.h and its corresponding cc/cu files.

Checklist

Essentials

Please feel free to remove inapplicable items for your PR.

  • Changes are complete (i.e. I finished coding on this PR)
  • All changes have test coverage:
  • Unit tests are added for small changes to verify correctness (e.g. adding a new operator)
  • Nightly tests are added for complicated/long-running ones (e.g. changing distributed kvstore)
  • Build tests will be added for build configuration changes (e.g. adding a new build option with NCCL)
  • Code is well-documented:
  • For user-facing API changes, API doc string has been updated.
  • For new C++ functions in header files, their functionalities and arguments are documented.
  • For new examples, README.md is added to explain the what the example does, the source of the dataset, expected performance on test set and reference to the original paper if applicable
  • Check the API doc at http://mxnet-ci-doc.s3-accelerate.dualstack.amazonaws.com/PR-$PR_ID/$BUILD_ID/index.html
  • To the my best knowledge, examples are either not affected by this change, or have been fixed to be compatible with this change

Changes

  • Feature1, tests, (and when applicable, API doc)
  • Feature2, tests, (and when applicable, API doc)

Comments

N/A

@jmacglashan
Copy link

jmacglashan commented Jul 6, 2018

This is a much appreciated addition. Question: I may be reading it wrong, but it looks like it will try to match all axes of target; could an argument be added for only matching some of the axes?
For example:

src = [[1, 2, 3]]   # (1x3)
target = [[1, 1], [1, 1]]  # (2x2)
broadcast_like(src, target, axes=(0,)) = [[1, 2, 3], [1, 2, 3]]  # (2x3)

And maybe more complex with different number of dimensions:

src = [[[1, 2], [3, 4]]]  # (1x2x2)
target = [[1, 1], [1, 1]]  # (2x2)
broadcast_like(src, target, axes=(0,)) = [[[1, 2], [3, 4]], [[1, 2], [3, 4]]]  # (2x2x2)

This last one is probably a headache because of how the axes get matched when they differ, but if nothing else the former would be nice to have.

@rondogency
Copy link
Contributor Author

@jmacglashan sorry for the late response. Currently I just tried to match all axes. I will work on it this weekend and try to add the option for specifying axes.

@eric-haibin-lin
Copy link
Member

same feature added in #11820 ... closing this now

@eric-haibin-lin
Copy link
Member

@jmacglashan looks like there's another PR added the same thing. For the axes option you mentioned, do you minding creating a issue with title feature request?

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

Successfully merging this pull request may close these issues.

4 participants