Skip to content

[SCHEDULE] New Reduction Mode for Tensorize #714

Closed

Description

@tqchen

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

Activity

  1. tqchen commented on Dec 19, 2017

    @tqchen
    MemberAuthor

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

  2. derisavi-huawei commented on Dec 19, 2017

    @derisavi-huawei
    Contributor

    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 :-)

  3. tqchen commented on Dec 20, 2017

    @tqchen
    MemberAuthor

    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

  4. merrymercy commented on Dec 21, 2017

    @merrymercy
    Member

    I can try this but may not too soon.

  5. derisavi-huawei commented on Dec 21, 2017

    @derisavi-huawei
    Contributor

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

  6. taknevski commented on Dec 22, 2017

    @taknevski

    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.

  7. kun-zh commented on Dec 23, 2017

    @kun-zh
    Contributor

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

  8. kun-zh commented on Dec 26, 2017

    @kun-zh
    Contributor

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

  9. tqchen commented on Dec 27, 2017

    @tqchen
    MemberAuthor
  10. tqchen commented on Dec 29, 2017

    @tqchen
    MemberAuthor

    close this, thanks to @kun-zh

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions