Skip to content

Commit

Permalink
Repatriate polynomial dialect
Browse files Browse the repository at this point in the history
Due to some governance discussions in upstream MLIR [1], we decided it would be appropriate to move the polynomial dialect back into the HEIR tree. We also have some plans to make minor changes to the types, for instance changing the coefficient type to AnyType and removing the coefficient modulus to support things like RNS+modarith coefficient rings, and we felt it would be simpler to just make these changes in tree rather than burden the MLIR community and core maintainers with them. Cf. #1085

[1]: https://discourse.llvm.org/t/rfc-mlir-project-charter-and-restructuring/82896

PiperOrigin-RevId: 696112603
  • Loading branch information
j2kun authored and copybara-github committed Nov 13, 2024
1 parent 58862fb commit 5dac435
Show file tree
Hide file tree
Showing 52 changed files with 1,909 additions and 102 deletions.
3 changes: 0 additions & 3 deletions lib/Dialect/BGV/Conversions/BGVToLWE/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,8 @@ cc_library(
":pass_inc_gen",
"@heir//lib/Dialect/BGV/IR:Dialect",
"@heir//lib/Dialect/LWE/IR:Dialect",
"@heir//lib/Utils/ConversionUtils",
"@llvm-project//mlir:ArithDialect",
"@llvm-project//mlir:IR",
"@llvm-project//mlir:Pass",
"@llvm-project//mlir:PolynomialDialect",
"@llvm-project//mlir:Support",
"@llvm-project//mlir:TensorDialect",
"@llvm-project//mlir:TransformUtils",
Expand Down
2 changes: 1 addition & 1 deletion lib/Dialect/BGV/IR/BGVOps.td
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ include "mlir/Interfaces/InferTypeOpInterface.td"

include "lib/Dialect/LWE/IR/LWETypes.td"
include "lib/Dialect/LWE/IR/LWETraits.td"
include "mlir/Dialect/Polynomial/IR/PolynomialAttributes.td"
include "lib/Dialect/Polynomial/IR/PolynomialAttributes.td"
include "mlir/Interfaces/SideEffectInterfaces.td"

class BGV_Op<string mnemonic, list<Trait> traits = []> :
Expand Down
2 changes: 1 addition & 1 deletion lib/Dialect/BGV/IR/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,6 @@ gentbl_cc_library(
":dialect_inc_gen",
":td_files",
"@heir//lib/Dialect/LWE/IR:td_files",
"@llvm-project//mlir:PolynomialTdFiles",
"@heir//lib/Dialect/Polynomial/IR:td_files",
],
)
2 changes: 1 addition & 1 deletion lib/Dialect/CGGI/IR/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ gentbl_cc_library(
":td_files",
"@heir//lib/Dialect:td_files",
"@heir//lib/Dialect/LWE/IR:td_files",
"@llvm-project//mlir:PolynomialTdFiles",
"@heir//lib/Dialect/Polynomial/IR:td_files",
],
)

Expand Down
2 changes: 1 addition & 1 deletion lib/Dialect/CGGI/IR/CGGIOps.td
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ include "lib/Dialect/HEIRInterfaces.td"
include "lib/Dialect/CGGI/IR/CGGIDialect.td"
include "lib/Dialect/CGGI/IR/CGGIAttributes.td"

include "mlir/Dialect/Polynomial/IR/PolynomialAttributes.td"
include "lib/Dialect/Polynomial/IR/PolynomialAttributes.td"
include "lib/Dialect/LWE/IR/LWETypes.td"

include "mlir/IR/OpBase.td"
Expand Down
2 changes: 1 addition & 1 deletion lib/Dialect/CGGI/Transforms/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ cc_library(
":pass_inc_gen",
"@heir//lib/Dialect/CGGI/IR:Dialect",
"@heir//lib/Dialect/LWE/IR:Dialect",
"@heir//lib/Dialect/Polynomial/IR:Dialect",
"@llvm-project//llvm:Support",
"@llvm-project//mlir:IR",
"@llvm-project//mlir:Pass",
"@llvm-project//mlir:PolynomialDialect",
],
)

