Skip to content

Commit 937917e

Browse files
committed
test remaining diagnostics
1 parent e9ac29d commit 937917e

File tree

2 files changed

+28
-2
lines changed

2 files changed

+28
-2
lines changed

mlir/lib/Dialect/Polynomial/IR/PolynomialOps.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,9 @@ LogicalResult ToTensorOp::verify() {
7979
InFlightDiagnostic diag =
8080
emitOpError() << "input type " << getInput().getType()
8181
<< " does not match output type " << getOutput().getType();
82-
diag.attachNote() << "he input type must be a tensor of shape [d] where d "
82+
diag.attachNote() << "the output type must be a tensor of shape [d] where d "
8383
"is at most the degree of the polynomialModulus of "
84-
"the output type's ring attribute";
84+
"the input type's ring attribute";
8585
return diag;
8686
}
8787

mlir/test/Dialect/Polynomial/ops_errors.mlir

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,32 @@ func.func @test_from_tensor_too_large_coeffs() {
1515

1616
// -----
1717

18+
#my_poly = #polynomial.polynomial<1 + x**4>
19+
#ring = #polynomial.ring<coefficientType=i32, coefficientModulus=256, polynomialModulus=#my_poly>
20+
!ty = !polynomial.polynomial<#ring>
21+
func.func @test_from_tensor_wrong_tensor_type() {
22+
%two = arith.constant 2 : i32
23+
%coeffs1 = tensor.from_elements %two, %two, %two, %two, %two : tensor<5xi32>
24+
// expected-error@below {{input type 'tensor<5xi32>' does not match output type 'polynomial.polynomial<#polynomial.ring<coefficientType=i32, coefficientModulus=256, polynomialModulus=#polynomial.polynomial<1 + x**4>>>'}}
25+
// expected-note@below {{at most the degree of the polynomialModulus of the output type's ring attribute}}
26+
%poly = polynomial.from_tensor %coeffs1 : tensor<2xi32> -> !ty
27+
return
28+
}
29+
30+
// -----
31+
32+
#my_poly = #polynomial.polynomial<1 + x**4>
33+
#ring = #polynomial.ring<coefficientType=i32, coefficientModulus=256, polynomialModulus=#my_poly>
34+
!ty = !polynomial.polynomial<#ring>
35+
func.func @test_to_tensor_wrong_output_tensor_type(%arg0 : !ty) {
36+
// expected-error@below {{input type 'polynomial.polynomial<#polynomial.ring<coefficientType=i32, coefficientModulus=256, polynomialModulus=#polynomial.polynomial<1 + x**4>>>' does not match output type 'tensor<5xi32>'}}
37+
// expected-note@below {{at most the degree of the polynomialModulus of the input type's ring attribute}}
38+
%tensor = polynomial.to_tensor %arg0 : !ty -> tensor<5xi32>
39+
return
40+
}
41+
42+
// -----
43+
1844
#my_poly = #polynomial.polynomial<1 + x**1024>
1945
#ring = #polynomial.ring<coefficientType=i16, coefficientModulus=256, polynomialModulus=#my_poly>
2046
!ty = !polynomial.polynomial<#ring>

0 commit comments

Comments
 (0)