-
Notifications
You must be signed in to change notification settings - Fork 725
[ET-VK] Fix tensor views with tensors that use deferred memory allocation #5831
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
Conversation
…tion ## Context Fix one (hopefully) final kink with tensor views. ### The issue When creating a tensor view of a tensor that uses deferred memory allocation, at the time the view is created, it will copy the handle of the original tensor's `VkImage`. However, since the `VkImage` is not yet bounded to memory, it will have have a `VkImageView` associated with it, and the tensor view will copy the `VkImageView` handle and `VK_NULL_HANDLE`. Later, the original tensor is expected to be bound to an allocation, at which point it will create an image view and bind the `VkImage` to memory. However, this does not update its views, which will still have a null `VkImageView`. If the tensor view is also bound to the allocation, then the same `VkImage` will be bound to the same memory multiple times which is against the Vulkan spec. ### The fix Allow binding of `VulkanImage` and `VulkanBuffer` copies to only call the binding function if it is not a copy; assume that the original tensor is responsible for binding to memory. In `ComputeGraph`, when adding a tensor view, add the created `Value` as a user of any `SharedObject` of which the original tensor is also a user. Differential Revision: [D63790718](https://our.internmc.facebook.com/intern/diff/D63790718/) [ghstack-poisoned]
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/5831
Note: Links to docs will display an error until the docs builds have been completed. ✅ No FailuresAs of commit 5aecf69 with merge base 3aa6b14 ( This comment was automatically generated by Dr. CI and updates every 15 minutes. |
|
This pull request was exported from Phabricator. Differential Revision: D63790718 |
…mory allocation" ## Context Fix one (hopefully) final kink with tensor views. ### The issue When creating a tensor view of a tensor that uses deferred memory allocation, at the time the view is created, it will copy the handle of the original tensor's `VkImage`. However, since the `VkImage` is not yet bounded to memory, it will have have a `VkImageView` associated with it, and the tensor view will copy the `VkImageView` handle and `VK_NULL_HANDLE`. Later, the original tensor is expected to be bound to an allocation, at which point it will create an image view and bind the `VkImage` to memory. However, this does not update its views, which will still have a null `VkImageView`. If the tensor view is also bound to the allocation, then the same `VkImage` will be bound to the same memory multiple times which is against the Vulkan spec. ### The fix Allow binding of `VulkanImage` and `VulkanBuffer` copies to only call the binding function if it is not a copy; assume that the original tensor is responsible for binding to memory. In `ComputeGraph`, when adding a tensor view, add the created `Value` as a user of any `SharedObject` of which the original tensor is also a user. Differential Revision: [D63790718](https://our.internmc.facebook.com/intern/diff/D63790718/) [ghstack-poisoned]
|
This pull request was exported from Phabricator. Differential Revision: D63790718 |
…mory allocation" ## Context Fix one (hopefully) final kink with tensor views. ### The issue When creating a tensor view of a tensor that uses deferred memory allocation, at the time the view is created, it will copy the handle of the original tensor's `VkImage`. However, since the `VkImage` is not yet bounded to memory, it will have have a `VkImageView` associated with it, and the tensor view will copy the `VkImageView` handle and `VK_NULL_HANDLE`. Later, the original tensor is expected to be bound to an allocation, at which point it will create an image view and bind the `VkImage` to memory. However, this does not update its views, which will still have a null `VkImageView`. If the tensor view is also bound to the allocation, then the same `VkImage` will be bound to the same memory multiple times which is against the Vulkan spec. ### The fix Allow binding of `VulkanImage` and `VulkanBuffer` copies to only call the binding function if it is not a copy; assume that the original tensor is responsible for binding to memory. In `ComputeGraph`, when adding a tensor view, add the created `Value` as a user of any `SharedObject` of which the original tensor is also a user. Differential Revision: [D63790718](https://our.internmc.facebook.com/intern/diff/D63790718/) [ghstack-poisoned]
|
This pull request was exported from Phabricator. Differential Revision: D63790718 |
|
This pull request has been merged in 7559ddd. |
Stack from ghstack (oldest at bottom):
repeat_interleave#5830Context
Fix one (hopefully) final kink with tensor views.
The issue
When creating a tensor view of a tensor that uses deferred memory allocation, at the time the view is created, it will copy the handle of the original tensor's
VkImage. However, since theVkImageis not yet bounded to memory, it will have have aVkImageViewassociated with it, and the tensor view will copy theVkImageViewhandle andVK_NULL_HANDLE.Later, the original tensor is expected to be bound to an allocation, at which point it will create an image view and bind the
VkImageto memory. However, this does not update its views, which will still have a nullVkImageView.If the tensor view is also bound to the allocation, then the same
VkImagewill be bound to the same memory multiple times which is against the Vulkan spec.The fix
Allow binding of
VulkanImageandVulkanBuffercopies to only call the binding function if it is not a copy; assume that the original tensor is responsible for binding to memory.In
ComputeGraph, when adding a tensor view, add the createdValueas a user of anySharedObjectof which the original tensor is also a user.Differential Revision: D63790718