google / google/heir

poly: add poly.constant folding and materialization

Open
#97 13 comments 0 reactions 0 assignees View on GitHub
dialect: polynomial
Dominant language
MLIR
Stars
906
Forks
171
Avg merge
4d 12h
Merged PRs (30d)
32

Description

From https://github.com/google/heir/pull/94#issuecomment-1679029556

> we should add a poly.constant op to directly convert a #poly.polynomial to a !poly.poly without the need to go via tensors

The idea is to have an op that is analogous to `arith.constant`, which, by the use of an array attribute, can populate a tensor of constants, not just a single value, as in

```
%coeffs1 = "arith.constant"() <{value = dense<[2, 2, 5]> : tensor<3xi32>}> : () -> tensor<3xi32>
```

We could have something similar like

```
#cycl_2048 = #poly.polynomial<1 + x**1024>
#ring = #poly.ring
%poly1 = "poly.constant"() <{coefficients = dense<[2, 2, 5]> : tensor<3xi32>}> : !poly.poly<#ring> : () -> !poly.poly<#ring>
```

The attributes are already implemented, and so we would just need the op and lowerings.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.