Skip to content

Commit

Permalink
add poly.to_tensor op
Browse files Browse the repository at this point in the history
  • Loading branch information
j2kun committed Oct 19, 2023
1 parent 8eea0d1 commit aa076f5
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
7 changes: 7 additions & 0 deletions lib/Dialect/Poly/PolyOps.td
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,13 @@ def Poly_FromTensorOp : Op<Poly_Dialect, "from_tensor", [Pure]> {
let hasFolder = 1;
}

def Poly_ToTensorOp : Op<Poly_Dialect, "to_tensor", [Pure]> {
let summary = "Converts a polynomial to a tensor of its integer coefficients.";
let arguments = (ins Polynomial:$input);
let results = (outs TensorOf<[AnyInteger]>:$output);
let assemblyFormat = "$input attr-dict `:` qualified(type($input)) `->` type($output)";
}

def IntOrComplex : AnyTypeOf<[AnyInteger, AnyComplex]>;

def Poly_EvalOp : Op<Poly_Dialect, "eval", [AllTypesMatch<["point", "output"]>, Has32BitArguments]> {
Expand Down
3 changes: 3 additions & 0 deletions tests/poly_syntax.mlir
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ module {
%12 = poly.constant dense<"0x020304"> : tensor<3xi8> : !poly.poly<10>
%13 = poly.constant dense<4> : tensor<100xi32> : !poly.poly<10>

// CHECK: poly.to_tensor
%14 = poly.to_tensor %1 : !poly.poly<10> -> tensor<10xi32>

return %4 : !poly.poly<10>
}
}

0 comments on commit aa076f5

Please sign in to comment.