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

[vm] add support for customized allocator #7763

Conversation

MuchToMyDelight
Copy link

Hello guys!

After trying the VM in TVM, I found that the default memory allocator(PooledAllocator) doesn't work very well: in case of dynamic inputs, the size of used buffers are different from inference to inference and PooledAllocator cached buffers based on the size. Therefore, it ends with out of device memory.

This patch doesn't aim to solve this problem, since memory allocation is a very complicated issue. I believe users should have the choice to implement whatever suits their needs the most. In addition, the cost of allowing users to register and use their customized allocator is little to none: Registery::Get gets called only once.

I suppose @wweic is the reviewer for VM, what's your opinion?

Signed-off-by: JasonL [email protected]

Thanks for contributing to TVM! Please refer to guideline https://tvm.apache.org/docs/contribute/ for useful information and tips. After the pull request is submitted, please request code reviews from Reviewers by @ them in the pull request thread.

@MuchToMyDelight MuchToMyDelight force-pushed the support_cutomized_allocator_for_vm branch from 83ed1bd to b806afd Compare March 29, 2021 17:11
@MuchToMyDelight MuchToMyDelight force-pushed the support_cutomized_allocator_for_vm branch from b806afd to 02b04c8 Compare March 29, 2021 17:12
fix clang-format
@jroesch
Copy link
Member

jroesch commented Mar 30, 2021

Hey @MuchToMyDelight the patch looks overall good, I wonder if we should allow users to instead register by name or some other key to support multiple allocators to be loaded?

@MuchToMyDelight
Copy link
Author

Hey @MuchToMyDelight the patch looks overall good, I wonder if we should allow users to instead register by name or some other key to support multiple allocators to be loaded?

Hello jroesch, I'm not sure what do you mean by 'some other key'. Do you mean add a C++ api like Set/GetAllocator, instead of register by name? I chose register by name because: 1. it makes code clean & neat. 2. There are other places using the same pattern in TVM, e.g. DeviceApiManger uses keys like "device_api.gpu"/"device_api.cpu". So I suppose this is the 'TVM way' of doing this kind of thing.

@jroesch jroesch added the needs-triage PRs or issues that need to be investigated by maintainers to find the right assignees to address it label Jan 19, 2022
@tqchen tqchen closed this Sep 6, 2024
@MrJungle1
Copy link

After trying the VM in TVM, I found that the default memory allocator(PooledAllocator) doesn't work very well: in case of dynamic inputs, the size of used buffers are different from inference to inference and PooledAllocator cached buffers based on the size. Therefore, it ends with out of device memory.

@MuchToMyDelight Hello, I have the same problem on the mobile. Is there any way to solve it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-triage PRs or issues that need to be investigated by maintainers to find the right assignees to address it status: need review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants