-
Notifications
You must be signed in to change notification settings - Fork 77
--polynomial-to-mod-arith
segfault
#1812
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
The following simpler IR fails with the same error (as does replacing #ring_i256 = #polynomial.ring<coefficientType = i256>
!poly = !polynomial.polynomial<ring = #ring_i256>
module {
func.func @constraints() -> !poly {
%c2 = arith.constant 2 : index
%c256_i256 = arith.constant 256 : i256
%0 = polynomial.monomial %c256_i256, %c2 : (i256, index) -> !poly
return %0 : !poly
}
} Taking a look. |
Ah, this is an artifact of our particular use case for the polynomial dialect, where all polynomials have a ring modulus. This allows us to lower polynomials to tensors of the same dimension (upper bounded by the degree of the ring modulus). The type converter in the offending pass does: auto degree = type.getRing().getPolynomialModulus().getPolynomial().getDegree();
return RankedTensorType::get({degree}, attr.getCoefficientType()) Changing your type to have a modulus (i.e., imposing an explicit degree upper bound, below I used 256) fixes the issue: #mod = #polynomial.int_polynomial<-1 + x**256>
#ring_i256 = #polynomial.ring<coefficientType = i256, polynomialModulus=#mod>
!poly = !polynomial.polynomial<ring = #ring_i256> Which transforms #mod = #polynomial.int_polynomial<-1 + x**256>
#ring_i256 = #polynomial.ring<coefficientType = i256, polynomialModulus=#mod>
!poly = !polynomial.polynomial<ring = #ring_i256>
module {
func.func @constraints() -> !poly {
%c2 = arith.constant 2 : index
%c256_i256 = arith.constant 256 : i256
%0 = polynomial.monomial %c256_i256, %c2 : (i256, index) -> !poly
return %0 : !poly
}
} to module {
func.func @constraints() -> tensor<256xi256> {
%c2 = arith.constant 2 : index
%c256_i256 = arith.constant 256 : i256
%cst = arith.constant dense<0> : tensor<256xi256>
%inserted = tensor.insert %c256_i256 into %cst[%c2] : tensor<256xi256>
return %inserted : tensor<256xi256>
}
} |
I put a better error message in #1813, which I would say is enough to close this issue. But I am curious about your use case. Are you interested in using the polynomial dialect independently of the rest of the HEIR pipelines, and if so, for what? |
is the offending file.
is the offending invocation.
The error is:
The text was updated successfully, but these errors were encountered: