18#include "mlir/Dialect/GPU/IR/GPUDialect.h"
19#include "mlir/Dialect/MemRef/IR/MemRef.h"
20#include "mlir/IR/DialectRegistry.h"
21#include "mlir/Support/LogicalResult.h"
27struct GPUAllocOpInterface
28 :
public MultidimensionalAllocInterface::ExternalModel<GPUAllocOpInterface,
30 Value allocate(Operation *op, OpBuilder &rewriter, Location loc, Type newType,
31 ValueRange dynamicDims)
const {
32 return gpu::AllocOp::create(rewriter, loc, cast<MemRefType>(newType),
33 ValueRange{}, dynamicDims,
38 void deallocate(Operation *op, OpBuilder &rewriter, Location loc,
40 gpu::DeallocOp::create(rewriter, loc, TypeRange(),
44 bool isDeallocation(Operation *op, Operation *user)
const {
45 return isa<gpu::DeallocOp>(user);
49struct GPULaunchOpInterface
50 :
public AutoDiffOpInterface::ExternalModel<GPULaunchOpInterface,
52 LogicalResult createForwardModeTangent(Operation *op, OpBuilder &builder,
58 for (
auto ®ion : op->getRegions())
59 for (
auto &block : region)
60 for (Operation &o : block)
69 DialectRegistry ®istry) {
70 registry.addExtension(+[](MLIRContext *context, gpu::GPUDialect *) {
71 gpu::AllocOp::attachInterface<GPUAllocOpInterface>(*context);
72 gpu::LaunchOp::attachInterface<GPULaunchOpInterface>(*context);
LogicalResult visitChild(Operation *op)
void registerGPUDialectAutoDiffInterface(DialectRegistry ®istry)
void registerAutoDiffUsingRegionTerminatorInterface(MLIRContext &context)