[Vulkan] Let tensor adopt an image with caller-supplied sizes - #21930
Open
kiymetakdemir wants to merge 1 commit into
Open
[Vulkan] Let tensor adopt an image with caller-supplied sizes#21930kiymetakdemir wants to merge 1 commit into
kiymetakdemir wants to merge 1 commit into
Conversation
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/21930
Note: Links to docs will display an error until the docs builds have been completed. ❌ 1 Unclassified FailureAs of commit 47404f6 with merge base 14326d9 ( UNCLASSIFIED FAILURE - DrCI could not classify the following job because the workflow did not run on the merge base. The failure may be pre-existing on trunk or introduced by this PR:
This comment was automatically generated by Dr. CI and updates every 15 minutes. |
This PR needs a
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
vTensor(context, image)infers the tensor's shape from the image's extents, and aVkImagehas three: width, height and depth, so that inference always yields a rank-3 shape. A logical shape such as[B, S, H, D]is unreachable, which blocks wrapping an externally owned image as a tensor whose axes the shaders can index.This lets the caller pass the image to the main vTensor constructor instead, so the sizes, dtype and layout come from the caller and only the storage comes from the image. A ComputeGraph::add_tensor overload reaches it. The image is held as a
VulkanImagecopy, which aliases the handle withis_copy_set, so the adopted view never destroys memory. An extent check rejects an image whose size disagrees with the requested sizes.The allocating path is untouched. The parameter defaults to
nullptrand construction only diverges when it is set, sological_limitsstill seeds from the physical extents as before.Files
backends/vulkan/runtime/api/containers/Tensor.h—adopt_imageon thevTensorconstructor.backends/vulkan/runtime/api/containers/Tensor.cpp— storage selection between the adopting and allocatingvTensorStorage, and the extent check.backends/vulkan/runtime/graph/ComputeGraph.h,.cpp— anadd_tensoroverload taking sizes, dtype, memory layout and an image.backends/vulkan/test/vulkan_compute_api_test.cpp— 3 new tests.Testing
vulkan_compute_api_testNew coverage: adopting at[1, 37, 8, 64]and keeping all four sizes, asserted against the inferring constructor collapsing the same image to rank 3; rejecting an image whose extents disagree with the requested sizes; and an adopted view reportingis_copy_ofthe source and leaving the source image live after the view is destroyed and deferred cleanup has run.cc @SS-JIA @manuelcandales @digantdesai @cbilgin