Skip to content

Conversation

@manuelcandales
Copy link
Contributor

Summary:
We want to establish a pattern where portable ops fall back to some default allocator if the temp allocator isn't available. This would let users override how the memory is allocated if they care about it, but provide a reasonable default if they don't.

We add new PAL hooks for allocation, which default to calling malloc and free. This lets bare metal users inject their own allocator if malloc isn't defined for them.

This diff:

  • Adds et_pal_allocate() and et_pal_free() to platform.h
  • Provides default implementations of those in posix.cpp and minimal.cpp. Posix uses malloc/free, and minimal returns nullptr when trying to allocate.
  • Adds a MemoryAllocator subclass that uses the new PAL fallback allocator

We allocate a little more than requested and use that memory as a node in a linked list, pushing the allocated buffers onto a list that's iterated and freed when the KernelRuntimeContext is destroyed.

The runtime installs the default temp allocator (that uses the PAL hook to allocate) if one isn't provided

Differential Revision: D60601742

@pytorch-bot
Copy link

pytorch-bot bot commented Sep 6, 2024

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/5121

Note: Links to docs will display an error until the docs builds have been completed.

✅ No Failures

As of commit 5e0c38a with merge base 657789e (image):
💚 Looks good so far! There are no failures yet. 💚

This comment was automatically generated by Dr. CI and updates every 15 minutes.

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Sep 6, 2024
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D60601742

@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D60601742

manuelcandales added a commit to manuelcandales/executorch-1 that referenced this pull request Sep 6, 2024
Summary:
Pull Request resolved: pytorch#5121

We want to establish a pattern where portable ops fall back to some default allocator if the temp allocator isn't available. This would let users override how the memory is allocated if they care about it, but provide a reasonable default if they don't.

We add new PAL hooks for allocation, which default to calling malloc and free. This lets bare metal users inject their own allocator if malloc isn't defined for them.

This diff:
- Adds et_pal_allocate() and et_pal_free() to platform.h
- Provides default implementations of those in posix.cpp and minimal.cpp. Posix uses malloc/free, and minimal returns nullptr when trying to allocate.
- Adds a MemoryAllocator subclass that uses the new PAL fallback allocator

We allocate a little more than requested and use that memory as a node in a linked list, pushing the allocated buffers onto a list that's iterated and freed when the KernelRuntimeContext is destroyed.

The runtime installs the default temp allocator (that uses the PAL hook to allocate) if one isn't provided

Differential Revision: D60601742
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D60601742

manuelcandales added a commit to manuelcandales/executorch-1 that referenced this pull request Sep 6, 2024
Summary:
Pull Request resolved: pytorch#5121

We want to establish a pattern where portable ops fall back to some default allocator if the temp allocator isn't available. This would let users override how the memory is allocated if they care about it, but provide a reasonable default if they don't.

We add new PAL hooks for allocation, which default to calling malloc and free. This lets bare metal users inject their own allocator if malloc isn't defined for them.

This diff:
- Adds et_pal_allocate() and et_pal_free() to platform.h
- Provides default implementations of those in posix.cpp and minimal.cpp. Posix uses malloc/free, and minimal returns nullptr when trying to allocate.
- Adds a MemoryAllocator subclass that uses the new PAL fallback allocator

We allocate a little more than requested and use that memory as a node in a linked list, pushing the allocated buffers onto a list that's iterated and freed when the KernelRuntimeContext is destroyed.

The runtime installs the default temp allocator (that uses the PAL hook to allocate) if one isn't provided

Differential Revision: D60601742
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D60601742

manuelcandales added a commit to manuelcandales/executorch-1 that referenced this pull request Sep 10, 2024
Summary:
Pull Request resolved: pytorch#5121

We want to establish a pattern where portable ops fall back to some default allocator if the temp allocator isn't available. This would let users override how the memory is allocated if they care about it, but provide a reasonable default if they don't.

We add new PAL hooks for allocation, which default to calling malloc and free. This lets bare metal users inject their own allocator if malloc isn't defined for them.

This diff:
- Adds et_pal_allocate() and et_pal_free() to platform.h
- Provides default implementations of those in posix.cpp and minimal.cpp. Posix uses malloc/free, and minimal returns nullptr when trying to allocate.
- Adds a MemoryAllocator subclass that uses the new PAL fallback allocator

We allocate a little more than requested and use that memory as a node in a linked list, pushing the allocated buffers onto a list that's iterated and freed when the KernelRuntimeContext is destroyed.

The runtime installs the default temp allocator (that uses the PAL hook to allocate) if one isn't provided

Differential Revision: D60601742
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D60601742

manuelcandales added a commit to manuelcandales/executorch-1 that referenced this pull request Sep 10, 2024
Summary:
Pull Request resolved: pytorch#5121

We want to establish a pattern where portable ops fall back to some default allocator if the temp allocator isn't available. This would let users override how the memory is allocated if they care about it, but provide a reasonable default if they don't.

