Skip to content

torch.aten.as_strided produces incorrect views, should not be decomposed from torch.chunk #4339

@raayandhar

Description

@raayandhar

From discussion with @zjgarvey, we have the following findings (mostly Zach, huge thanks):

The torch.chunk operation currently relies on aten.as_strided which is overkill for what the op actually does, and it can use .slice instead. However, we also note that aten.as_strided relies on accurate stride input layout, but in torch-mlir, tensors are materialized as contiguous (torch can have non-contiguous tensors, we don't. For example, transpose the input.). Therefore the static accessings args from as_strided refer to data that is no longer in the same format.

aten.as_strided is only generated in decompositions of split.Tensor. We propose that

  1. Remove aten.as_strided from all decomposition lists in torch-mlir (all paths reachable post-import) fix: remove split.Tensor and split_with_sizes from decomp tables #4340
  2. On the IREE side, we can add the RecomposeComplexOps pass from torch-mlir that will decompose .chunk into .slice instead of as_strided [Codegen] Add RecomposeComplexOps pass in Torch/InputConversion/Passes iree-org/iree#22276
  3. Remove split.Tensor and split_with_sizes from IREE-Turbine's decomposition table http://github.com/iree-org/iree-turbine/pull/1175
    Eventually we should probably deprecate the aten.as_strided support and throw an error on input when we see a aten.as_strided op, since we cannot guarantee the correctness.

Related issues:

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions