Skip to content
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

[vulkan] Pad channels when using texture storage instead of "tight packing" #95251

Closed
wants to merge 2 commits into from

Commits on Feb 22, 2023

  1. [vulkan] Pad channels when using texture storage instead of "tight pa…

    …cking"
    
    Currently, in Vulkan 4D tensors are represented in GPU textures by simply combining the batch and channel dimensions into the depth axis. However, if the number of channels is not a multiple of 4, then data belonging to the same batch can cross texel boundaries.
    
    For instance, consider a tensor with `N=2`, `C=3`. The depth axis of the texture would contain the data
    
    ```
    |tex1|tex2|
    -----------
    |AAAB|BB00|
    ```
    Where A represents data from `n=1`and B represents data form `n=2`.
    
    This packing structure ("tight packing") makes some ops that care about batch boundaries more complex and inefficient to implement. Therefore this diff introduces channel padding when storing tensors as image textures.
    
    The same tensor with `N=2`, `C=3` would now have the depth axis contain
    
    ```
    |tex1|tex2|
    -----------
    |AAA0|BBB0|
    ```
    
    Differential Revision: [D43068669](https://our.internmc.facebook.com/intern/diff/D43068669/)
    
    **NOTE FOR REVIEWERS**: This PR has internal Meta-specific changes or comments, please review them on [Phabricator](https://our.internmc.facebook.com/intern/diff/D43068669/)!
    
    [ghstack-poisoned]
    SS-JIA committed Feb 22, 2023
    Configuration menu
    Copy the full SHA
    813f0a1 View commit details
    Browse the repository at this point in the history
  2. Update on "[vulkan] Pad channels when using texture storage instead o…

    …f "tight packing""
    
    Currently, in Vulkan 4D tensors are represented in GPU textures by simply combining the batch and channel dimensions into the depth axis. However, if the number of channels is not a multiple of 4, then data belonging to the same batch can cross texel boundaries.
    
    For instance, consider a tensor with `N=2`, `C=3`. The depth axis of the texture would contain the data
    
    ```
    |tex1|tex2|
    -----------
    |AAAB|BB00|
    ```
    Where A represents data from `n=1`and B represents data form `n=2`.
    
    This packing structure ("tight packing") makes some ops that care about batch boundaries more complex and inefficient to implement. Therefore this diff introduces channel padding when storing tensors as image textures.
    
    The same tensor with `N=2`, `C=3` would now have the depth axis contain
    
    ```
    |tex1|tex2|
    -----------
    |AAA0|BBB0|
    ```
    
    Differential Revision: [D43068669](https://our.internmc.facebook.com/intern/diff/D43068669/)
    
    **NOTE FOR REVIEWERS**: This PR has internal Meta-specific changes or comments, please review them on [Phabricator](https://our.internmc.facebook.com/intern/diff/D43068669/)!
    
    [ghstack-poisoned]
    SS-JIA committed Feb 22, 2023
    Configuration menu
    Copy the full SHA
    2790599 View commit details
    Browse the repository at this point in the history