We add new PAL hooks for allocation, which default to calling malloc and free. This lets bare metal users inject their own allocator if malloc isn't defined for them.

This diff:
- Adds et_pal_allocate() and et_pal_free() to platform.h
- Provides default implementations of those in posix.cpp and minimal.cpp. Posix uses malloc/free, and minimal returns nullptr when trying to allocate.
- Adds a MemoryAllocator subclass that uses the new PAL fallback allocator

We allocate a little more than requested and use that memory as a node in a linked list, pushing the allocated buffers onto a list that's iterated and freed when the KernelRuntimeContext is destroyed.

The runtime installs the default temp allocator (that uses the PAL hook to allocate) if one isn't provided

Differential Revision: D60601742
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D60601742

manuelcandales added a commit to manuelcandales/executorch-1 that referenced this pull request Sep 10, 2024
Summary:
Pull Request resolved: pytorch#5121

We want to establish a pattern where portable ops fall back to some default allocator if the temp allocator isn't available. This would let users override how the memory is allocated if they care about it, but provide a reasonable default if they don't.

We add new PAL hooks for allocation, which default to calling malloc and free. This lets bare metal users inject their own allocator if malloc isn't defined for them.

This diff:
- Adds et_pal_allocate() and et_pal_free() to platform.h
- Provides default implementations of those in posix.cpp and minimal.cpp. Posix uses malloc/free, and minimal returns nullptr when trying to allocate.
- Adds a MemoryAllocator subclass that uses the new PAL fallback allocator

We allocate a little more than requested and use that memory as a node in a linked list, pushing the allocated buffers onto a list that's iterated and freed when the KernelRuntimeContext is destroyed.

The runtime installs the default temp allocator (that uses the PAL hook to allocate) if one isn't provided

Differential Revision: D60601742
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D60601742

manuelcandales added a commit to manuelcandales/executorch-1 that referenced this pull request Sep 10, 2024
Summary:
Pull Request resolved: pytorch#5121

We want to establish a pattern where portable ops fall back to some default allocator if the temp allocator isn't available. This would let users override how the memory is allocated if they care about it, but provide a reasonable default if they don't.

We add new PAL hooks for allocation, which default to calling malloc and free. This lets bare metal users inject their own allocator if malloc isn't defined for them.

This diff:
- Adds et_pal_allocate() and et_pal_free() to platform.h
- Provides default implementations of those in posix.cpp and minimal.cpp. Posix uses malloc/free, and minimal returns nullptr when trying to allocate.
- Adds a MemoryAllocator subclass that uses the new PAL fallback allocator

We allocate a little more than requested and use that memory as a node in a linked list, pushing the allocated buffers onto a list that's iterated and freed when the KernelRuntimeContext is destroyed.

The runtime installs the default temp allocator (that uses the PAL hook to allocate) if one isn't provided

Differential Revision: D60601742
Summary:
Pull Request resolved: pytorch#5121

We want to establish a pattern where portable ops fall back to some default allocator if the temp allocator isn't available. This would let users override how the memory is allocated if they care about it, but provide a reasonable default if they don't.

We add new PAL hooks for allocation, which default to calling malloc and free. This lets bare metal users inject their own allocator if malloc isn't defined for them.

This diff:
- Adds et_pal_allocate() and et_pal_free() to platform.h
- Provides default implementations of those in posix.cpp and minimal.cpp. Posix uses malloc/free, and minimal returns nullptr when trying to allocate.
- Adds a MemoryAllocator subclass that uses the new PAL fallback allocator

We allocate a little more than requested and use that memory as a node in a linked list, pushing the allocated buffers onto a list that's iterated and freed when the KernelRuntimeContext is destroyed.

The runtime installs the default temp allocator (that uses the PAL hook to allocate) if one isn't provided

Differential Revision: D60601742
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D60601742

@facebook-github-bot facebook-github-bot merged commit 4ce0f9d into pytorch:main Sep 10, 2024
per added a commit to per/executorch that referenced this pull request Sep 12, 2024
The introduction of the PlatformMemoryAllocator in
pytorch#5121 introduced a hard fault
in arm_executor_runner when not supplying the temp_allocator in the
MemoryManager, so add it to get tests running again.

Signed-off-by: Per Åstrand <per.astrand@arm.com>
Change-Id: I357244a15c1b1fdee567ad828e09e3607e43e2e7
facebook-github-bot pushed a commit that referenced this pull request Sep 12, 2024
Summary:
The introduction of the PlatformMemoryAllocator in #5121 introduced a hard fault in arm_executor_runner when not supplying the temp_allocator in the MemoryManager, so add it to get tests running again.

Change-Id: I357244a15c1b1fdee567ad828e09e3607e43e2e7

Pull Request resolved: #5302

Reviewed By: manuelcandales

Differential Revision: D62582281

Pulled By: digantdesai

fbshipit-source-id: c650771d5ad2eddf80b30fcbafaf6e731ca9eed3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. fb-exported

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants