[ET-VK] Clean up api::vTensor class#3149
Closed
SS-JIA wants to merge 2 commits intogh/SS-JIA/40/basefrom
Closed
Conversation
Differential Revision: [D55811279](https://our.internmc.facebook.com/intern/diff/D55811279/) [ghstack-poisoned]
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/3149
Note: Links to docs will display an error until the docs builds have been completed. ✅ No FailuresAs of commit 1863fa6 with merge base 269b6ad ( This comment was automatically generated by Dr. CI and updates every 15 minutes. |
Contributor
|
This pull request was exported from Phabricator. Differential Revision: D55811279 |
This was referenced Apr 19, 2024
junpi3
approved these changes
Apr 19, 2024
## Context Now that we have forked the `api/` directory from PyTorch Vulkan, we can clean up the `vTensor` class and remove functionality that is not necessary for the ExecuTorch Vulkan delegate. The following changes are made: * Remove unused member variables and member functions from `vTensor` and `vTensorStorage` * Remove all quantization related member variables, member functions, and the `vTensor` constructor for quantized tensors. The Quantization API will be reworked from the ground up. * Rename `view_` (which is an instance of `vTensorStorage`) to `storage_` Finally, the critical change that is introduced is that we now store `storage_` as a direct `vTensorStorage` member variable in `vTensor` instead of storing it as a `std::shared_ptr<vTensorStorage>`. For context, the reason `storage_` was stored as a shared pointer is to be compliant with ATen Tensors, which needs to enable copy construction to enable the following: ``` at::Tensor b = at::rand(...); // Oftentimes this will create a "view" of the tensor. a and b will point the the same underlying storage, but with different metadata. at::Tensor a = b; ``` However, in the ExecuTorch delegate this is no longer necessary. Each Tensor is associated with it's own independent storage and is responsible for managing it's own memory. **By getting rid of `std::shared_ptr`, we can avoid a heap allocation and avoid chasing pointers whenever we need to access the resources of a `vTensor`.** Differential Revision: [D55811279](https://our.internmc.facebook.com/intern/diff/D55811279/) [ghstack-poisoned]
Contributor
|
This pull request was exported from Phabricator. Differential Revision: D55811279 |
Contributor
|
This pull request has been merged in bf5093a. |
Closed
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.
Stack from ghstack (oldest at bottom):
ParamsBindListto prevent needing to passshared_ptrto bind parameter UBOs #3150Value#3148Context
Now that we have forked the
api/directory from PyTorch Vulkan, we can clean up thevTensorclass and remove functionality that is not necessary for the ExecuTorch Vulkan delegate.The following changes are made:
vTensorandvTensorStoragevTensorconstructor for quantized tensors. The Quantization API will be reworked from the ground up.view_(which is an instance ofvTensorStorage) tostorage_Finally, the critical change that is introduced is that we now store
storage_as a directvTensorStoragemember variable invTensorinstead of storing it as astd::shared_ptr<vTensorStorage>.For context, the reason
storage_was stored as a shared pointer is to be compliant with ATen Tensors, which needs to enable copy construction to enable the following:However, in the ExecuTorch delegate this is no longer necessary. Each Tensor is associated with it's own independent storage and is responsible for managing it's own memory. By getting rid of
std::shared_ptr, we can avoid a heap allocation and avoid chasing pointers whenever we need to access the resources of avTensor.Differential Revision: D55811279