vTensor cleanup 4/N - consolidate texture positions and extents to be logical positions and extents (#5442)
Summary: Pull Request resolved: https://github.com/pytorch/executorch/pull/5442 ## Context Tensors are N-dimensional constructs, whereas image textures are limited to 3 dimensions (with an X, Y, and Z axis). Before axis mapping was introduced, converting between tensor index and texture coordinate, as well as converting between tensor sizes and texture limits, was easy because of rigid way texture axes were used to represent tensor dimensions: 1. the X axis of the tensor corresponds to the width dim 2. the Y axis of the tensor corresponds to the height dim 3. the Z axis of the tensor corresponds to the combined batch + channels dim However, with the introduction of axis mapping, the texture representation of a tensor is far more flexible. NOTE: summary is still a WIP. Short on time today so will fill in more context later This diff consolidates all image extent related member variables of `vTensor` to use logical texture limits instead of physical texture limits. The reason for this is to reduce developer confusion about different representations of texture metadata, and also to enforce better practices in shader programming. Using logical texture positions and logical texture limits is usually preferable because of the following: 1. Each element has a clear relationship to a tensor dimension, thus it is easier to understand semantically 2. It's more efficient to translate between logical texture position and tensor indices; in shaders, we often have to convert texture positions to tensor indices to coordinate data loads/write among the different input tensors and output tensor ## Notes for Reviewers There are a large number of changes in this file, but majority of meaningful changes are in `Tensor.h` and `Tensor.cpp`. The rest is just replacing instance of `image_extents()` and `texture_limits()` with `logical_limits()`. ghstack-source-id: 243309911 exported-using-ghexport Reviewed By: jorgep31415 Differential Revision: D62901893 fbshipit-source-id: bfb63151c85255967ed9e26afc82eaa70b1b365b
S
Stephen Jia committed
f5f54b883f623758966f95c01bfa59f54f2425ad
Parent: 958afe1
Committed by Facebook GitHub Bot <facebook-github-bot@users.noreply.github.com>
on 9/18/2024, 4:59:53 PM