-
Notifications
You must be signed in to change notification settings - Fork 684
Metal backend: Add AOTI shims for memory management #15021
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
base: gh/manuelcandales/140/head
Are you sure you want to change the base?
Metal backend: Add AOTI shims for memory management #15021
Conversation
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/15021
Note: Links to docs will display an error until the docs builds have been completed. ❗ 2 Active SEVsThere are 2 currently active SEVs. If your PR is affected, please view them below:
❌ 5 New Failures, 1 Cancelled JobAs of commit f12117b with merge base 896178e ( NEW FAILURES - The following jobs have failed:
CANCELLED JOB - The following job was cancelled. Please retry:
This comment was automatically generated by Dr. CI and updates every 15 minutes. |
dtype); | ||
int64_t nbytes = numel * element_size; | ||
|
||
if (device_type == 2) { // Metal/MPS |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not use the function?
int32_t mps_device_type = aoti_torch_device_type_mps(); // Returns 13
if (device_type == mps_device_type) {
...
}
ET_LOG( | ||
Debug, | ||
"aoti_torch_delete_tensor_object: successfull (Metal GPU memory)"); | ||
return Error::Ok; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
returning early causes memory leak, no?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe explicitly implement metal_free_buffer to properly clean up metal buffers and call the method whenever appropriate
#include <executorch/backends/apple/metal/runtime/shims/tensor_attribute.h> | ||
#include <executorch/backends/apple/metal/runtime/shims/utils.h> | ||
#include <executorch/runtime/platform/log.h> | ||
#include <cstdint> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
duplicate declaration
Implement the following shims: