cleanup(compiler): Remove dead code and usless pass

This commit is contained in:
Quentin Bourgerie
2022-06-16 17:05:35 +02:00
parent ab64532b7b
commit ef9d11c16f
7 changed files with 8 additions and 102 deletions

View File

@@ -47,12 +47,6 @@ def ConcreteToBConcrete : Pass<"concrete-to-bconcrete", "mlir::ModuleOp"> {
let dependentDialects = ["mlir::linalg::LinalgDialect", "mlir::concretelang::Concrete::ConcreteDialect", "mlir::concretelang::BConcrete::BConcreteDialect"];
}
def BConcreteToBConcreteCAPI : Pass<"bconcrete-to-bconcrete-c-api", "mlir::ModuleOp"> {
let summary = "Lower operations from the Bufferized Concrete dialect to std with function call to the Bufferized Concrete C API";
let constructor = "mlir::concretelang::createConvertBConcreteToBConcreteCAPIPass()";
let dependentDialects = ["mlir::concretelang::BConcrete::BConcreteDialect", "mlir::func::FuncDialect", "mlir::memref::MemRefDialect"];
}
def MLIRLowerableDialectsToLLVM : Pass<"mlir-lowerable-dialects-to-llvm", "mlir::ModuleOp"> {
let summary = "Lowers operations from MLIR lowerable dialects to LLVM";
let constructor = "mlir::concretelang::createConvertMLIRLowerableDialectsToLLVMPass()";

View File

@@ -1,5 +1,5 @@
set(LLVM_TARGET_DEFINITIONS Bufferize.td)
mlir_tablegen(Bufferize.h.inc -gen-pass-decls -name Transforms)
set(LLVM_TARGET_DEFINITIONS Passes.td)
mlir_tablegen(Passes.h.inc -gen-pass-decls -name Transforms)
add_public_tablegen_target(ConcretelangTransformsBufferizePassIncGen)
set(LLVM_TARGET_DEFINITIONS OneShotBufferizeDPSWrapper.td)

View File

@@ -3,21 +3,19 @@
// https://github.com/zama-ai/concrete-compiler-internal/blob/main/LICENSE.txt
// for license information.
#ifndef CONCRETELANG_BUFFERIZE_PASS_H
#define CONCRETELANG_BUFFERIZE_PASS_H
#ifndef CONCRETELANG_TRANSFORMS_PASS_H
#define CONCRETELANG_TRANSFORMS_PASS_H
#include <mlir/Dialect/Func/IR/FuncOps.h>
#include <mlir/Dialect/MemRef/IR/MemRef.h>
#include <mlir/Dialect/SCF/SCF.h>
#include <mlir/IR/BuiltinOps.h>
#include <mlir/Pass/Pass.h>
#define GEN_PASS_CLASSES
#include <concretelang/Transforms/Bufferize.h.inc>
#include <concretelang/Transforms/Passes.h.inc>
namespace mlir {
namespace concretelang {
std::unique_ptr<mlir::OperationPass<mlir::func::FuncOp>>
createFinalizingBufferizePass();
std::unique_ptr<mlir::OperationPass<mlir::ModuleOp>> createForLoopToParallel();
} // namespace concretelang

View File

@@ -3,16 +3,6 @@
include "mlir/Pass/PassBase.td"
def FinalizingBufferize
: Pass<"concretelang-bufferize", "::mlir::func::FuncOp"> {
let summary =
"Marks FHELinalg operations for tiling using a vector of tile sizes";
let constructor = "mlir::concretelang::createBufferizePass()";
let options = [];
let dependentDialects =
["mlir::memref::MemRefDialect", "mlir::func::FuncDialect"];
}
def ForLoopToParallel : Pass<"for-loop-to-parallel", "mlir::ModuleOp"> {
let summary =
"Transform scf.for marked with the custom attribute parallel = true loop "

View File

@@ -1,75 +0,0 @@
// Part of the Concrete Compiler Project, under the BSD3 License with Zama
// Exceptions. See
// https://github.com/zama-ai/concrete-compiler-internal/blob/main/LICENSE.txt
// for license information.
#include "concretelang/Transforms/Bufferize.h"
#include "mlir/Dialect/Bufferization/Transforms/Bufferize.h"
#include "mlir/Dialect/MemRef/IR/MemRef.h"
#include "mlir/IR/Operation.h"
#include "mlir/Transforms/DialectConversion.h"
#include "mlir/Transforms/Passes.h"
using namespace mlir;
namespace {
// In a finalizing bufferize conversion, we know that all tensors have been
// converted to memrefs, thus, this op becomes an identity.
class BufferizeTensorStoreOp
: public OpConversionPattern<memref::TensorStoreOp> {
public:
using OpConversionPattern::OpConversionPattern;
LogicalResult
matchAndRewrite(memref::TensorStoreOp op, OpAdaptor adaptor,
ConversionPatternRewriter &rewriter) const override {
rewriter.replaceOpWithNewOp<memref::CopyOp>(op, op.tensor(), op.memref());
return success();
}
};
} // namespace
void populatePatterns(bufferization::BufferizeTypeConverter &typeConverter,
RewritePatternSet &patterns) {
bufferization::populateEliminateBufferizeMaterializationsPatterns(
typeConverter, patterns);
patterns.add<BufferizeTensorStoreOp>(typeConverter, patterns.getContext());
}
namespace {
struct FinalizingBufferizePass
: public FinalizingBufferizeBase<FinalizingBufferizePass> {
using FinalizingBufferizeBase<
FinalizingBufferizePass>::FinalizingBufferizeBase;
void runOnOperation() override {
auto func = getOperation();
auto *context = &getContext();
bufferization::BufferizeTypeConverter typeConverter;
RewritePatternSet patterns(context);
ConversionTarget target(*context);
populatePatterns(typeConverter, patterns);
// If all result types are legal, and all block arguments are legal (ensured
// by func conversion above), then all types in the program are legal.
//
// We also check that the operand types are legal to avoid creating invalid
// IR. For example, this prevents
// populateEliminateBufferizeMaterializationsPatterns from updating the
// types of the operands to a return op without updating the enclosing
// function.
target.markUnknownOpDynamicallyLegal(
[&](Operation *op) { return typeConverter.isLegal(op); });
target.addLegalOp<memref::CopyOp>();
if (failed(applyFullConversion(func, target, std::move(patterns))))
signalPassFailure();
}
};
} // namespace
std::unique_ptr<OperationPass<func::FuncOp>>
mlir::concretelang::createFinalizingBufferizePass() {
return std::make_unique<FinalizingBufferizePass>();
}

View File

@@ -1,5 +1,4 @@
add_mlir_library(ConcretelangTransforms
Bufferize.cpp
OneShotBufferizeDPSWrapper.cpp
ForLoopToParallel.cpp
@@ -11,7 +10,7 @@ add_mlir_library(ConcretelangTransforms
ConcretelangTransformsBufferizePassIncGen
ConcretelangTransformsOneShotBufferizeDPSWrapperPassIncGen
mlir-headers
LINK_LIBS PUBLIC
MLIRIR
MLIRMemRef

View File

@@ -3,7 +3,7 @@
// https://github.com/zama-ai/concrete-compiler-internal/blob/main/LICENSE.txt
// for license information.
#include "concretelang/Transforms/Bufferize.h"
#include "concretelang/Transforms/Passes.h"
#include "mlir/Dialect/Bufferization/Transforms/Bufferize.h"
#include "mlir/Dialect/SCF/SCF.h"