Skip to content

[mlir][Interfaces] Add SubsetOpInterface and SubsetExtractionOpInterface #70617

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
#include "mlir/Interfaces/CopyOpInterface.h"
#include "mlir/Interfaces/DestinationStyleOpInterface.h"
#include "mlir/Interfaces/InferTypeOpInterface.h"
#include "mlir/Interfaces/SubsetInsertionOpInterface.h"
#include "mlir/Interfaces/SubsetOpInterface.h"

//===----------------------------------------------------------------------===//
// Bufferization Dialect
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ include "mlir/Dialect/Bufferization/IR/BufferizationBase.td"
include "mlir/Interfaces/DestinationStyleOpInterface.td"
include "mlir/Interfaces/InferTypeOpInterface.td"
include "mlir/Interfaces/SideEffectInterfaces.td"
include "mlir/Interfaces/SubsetInsertionOpInterface.td"
include "mlir/Interfaces/SubsetOpInterface.td"
include "mlir/Interfaces/CopyOpInterface.td"

class Bufferization_Op<string mnemonic, list<Trait> traits = []>
Expand Down Expand Up @@ -220,6 +220,7 @@ def Bufferization_MaterializeInDestinationOp
AllElementTypesMatch<["source", "dest"]>,
BufferizableOpInterface, DestinationStyleOpInterface,
DeclareOpInterfaceMethods<ReifyRankedShapedTypeOpInterface>,
DeclareOpInterfaceMethods<SubsetOpInterface>,
DeclareOpInterfaceMethods<SubsetInsertionOpInterface,
["getSourceOperand", "getValuesNeededToBuildSubsetExtraction",
"buildSubsetExtraction", "isEquivalentSubset"]>,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ namespace mlir {
class DialectRegistry;

namespace linalg {
void registerSubsetInsertionOpInterfaceExternalModels(
DialectRegistry &registry);
void registerSubsetOpInterfaceExternalModels(DialectRegistry &registry);
} // namespace linalg
} // namespace mlir

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ namespace mlir {
class DialectRegistry;

namespace tensor {
void registerSubsetInsertionOpInterfaceExternalModels(
DialectRegistry &registry);
void registerSubsetOpInterfaceExternalModels(DialectRegistry &registry);
} // namespace tensor
} // namespace mlir

Expand Down
4 changes: 2 additions & 2 deletions mlir/include/mlir/InitAllDialects.h
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ inline void registerAllDialects(DialectRegistry &registry) {
cf::registerBufferDeallocationOpInterfaceExternalModels(registry);
gpu::registerBufferDeallocationOpInterfaceExternalModels(registry);
linalg::registerBufferizableOpInterfaceExternalModels(registry);
linalg::registerSubsetInsertionOpInterfaceExternalModels(registry);
linalg::registerSubsetOpInterfaceExternalModels(registry);
linalg::registerTilingInterfaceExternalModels(registry);
linalg::registerValueBoundsOpInterfaceExternalModels(registry);
memref::registerAllocationOpInterfaceExternalModels(registry);
Expand All @@ -167,7 +167,7 @@ inline void registerAllDialects(DialectRegistry &registry) {
tensor::registerBufferizableOpInterfaceExternalModels(registry);
tensor::registerFindPayloadReplacementOpInterfaceExternalModels(registry);
tensor::registerInferTypeOpInterfaceExternalModels(registry);
tensor::registerSubsetInsertionOpInterfaceExternalModels(registry);
tensor::registerSubsetOpInterfaceExternalModels(registry);
tensor::registerTilingInterfaceExternalModels(registry);
tensor::registerValueBoundsOpInterfaceExternalModels(registry);
vector::registerBufferizableOpInterfaceExternalModels(registry);
Expand Down
2 changes: 1 addition & 1 deletion mlir/include/mlir/Interfaces/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ add_mlir_interface(ParallelCombiningOpInterface)
add_mlir_interface(RuntimeVerifiableOpInterface)
add_mlir_interface(ShapedOpInterfaces)
add_mlir_interface(SideEffectInterfaces)
add_mlir_interface(SubsetInsertionOpInterface)
add_mlir_interface(SubsetOpInterface)
add_mlir_interface(TilingInterface)
add_mlir_interface(ValueBoundsOpInterface)
add_mlir_interface(VectorInterfaces)
Expand Down
27 changes: 0 additions & 27 deletions mlir/include/mlir/Interfaces/SubsetInsertionOpInterface.h

This file was deleted.

155 changes: 0 additions & 155 deletions mlir/include/mlir/Interfaces/SubsetInsertionOpInterface.td

This file was deleted.

45 changes: 45 additions & 0 deletions mlir/include/mlir/Interfaces/SubsetOpInterface.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
//===- SubsetOpInterface.h - Tensor Subsets ---------------------*- C++ -*-===//
//
// 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
//
//===----------------------------------------------------------------------===//

#ifndef MLIR_INTERFACES_SUBSETOPINTERFACE_H_
#define MLIR_INTERFACES_SUBSETOPINTERFACE_H_

#include "mlir/IR/OpDefinition.h"

namespace mlir {
class SubsetOpInterface;
class SubsetExtractionOpInterface;
class SubsetInsertionOpInterface;

namespace detail {

/// Return the destination/"init" operand of the op if it implements the
/// `DestinationStyleOpInterface` and has exactly one "init" operand. Asserts
/// otherwise.
OpOperand &defaultGetDestinationOperand(Operation *op);

/// Return the updated destination result of the op if it implements the
/// `DestinationStyleOpInterface`.
OpResult defaultGetUpdatedDestination(Operation *op);

/// Default implementation of `isEquivalentSubset`.
bool defaultIsEquivalentSubset(Operation *op, Value candidate,
function_ref<bool(Value, Value)> equivalenceFn);

/// Verify `SubsetOpInterface`.
LogicalResult verifySubsetOpInterface(SubsetOpInterface op);

/// Verify `SubsetExtractionOpInterface`.
LogicalResult verifySubsetExtractionOpInterface(SubsetExtractionOpInterface op);

} // namespace detail
} // namespace mlir

#include "mlir/Interfaces/SubsetOpInterface.h.inc"

#endif // MLIR_INTERFACES_SUBSETOPINTERFACE_H_
Loading