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

[Unity] Allocate workspace for all functions #15118

Merged
merged 1 commit into from
Jun 19, 2023

Conversation

yelite
Copy link
Contributor

@yelite yelite commented Jun 16, 2023

This PR makes AllocateWorkspace allocate workspace in all Relax functions that doesn't have Codegen or Composite attributes.

cc @masahi

@tvm-bot
Copy link
Collaborator

tvm-bot commented Jun 16, 2023

Thanks for contributing to TVM! Please refer to the contributing guidelines https://tvm.apache.org/docs/contribute/ for useful information and tips. Please request code reviews from Reviewers by @-ing them in a comment.

Generated by tvm-bot

@masahi
Copy link
Member

masahi commented Jun 19, 2023

This assumes that all entry functions get the same workspace size right?

I also have a WIP branch https://github.com/masahi/tvm/tree/workspace-provider-entry-func that calculates the minimum-necessary workspace size for each function that calls another functions with kWorkSpaceSize attribute. It doesn't yet handle the case where the same function with kWorkSpaceSize is called by multiple entry functions, with different maximum workspace sizes. Since we modify the function signature for a function that needs workspace param, the param size needs to take into account all entry funcs that call it.

So the upshot is, even though different entry funcs can have its own minimum workspace size, to handle the case above we need to take the max over all functions with kWorkSpaceSize, even though a single entry func might not call all of them. I was planning to add such logic on top of my branch, but looking at this PR makes me realize that this simple patch is effectively sufficient.

Do you agree with my assessment? @yelite

@yelite
Copy link
Contributor Author

yelite commented Jun 19, 2023

@masahi I think what you described is ideal and the workspace param can be made as R.Object to workaround the multi-caller limitation. I am just not sure what we lose by stripping out shape information from the workspace param. If all the usages of workspace validates the actual size of workspace, and allocate if workspace is not large enough, like what attention does currently, I think it should be fine.

Copy link
Member

@masahi masahi left a comment

Choose a reason for hiding this comment

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

R.Object sounds like a good solution. For now this patch should be fine.

@masahi masahi merged commit 2260bba into apache:unity Jun 19, 2023
junrushao pushed a commit to junrushao/tvm that referenced this pull request Jun 22, 2023
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.

3 participants