Files
clang-p2996/mlir/lib/Dialect/Bufferization/IR/SubsetInsertionOpInterface.cpp
Matthias Springer 8143307b33 [mlir][bufferization] Generalize tensor slice rules to subset ops (#65619)
This commit generalizes the special
tensor.extract_slice/tensor.insert_slice bufferization rules to tensor
subset ops.

Ops that insert a tensor into a tensor at a specified subset (e.g.,
tensor.insert_slice, tensor.scatter) can implement the
`SubsetInsertionOpInterface`.

Apart from adding a new op interface (extending the API), this change is
NFC. The only ops that currently implement the new interface are
tensor.insert_slice and tensor.parallel_insert_slice, and those ops were
are supported by One-Shot Bufferize.
2023-09-13 12:27:19 +02:00

24 lines
976 B
C++

//===- SubsetInsertionOpInterface.cpp - Tensor Subsets --------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#include "mlir/Dialect/Bufferization/IR/SubsetInsertionOpInterface.h"
#include "mlir/Interfaces/DestinationStyleOpInterface.h"
#include "mlir/Dialect/Bufferization/IR/SubsetInsertionOpInterface.cpp.inc"
using namespace mlir;
OpOperand &bufferization::detail::defaultGetDestinationOperand(Operation *op) {
auto dstOp = dyn_cast<DestinationStyleOpInterface>(op);
assert(dstOp && "getDestination must be implemented for non-DPS ops");
assert(
dstOp.getNumDpsInits() == 1 &&
"getDestination must be implemented for ops with 0 or more than 1 init");
return *dstOp.getDpsInitOperand(0);
}