Expand Down
8 changes: 4 additions & 4 deletions lib/Dialect/CGGI/Transforms/SetDefaultParameters.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
#include "lib/Dialect/CGGI/IR/CGGIAttributes.h"
#include "lib/Dialect/CGGI/IR/CGGIOps.h"
#include "lib/Dialect/LWE/IR/LWEAttributes.h"
#include "llvm/include/llvm/ADT/TypeSwitch.h" // from @llvm-project
#include "llvm/include/llvm/Support/Debug.h" // from @llvm-project
#include "mlir/include/mlir/Dialect/Polynomial/IR/Polynomial.h" // from @llvm-project
#include "mlir/include/mlir/Dialect/Polynomial/IR/PolynomialAttributes.h" // from @llvm-project
#include "lib/Dialect/Polynomial/IR/Polynomial.h"
#include "lib/Dialect/Polynomial/IR/PolynomialAttributes.h"
#include "llvm/include/llvm/ADT/TypeSwitch.h" // from @llvm-project
#include "llvm/include/llvm/Support/Debug.h" // from @llvm-project
#include "mlir/include/mlir/IR/BuiltinAttributes.h" // from @llvm-project
#include "mlir/include/mlir/IR/BuiltinTypes.h" // from @llvm-project
#include "mlir/include/mlir/IR/Visitors.h" // from @llvm-project
Expand Down
2 changes: 1 addition & 1 deletion lib/Dialect/CKKS/IR/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,6 @@ gentbl_cc_library(
":dialect_inc_gen",
":td_files",
"@heir//lib/Dialect/LWE/IR:td_files",
"@llvm-project//mlir:PolynomialTdFiles",
"@heir//lib/Dialect/Polynomial/IR:td_files",
],
)
2 changes: 1 addition & 1 deletion lib/Dialect/CKKS/IR/CKKSOps.td
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ include "mlir/Interfaces/InferTypeOpInterface.td"

include "lib/Dialect/LWE/IR/LWETypes.td"
include "lib/Dialect/LWE/IR/LWETraits.td"
include "mlir/Dialect/Polynomial/IR/PolynomialAttributes.td"
include "lib/Dialect/Polynomial/IR/PolynomialAttributes.td"
include "mlir/Interfaces/SideEffectInterfaces.td"

class CKKS_Op<string mnemonic, list<Trait> traits = []> :
Expand Down
2 changes: 1 addition & 1 deletion lib/Dialect/LWE/Conversions/LWEToPolynomial/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ cc_library(
deps = [
":pass_inc_gen",
"@heir//lib/Dialect/LWE/IR:Dialect",
"@heir//lib/Dialect/Polynomial/IR:Dialect",
"@heir//lib/Dialect/Random/IR:Dialect",
"@heir//lib/Utils/ConversionUtils",
"@llvm-project//llvm:Support",
"@llvm-project//mlir:ArithDialect",
"@llvm-project//mlir:IR",
"@llvm-project//mlir:Pass",
"@llvm-project//mlir:PolynomialDialect",
"@llvm-project//mlir:Support",
"@llvm-project//mlir:TensorDialect",
"@llvm-project//mlir:TransformUtils",
Expand Down
16 changes: 8 additions & 8 deletions lib/Dialect/LWE/Conversions/LWEToPolynomial/LWEToPolynomial.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,19 @@
#include "lib/Dialect/LWE/IR/LWEAttributes.h"
#include "lib/Dialect/LWE/IR/LWEOps.h"
#include "lib/Dialect/LWE/IR/LWETypes.h"
#include "lib/Dialect/Polynomial/IR/Polynomial.h"
#include "lib/Dialect/Polynomial/IR/PolynomialAttributes.h"
#include "lib/Dialect/Polynomial/IR/PolynomialOps.h"
#include "lib/Dialect/Polynomial/IR/PolynomialTypes.h"
#include "lib/Dialect/Random/IR/RandomDialect.h"
#include "lib/Dialect/Random/IR/RandomEnums.h"
#include "lib/Dialect/Random/IR/RandomOps.h"
#include "lib/Dialect/Random/IR/RandomTypes.h"
#include "lib/Utils/ConversionUtils/ConversionUtils.h"
#include "llvm/include/llvm/ADT/ArrayRef.h" // from @llvm-project
#include "llvm/include/llvm/ADT/TypeSwitch.h" // from @llvm-project
#include "llvm/include/llvm/Support/ErrorHandling.h" // from @llvm-project
#include "mlir/include/mlir/Dialect/Arith/IR/Arith.h" // from @llvm-project
#include "mlir/include/mlir/Dialect/Polynomial/IR/Polynomial.h" // from @llvm-project
#include "mlir/include/mlir/Dialect/Polynomial/IR/PolynomialAttributes.h" // from @llvm-project
#include "mlir/include/mlir/Dialect/Polynomial/IR/PolynomialOps.h" // from @llvm-project
#include "mlir/include/mlir/Dialect/Polynomial/IR/PolynomialTypes.h" // from @llvm-project
#include "llvm/include/llvm/ADT/ArrayRef.h" // from @llvm-project
#include "llvm/include/llvm/ADT/TypeSwitch.h" // from @llvm-project
#include "llvm/include/llvm/Support/ErrorHandling.h" // from @llvm-project
#include "mlir/include/mlir/Dialect/Arith/IR/Arith.h" // from @llvm-project
#include "mlir/include/mlir/Dialect/Tensor/IR/Tensor.h" // from @llvm-project
#include "mlir/include/mlir/IR/BuiltinOps.h" // from @llvm-project
#include "mlir/include/mlir/IR/BuiltinTypes.h" // from @llvm-project
Expand Down
6 changes: 3 additions & 3 deletions lib/Dialect/LWE/IR/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ cc_library(
":dialect_inc_gen",
":ops_inc_gen",
":types_inc_gen",
"@heir//lib/Dialect/Polynomial/IR:Dialect",
"@llvm-project//llvm:Support",
"@llvm-project//mlir:IR",
"@llvm-project//mlir:InferTypeOpInterface",
"@llvm-project//mlir:PolynomialDialect",
"@llvm-project//mlir:Support",
],
)
Expand Down Expand Up @@ -159,7 +159,7 @@ gentbl_cc_library(
":attributes_inc_gen",
":dialect_inc_gen",
":td_files",
"@llvm-project//mlir:PolynomialTdFiles",
"@heir//lib/Dialect/Polynomial/IR:td_files",
],
)

Expand All @@ -185,6 +185,6 @@ gentbl_cc_library(
":dialect_inc_gen",
":td_files",
":types_inc_gen",
"@llvm-project//mlir:PolynomialTdFiles",
"@heir//lib/Dialect/Polynomial/IR:td_files",
],
)
2 changes: 1 addition & 1 deletion lib/Dialect/LWE/IR/LWEAttributes.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include "lib/Dialect/LWE/IR/LWEEnums.h.inc"
#include "mlir/include/mlir/IR/TensorEncoding.h" // from @llvm-project
// Required to pull in poly's Ring_Attr
#include "mlir/include/mlir/Dialect/Polynomial/IR/PolynomialAttributes.h" // from @llvm-project
#include "lib/Dialect/Polynomial/IR/PolynomialAttributes.h"
#define GET_ATTRDEF_CLASSES
#include "lib/Dialect/LWE/IR/LWEAttributes.h.inc"

Expand Down
12 changes: 6 additions & 6 deletions lib/Dialect/LWE/IR/LWEDialect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
#include "lib/Dialect/LWE/IR/LWEAttributes.h"
#include "lib/Dialect/LWE/IR/LWEOps.h"
#include "lib/Dialect/LWE/IR/LWETypes.h"
#include "llvm/include/llvm/ADT/STLFunctionalExtras.h" // from @llvm-project
#include "llvm/include/llvm/ADT/TypeSwitch.h" // from @llvm-project
#include "llvm/include/llvm/Support/Casting.h" // from @llvm-project
#include "llvm/include/llvm/Support/ErrorHandling.h" // from @llvm-project
#include "mlir/include/mlir/Dialect/Polynomial/IR/PolynomialAttributes.h" // from @llvm-project
#include "mlir/include/mlir/Dialect/Polynomial/IR/PolynomialTypes.h" // from @llvm-project
#include "lib/Dialect/Polynomial/IR/PolynomialAttributes.h"
#include "lib/Dialect/Polynomial/IR/PolynomialTypes.h"
#include "llvm/include/llvm/ADT/STLFunctionalExtras.h" // from @llvm-project
#include "llvm/include/llvm/ADT/TypeSwitch.h" // from @llvm-project
#include "llvm/include/llvm/Support/Casting.h" // from @llvm-project
#include "llvm/include/llvm/Support/ErrorHandling.h" // from @llvm-project
#include "mlir/include/mlir/IR/Diagnostics.h" // from @llvm-project
#include "mlir/include/mlir/IR/DialectImplementation.h" // from @llvm-project

Expand Down
2 changes: 1 addition & 1 deletion lib/Dialect/LWE/IR/LWEOps.td
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
include "lib/Dialect/LWE/IR/LWEDialect.td"
include "lib/Dialect/LWE/IR/LWETraits.td"
include "lib/Dialect/LWE/IR/LWETypes.td"
include "mlir/Dialect/Polynomial/IR/PolynomialAttributes.td"
include "lib/Dialect/Polynomial/IR/PolynomialAttributes.td"

include "mlir/IR/BuiltinAttributeInterfaces.td"
include "mlir/Interfaces/InferTypeOpInterface.td"
Expand Down
2 changes: 1 addition & 1 deletion lib/Dialect/LWE/IR/LWETraits.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#define LIB_DIALECT_LWE_IR_LWETRAITS_H_

#include "lib/Dialect/LWE/IR/LWETypes.h"
#include "mlir/include/mlir/Dialect/Polynomial/IR/PolynomialAttributes.h" // from @llvm-project
#include "lib/Dialect/Polynomial/IR/PolynomialAttributes.h"
#include "mlir/include/mlir/IR/OpDefinition.h" // from @llvm-project
#include "mlir/include/mlir/IR/Operation.h" // from @llvm-project
#include "mlir/include/mlir/Support/LLVM.h" // from @llvm-project
Expand Down
2 changes: 1 addition & 1 deletion lib/Dialect/ModArith/IR/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,6 @@ gentbl_cc_library(
deps = [
":dialect_inc_gen",
":td_files",
"@llvm-project//mlir:PolynomialTdFiles",
"@heir//lib/Dialect/Polynomial/IR:td_files",
],
)
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ cc_library(
],
deps = [
":pass_inc_gen",
"@heir//lib/Dialect/Polynomial/IR:Dialect",
"@heir//lib/Utils/ConversionUtils",
"@llvm-project//llvm:Support",
"@llvm-project//mlir:AffineDialect",
Expand All @@ -24,7 +25,6 @@ cc_library(
"@llvm-project//mlir:LLVMDialect",
"@llvm-project//mlir:LinalgDialect",
"@llvm-project//mlir:Pass",
"@llvm-project//mlir:PolynomialDialect",
"@llvm-project//mlir:SCFDialect",
"@llvm-project//mlir:Support",
"@llvm-project//mlir:TensorDialect",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@
#include <utility>
#include <vector>

#include "lib/Dialect/Polynomial/IR/Polynomial.h"
#include "lib/Dialect/Polynomial/IR/PolynomialAttributes.h"
#include "lib/Dialect/Polynomial/IR/PolynomialDialect.h"
#include "lib/Dialect/Polynomial/IR/PolynomialOps.h"
#include "lib/Dialect/Polynomial/IR/PolynomialTypes.h"
#include "lib/Utils/ConversionUtils/ConversionUtils.h"
#include "llvm/include/llvm/Support/Casting.h" // from @llvm-project
#include "llvm/include/llvm/Support/Debug.h" // from @llvm-project
Expand All @@ -20,13 +25,8 @@
#include "mlir/include/mlir/Dialect/LLVMIR/LLVMAttrs.h" // from @llvm-project
#include "mlir/include/mlir/Dialect/LLVMIR/LLVMDialect.h" // from @llvm-project
#include "mlir/include/mlir/Dialect/Linalg/IR/Linalg.h" // from @llvm-project
#include "mlir/include/mlir/Dialect/Polynomial/IR/Polynomial.h" // from @llvm-project
#include "mlir/include/mlir/Dialect/Polynomial/IR/PolynomialAttributes.h" // from @llvm-project
#include "mlir/include/mlir/Dialect/Polynomial/IR/PolynomialDialect.h" // from @llvm-project
#include "mlir/include/mlir/Dialect/Polynomial/IR/PolynomialOps.h" // from @llvm-project
#include "mlir/include/mlir/Dialect/Polynomial/IR/PolynomialTypes.h" // from @llvm-project
#include "mlir/include/mlir/Dialect/SCF/IR/SCF.h" // from @llvm-project
#include "mlir/include/mlir/Dialect/Tensor/IR/Tensor.h" // from @llvm-project
#include "mlir/include/mlir/Dialect/SCF/IR/SCF.h" // from @llvm-project
#include "mlir/include/mlir/Dialect/Tensor/IR/Tensor.h" // from @llvm-project
#include "mlir/include/mlir/Dialect/Utils/StructuredOpsUtils.h" // from @llvm-project
#include "mlir/include/mlir/IR/AffineExpr.h" // from @llvm-project
#include "mlir/include/mlir/IR/AffineMap.h" // from @llvm-project
Expand Down
Loading

0 comments on commit 5dac435

Please sign in to comment.