Skip to content

Conversation

@asparkhi
Copy link
Contributor

Introduces a Pass for removing intermediate reshapes post
LowerTE() in AOT compiler. This commit adds pass specific
tests and updates usmp generated workspace pools due to
reduction in number of allocations post reshape removals.

Note: this pass at present does not support first reshape
appearing in the graph. If seen as a useful case, it can be
added in the future.

cc: @manupa-arm @grant-arm

Copy link
Contributor

@manupak manupak left a comment

Choose a reason for hiding this comment

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

Thanks for this work!
Also worth highlighting in some docs of the pass the value of it and why it should be enabled.

cc : @areusch @altanh @lhutton1

Copy link
Contributor

@manupak manupak left a comment

Choose a reason for hiding this comment

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

Thanks @ashutosh-arm. looking good!

I think we need unit tests for the pass as well.
(E.g. https://github.com/apache/tvm/blob/main/tests/python/relay/test_pass_partition_graph.py)

Copy link
Contributor

@lhutton1 lhutton1 left a comment

Choose a reason for hiding this comment

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

Great work @ashutosh-arm! Just some small things I picked up on..

Copy link
Contributor

@areusch areusch left a comment

Choose a reason for hiding this comment

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

don't have tons of context here, but left a couple suggestions

return WithFields(GetRef<Let>(let), var, value, body);
}

/*! * \brief Returns preceding CallLowered when call is a CallLowered(Reshape) */
Copy link
Contributor

Choose a reason for hiding this comment

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

i'm probably missing some context here, but what about just returning the args to reshape()?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Graph contains let nodes in between the call_lowered(). I've included the following piece as part of the Rewrite_() as well.

    /*
    %1 = call_lowered(@tvmgen_default_non_reshape_function, %input, ...);
    let %x: = on_device(%1, ...);
    %2 = (%x,);
    %3 = call_lowered(@tvmgen_default_fused_reshape, %2, ...,
    "relay_attrs"=__dict__="relay.reshape_only"=1, ...);
    */

Ashutosh Parkhi added 4 commits August 4, 2022 11:03
Change-Id: Iaf5a5f44776080b0b842af4b563d596134508de1
Change-Id: I1f45ee3b15fbe290fdce69832a850d7d85ea1681
Change-Id: I81462a552f467d88cf1288acef2f9cbacc3ff532
Change-Id: I8502bc74eb0914cfcaa86cb809d7c4a9c6e86c70
Copy link
Contributor

@manupak manupak left a comment

Choose a reason for hiding this comment

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

LGTM!

@lhutton1 @areusch maybe have a look ?

Copy link
Contributor

@lhutton1 lhutton1 left a comment

Choose a reason for hiding this comment

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

LGTM!

@lhutton1 lhutton1 merged commit fc411dc into apache:main Aug 8, 2022
@lhutton1
Copy link
Contributor

lhutton1 commented Aug 8, 2022

Thanks @ashutosh-arm @manupa-arm @areusch!

@asparkhi asparkhi deleted the remove_reshapes branch August 31, 2022 11:30
xinetzone pushed a commit to daobook/tvm that referenced this pull request Nov 25, 2022
Introduces a Pass for removing intermediate reshapes post
LowerTE() in AOT compiler. This commit adds pass specific
tests and updates usmp generated workspace pools due to
reduction in number of allocations post reshape removals.

Note: this pass at present does not support first reshape
appearing in the graph. If seen as a useful case, it can be
added in the future.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants