feat(compiler): Add op interface SDFGConvertibleOpInterface

This adds a new operation interface `SDFGConvertibleOpInterface` that
allows an operation to specify how it is converted to an SDFG
process. The interface consists of a single method `convert` that
receives as the arguments the DFG created using `SDFG.init`, a set of
SDFG input streams corresponding to the operands and a set of output
streams for results. The order of the input and output streams
corresponds to the order of the operands and output values,
respectively.
This commit is contained in:
Andi Drebes
2022-11-25 14:37:19 +01:00
committed by Andi Drebes
parent 9f3615513b
commit b7805f00d3
9 changed files with 73 additions and 1 deletions

View File

@@ -1 +1,2 @@
add_subdirectory(Interfaces)
add_subdirectory(IR)

View File

@@ -0,0 +1 @@
add_mlir_interface(SDFGConvertibleInterface)

View File

@@ -0,0 +1,14 @@
// 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.
#ifndef CONCRETELANG_DIALECT_SDFG_INTERFACES_SDFGCONVERTIBLEINTERFACE_H
#define CONCRETELANG_DIALECT_SDFG_INTERFACES_SDFGCONVERTIBLEINTERFACE_H
#include "mlir/IR/ImplicitLocOpBuilder.h"
#include "concretelang/Dialect/SDFG/IR/SDFGOps.h"
#include "concretelang/Dialect/SDFG/Interfaces/SDFGConvertibleInterface.h.inc"
#endif

View File

@@ -0,0 +1,31 @@
#ifndef CONCRETELANG_DIALECT_SDFG_INTERFACES_SDFGCONVERTIBLEINTERFACE
#define CONCRETELANG_DIALECT_SDFG_INTERFACES_SDFGCONVERTIBLEINTERFACE
include "mlir/IR/OpBase.td"
def SDFG_SDFGConvertibleOpInterface : OpInterface<"SDFGConvertibleOpInterface"> {
let description = [{
Interface for operations processing a scalar that can be batched
if invoked multiple times with different, independent operands.
}];
let cppNamespace = "::mlir::concretelang::SDFG";
let methods = [
InterfaceMethod<[{
Create the associated operation and return it as a value.
}],
/*retTy=*/"::mlir::concretelang::SDFG::MakeProcess",
/*methodName=*/"convert",
/*args=*/(ins "::mlir::ImplicitLocOpBuilder&":$builder,
"::mlir::Value":$dfg,
"::mlir::ValueRange":$inStreams,
"::mlir::ValueRange":$outStreams),
/*methodBody=*/"",
/*defaultImplementation=*/[{
llvm_unreachable("convert not implemented");
}]
>
];
}
#endif // CONCRETELANG_DIALECT_SDFG_INTERFACES_SDFGCONVERTIBLEINTERFACE

View File

@@ -241,7 +241,7 @@ const LLVM_STATIC_LIBS: [&str; 51] = [
"LLVMX86Info",
];
const CONCRETE_COMPILER_LIBS: [&str; 30] = [
const CONCRETE_COMPILER_LIBS: [&str; 31] = [
"RTDialect",
"RTDialectTransforms",
"ConcretelangSupport",
@@ -255,6 +255,7 @@ const CONCRETE_COMPILER_LIBS: [&str; 30] = [
"TFHEGlobalParametrization",
"ConcretelangClientLib",
"ConcretelangBConcreteTransforms",
"ConcretelangSDFGInterfaces",
"CONCRETELANGCAPISupport",
"FHELinalgDialect",
"ConcretelangInterfaces",

View File

@@ -1 +1,2 @@
add_subdirectory(Interfaces)
add_subdirectory(IR)

View File

@@ -0,0 +1,14 @@
add_mlir_dialect_library(
ConcretelangSDFGInterfaces
SDFGConvertibleInterface.cpp
ADDITIONAL_HEADER_DIRS
${PROJECT_SOURCE_DIR}/include/concretelang/Dialect/SDFG
DEPENDS
mlir-headers
LINK_LIBS
PUBLIC
SDFGDialect
MLIRIR
MLIRMemRefDialect
MLIRPass
MLIRTransforms)

View File

@@ -0,0 +1,8 @@
// 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/Dialect/SDFG/Interfaces/SDFGConvertibleInterface.h"
#include "concretelang/Dialect/SDFG/Interfaces/SDFGConvertibleInterface.cpp.inc"

View File

@@ -27,6 +27,7 @@ add_mlir_library(
RTDialectAnalysis
ConcretelangTransforms
ConcretelangBConcreteTransforms
ConcretelangSDFGInterfaces
LinalgExtras
ConcreteDialectTransforms
concrete_optimizer