This is an archive of the discontinued LLVM Phabricator instance.

Introduce tensor.insert op to Tensor dialect.
ClosedPublic

Authored by hanchung on Jun 11 2021, 11:29 AM.

Details

Summary

Add tensor.insert op to make tensor.extract/tensor.insert work in pairs
for scalar domain. Like subtensor/subtensor_insert work in pairs in
tensor domain, and vector.transfer_read/vector.transfer_write work in
pairs in vector domain.

Diff Detail

Event Timeline

hanchung created this revision.Jun 11 2021, 11:29 AM
hanchung requested review of this revision.Jun 11 2021, 11:29 AM
hanchung updated this revision to Diff 351516.Jun 11 2021, 11:35 AM

delete wrong comments

silvas requested changes to this revision.Jun 11 2021, 12:40 PM
silvas added inline comments.
mlir/include/mlir/Dialect/Tensor/IR/TensorOps.td
212

Could the syntax tensor.insert %ut into %dest[%1, %2] : tensor<*xi32>work as well? The scalar type being inserted should always be the tensor element type (I think TypesMatchWith is able to support this)

227

nit: why is cast to ShapedType needed?

mlir/lib/Dialect/Tensor/IR/TensorOps.cpp
299

Redundant after you add TypesMatchWith for scalar.

This revision now requires changes to proceed.Jun 11 2021, 12:40 PM
hanchung updated this revision to Diff 351572.Jun 11 2021, 3:54 PM
hanchung marked 3 inline comments as done.

address comments

mlir/include/mlir/Dialect/Tensor/IR/TensorOps.td
212

Yes, it works. I also added the case to ops.mlir. It won't complain after adding TypesMatchWith.

227

Done. It is not needed. I copied it from ExtractOp, but did not notice it.

mlir/lib/Dialect/Tensor/IR/TensorOps.cpp
299

Done, deleted.

silvas accepted this revision.Jun 11 2021, 5:24 PM
This revision is now accepted and ready to land.Jun 11 2021, 5:24 PM
This revision was automatically updated to reflect the committed changes.