    def __init__(self, original_tensor: Tensor) -> None:
        """
        Initializes the TensorAccessor with an "original" tensor.
        """
        super().__init__()
        # Tensor offset in terms of number of elements compared to the base tensor.
        self.offset = 0
        self.original_shapes = original_tensor._attrs["shape"]
        # We need dtype for computing alignment requirement
        self.tensor_dtype = original_tensor.dtype()
        # This strictly means that the tensor's memory itself is contiguous
        self.is_contiguous = True

        # These variables are only set when self.stride_dim != None.
        # A tensor can be contiguous and still come from a strided tensor,
        # e.g., when stride_dim == 0
        self.is_from_strided_tensor = False
        self.stride_dim = None
        self.actual_shapes = None

        # Total number of elements starting from the stride dim, before & after.
        self.original_total_elements_from_stride_dim = None
        self.actual_total_elements_from_stride_dim = None

        # List[(original_dim_group, actual_dim_group)], where
        # original_dim_group is a list of indices for self.original_shapes, and
        # actual_dim_group is a list of indices for self.actual_shapes.
        #
        # This field is used to record dim mapping between self.original_shapes
        # and self.actual_shapes when update_base_tensor_shape() is called,
        # which means this TensorAccessor is used to handle a view op (e.g. reshape).
        # This will be used together with strided_dim to calculate
        # strides based on original tensor shape and dim.
        #
        # By default, self._dim_mapping = [([0], [0]), ([1], [1]), ...., ([n], [n])],
        # where n = len(self.original_shapes) - 1.
        # It represents that there is 1:1 dim mapping relationship between
        # self.original_shapes and self.actual_shapes.
        #
        # When self.update_base_tensor_shape() is called, # dimension may be different
        # between self.original_shapes and self.actual_shapes.
        # e.g. The original tensor is in shape [2, 3, 2], and it's reshaped to [2, 6].
        # In this case, self._dim_mapping = [([0], [0]), ([1, 2], [1])], which represents
        # that self.original_shapes[0] and self.actual_shapes[0] are in the same group,
        # and self.original_shapes[1:2] and self.actual_shapes[1] are in the same group.
        #
        # It's possible that such a mapping cannot be calculated (e.g. because of
        # dynamic shapes), and in such a case, self._dim_mapping is updated to None
        # to represent that this tensor_accessor cannot be further updated with
        # another stride dims.
        self._dim_mapping = [([i], [i]) for i in range(len(self.original_shapes))]
Initializes the TensorAccessor with an "original" tensor.
python/aitemplate/compiler/tensor_accessor.py