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

[SCHEDULE] New Reduction Mode for Tensorize #714

Closed
tqchen opened this issue Dec 19, 2017 · 10 comments
Closed

[SCHEDULE] New Reduction Mode for Tensorize #714

tqchen opened this issue Dec 19, 2017 · 10 comments

Comments

@tqchen
Copy link
Member

tqchen commented Dec 19, 2017

So far we are implementing reduction as

init(C)

for rx in reduce_range_x:
    for ry in reduce_range_y:
      update(C, reduce_value)

This may not be desirable, especially when there is no reset(init) intrinsic available. So alternatively, we can do

for rx in reduce_range_x:
    for ry in reduce_range_y:
      if likely(rx == 0) and likely(ry == 0):
         compute(C, reduce_value)
      else:
         update(C, reduce_value)

The subsequent loop split process will peel the loop to remove the likely condition when possible.

For now, we can enable this mode, when user did not provide init intrinsic in tensor_intrin, but provided compute and update intrinsic

@tqchen
Copy link
Member Author

tqchen commented Dec 19, 2017

cc @derisavi-huawei @merrymercy let me know if it makes sense to you and see if any of you are interested in this

@derisavi-huawei
Copy link
Contributor

derisavi-huawei commented Dec 19, 2017

I'm not crystal clear on what the problem is. It seems to me that an init intrinsic should always be available because a reduction always has an identity element. Is this about an alternative way for TVM to generate IR for reduce_axis(so that it eventually leads to more efficient code on a particular hardware), or is it about what kind of patterns (init/update vs compute/update) tensorize can match, or both, or something else? That was a lot of ORs :-) Can you please elaborate?

Also, I don't clearly see the pros and cons of the design decisions involved here. Could you give us initial ideas so we can brainstorm?

In terms of interest, it's not something that will be on our radar in the next month or so. If we grow an interest in it, I'll definitely let you know.

Sorry! You were expecting answers and you received many questions instead :-)

@tqchen
Copy link
Member Author

tqchen commented Dec 20, 2017

It is related to #512 on comment in terms of the alternative way of generating reduction, and is useful when init intrinsic is not available due too limitation of hardware

@merrymercy
Copy link
Member

I can try this but may not too soon.

@derisavi-huawei
Copy link
Contributor

Second form makes life easier for us, so we are interested. Unfortunately we can't invest time in this in the short term.

@taknevski
Copy link

Hi,
Let me know if this is off-topic..
I was wondering if the reduction initialization could be scheduled separately much in the same way as the tvm.scan init and update operations. Currently I want to move the zero initialization for the output tensor in convolution to a separate loop nest(at the outermost level) but I can't seem to find a way to do it easily.

@kun-zh
Copy link
Contributor

kun-zh commented Dec 23, 2017

@tqchen , I have a solution in my local now, as we discussed, firstly set the reset part as "None" in intrinsic definition, then transform the update part in tensorize.cc. I will send to u for review after some tests.

@kun-zh
Copy link
Contributor

kun-zh commented Dec 26, 2017

@tqchen , I created a pull request, can u help to review it?

@tqchen
Copy link
Member Author

tqchen commented Dec 27, 2017

#727

@tqchen tqchen closed this as completed Dec 29, 2017
@tqchen
Copy link
Member Author

tqchen commented Dec 29, 2017

close this, thanks to @kun-zh

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

5 participants