Skip to content

Pass that removes reshapes post LowerTE#12215

Merged
lhutton1 merged 4 commits into
apache:mainfrom
asparkhi:remove_reshapes
Aug 8, 2022
Merged

Pass that removes reshapes post LowerTE#12215
lhutton1 merged 4 commits into
apache:mainfrom
asparkhi:remove_reshapes

Conversation

@asparkhi

Copy link
Copy Markdown
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

@manupak manupak left a comment

Copy link
Copy Markdown
Contributor

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

Comment thread include/tvm/relay/transform.h Outdated
Comment thread src/relay/transforms/remove_reshapes.cc
Comment thread src/relay/transforms/remove_reshapes.cc Outdated

@manupak manupak left a comment

Copy link
Copy Markdown
Contributor

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)

@lhutton1 lhutton1 left a comment

Copy link
Copy Markdown
Contributor

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

Comment thread src/relay/transforms/remove_standalone_reshapes.cc Outdated
Comment thread src/relay/transforms/remove_standalone_reshapes.cc Outdated
Comment thread src/relay/transforms/remove_standalone_reshapes.cc

@areusch areusch left a comment

Copy link
Copy Markdown
Contributor

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

Comment thread src/relay/backend/aot_executor_codegen.cc Outdated
return WithFields(GetRef<Let>(let), var, value, body);
}

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

Copy link
Copy Markdown
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
Copy Markdown
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

@manupak manupak left a comment

Copy link
Copy Markdown
Contributor

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 ?

@lhutton1 lhutton1 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM!

Comment thread tests/python/relay/backend/test_pass_remove_standalone_reshapes.py
@lhutton1 lhutton1 merged commit fc411dc into apache:main Aug 8, 2022
@lhutton1

lhutton1 commented Aug 8, 2022

Copy link
Copy Markdown
Contributor

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

@asparkhi asparkhi deleted the remove_reshapes branch August 31, 2022 11:30
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