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

[Codegen] Support broadcast op with symbolic shape #3389

Merged
merged 10 commits into from
Jul 2, 2019

Conversation

yzhliu
Copy link
Member

@yzhliu yzhliu commented Jun 18, 2019

Copy link
Member

@junrushao junrushao left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@tqchen tqchen added the status: need RFC need RFC discussion label Jun 18, 2019
@tqchen
Copy link
Member

tqchen commented Jun 18, 2019

Thanks for the RFC, I like the idea. Sorry that I didn't get enough time to comment specifically about the behavior, can you please open an RFC issue? So we can discuss it a bit more.

The things to be improved are

  • Document the behavior independent of arg_binder.
    • Maps buffer[i][j][k] -> buffer[i][0][k] if dimension i's shape equals 0
  • Debate on the name (auto broadcast?), enum vs string as type key
  • Discuss how would the behavior affect topi implementation of broadcast and reduce ops
  • Think about alternative implementations
    • Do we have to introduce stride?
    • e.g. j -> min(j, shape[ndim])
    • j -> j * scale(scale = 0 or 1)

@junrushao
Copy link
Member

  • Do we have to introduce stride?
  • e.g. j -> min(j, shape[ndim])
  • j -> j * scale(scale = 0 or 1)

I do think it is proper to introduce stride. First, as far as we could see, using strides does not seem to have too much overhead, compared with other workarounds. Second, it seems to pave ways for other possible hacks to the buffer.

@junrushao
Copy link
Member

@were Could you review this PR?

@were
Copy link
Contributor

were commented Jun 28, 2019

LGTM, too.

@yzhliu yzhliu added status: need review and removed status: need RFC need RFC discussion labels Jun 30, 2019
@yzhliu
Copy link
Member Author

yzhliu commented Jul 1, 2019

@tqchen modified per suggestion.

auto_broadcast buffer allows one to implement broadcast computation
without considering whether dimension size equals to one.
TVM will insert `strides[i] = shape[i] == 1 ? 0 : strides[i]` during arg binding.
See src/pass/arg_binder.cc for reference.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let us avoid refer to c++ code in the python side, would be great if python doc can stand by itself

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

addressed

@yzhliu yzhliu merged commit 0af5c21 into apache:master Jul 2, 2019
@yzhliu
Copy link
Member Author

yzhliu commented Jul 2, 2019

Thanks @tqchen @junrushao1994 @were for review.

wweic pushed a commit to wweic/tvm that referenced this pull request Jul 11, 2019
* [Codegen] Support broadcast op with symbolic shape

* fix case where last dim = 1

* use enum; simplify stride calculation; improve doc

* fix lint

* improve py doc
wweic pushed a commit to wweic/tvm that referenced this pull request Jul 11, 2019
* [Codegen] Support broadcast op with symbolic shape

* fix case where last dim = 1

* use enum; simplify stride calculation; improve doc

* fix lint

* improve py doc
wweic pushed a commit to neo-ai/tvm that referenced this pull request Jul 11, 2019
* [Codegen] Support broadcast op with symbolic shape

* fix case where last dim = 1

* use enum; simplify stride calculation; improve doc

* fix lint

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

Successfully merging this pull request may close these issues.

4 participants