[RFC] Should `vector.reshape` be removed?

As part of a little tidy-up I’ve been doing (see [mlir][vector] Use `DenseI64ArrayAttr` for constant_mask dim sizes by MacDue · Pull Request #100997 · llvm/llvm-project · GitHub), I took a look at vector.reshape.

This operation was added five years ago and has no lowerings or uses within upstream MLIR. There’s only a handful of round-trip tests.

It seems the actual implementation has been left as a TODO:

// TODO: Add transformation which decomposes ReshapeOp into an optimized
// sequence of vector rotate/shuffle/select operations.

Is there any reason to keep an operation like this around? Are there downstream uses/implementations? or is this just an operation that was forgotten about?

Note: I don’t mind if it stays or goes, I’m just wondering why it is still here :slight_smile:

I’ve grepped the IREE code base and haven’t found any uses either.

So +1 to dropping it.

Thanks for the cleanup! +1 to remove it.

Local search yielded no usage from Intel side. +1 from us.

I’ve made a PR for removal here: [mlir][vector] Remove `vector.reshape` operation by MacDue · Pull Request #101645 · llvm/llvm-project · GitHub

As a related idea, sometime later vector.shape_cast could be renamed to vector.reshape, which could be a more accurate name (as shape_casts are not necessarily cast, they can lower to data movement).

Forgot to hit send earlier: no usage Google side either.

I’d avoid too many renames in one go. Let this one sink, and if no downstream is affected, we talk about the next one.

Renaming is more complicated than removing an unused op. Unless of course, the renamed op is also unused. But I’d not cross wires as a general strategy.

Of course :+1:

I don’t intend to rename shape_cast with this change (or soon after it). It just occurred to me that if “vector.reshape” was free, it may be a more fitting name for what vector.shape_cast has evolved into.

I’ve landed the removal now (though I don’t object to a revert if someone wants to save the operation :slight_smile:).

Also, I have a patch to add a notice to Deprecations & Current Refactoring - MLIR here: Add notice about the removal of `vector.reshape` by MacDue · Pull Request #198 · llvm/mlir-www · GitHub (though I don’t have commit access there).