It’s hard to represent scatter op in Linalg because there are some requirements in Linalg ops (e.g., indexing_maps, etc).
I’ve prototyped on how to compile mhlo.scatter op end-to-end in IREE. The current solution is that we created LinalgExt dialect in IREE, added a linalg_ext.scatter op. We implemented scatter → linalg_ext and linalg_ext → loops lowering. Then we can run it in IREE. https://github.com/google/iree/blob/main/llvm-external-projects/iree-dialects/include/iree-dialects/Dialect/LinalgExt/IR/LinalgExtOps.td#L46
Also, we did some optimization on the op. I.e. we are able to tile and distribute the op.
During the prototyping, I added a lowering from mhlo.scatter to linalg.generic op. But it only works for specific cases and it’s inefficient. I don’t think this is the way to go, just put a note here. https://github.com/tensorflow/mlir-hlo/blob/2554e989200ec94dc216797c1e29a0bf820b735a/lib/Dialect/mhlo/transforms/legalize_to_linalg.cc#L2344