Skip to content

Why does stablehlo.reshape not convert directly to tensor.reshape, but instead lower to tensor.collapse_shape or tensor.expand_shape? #2831

@heshuju

Description

@heshuju

I’m using stablehloConvertToLinalg, and I noticed that stablehlo.reshape gets decomposed into tensor.collapse_shape and tensor.expand_shape.
However, I also see that the tensor dialect has a tensor.reshape operation, which seems to have the same semantics.
I’m a bit confused — why not lower stablehlo.reshape directly to tensor.reshape? Is there a specific reason for choosing collapse_shape / expand_shape instead?

https://github.com/openxla/stablehlo/blob/main/stablehlo/conversions/linalg/transforms/StablehloLegalizeToLinalg.cpp#L1088

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