This is an archive of the discontinued LLVM Phabricator instance.

[mlir][vector] add proper verification to vector.print operation
ClosedPublic

Authored by aartbik on Feb 6 2023, 10:39 AM.

Details

Summary

Rationale:
Only proper vectors and scalars of floating-point or integral types
are actually lowered to calls into the light-weight output library.

Diff Detail

Event Timeline

aartbik created this revision.Feb 6 2023, 10:39 AM
aartbik requested review of this revision.Feb 6 2023, 10:39 AM
ThomasRaoux added inline comments.Feb 6 2023, 10:48 AM
mlir/lib/Dialect/Vector/IR/VectorOps.cpp
5194–5206 ↗(On Diff #495213)

I hate to be that guy but that could be done at the tablegen level by making the input type a VectorOf<[...?

aartbik added inline comments.Feb 6 2023, 10:53 AM
mlir/lib/Dialect/Vector/IR/VectorOps.cpp
5194–5206 ↗(On Diff #495213)

Is there an easy way to say

VectorOf or ScalarOf

?

ThomasRaoux added inline comments.Feb 6 2023, 10:58 AM
mlir/lib/Dialect/Vector/IR/VectorOps.cpp
5194–5206 ↗(On Diff #495213)
mlir/include/mlir/Dialect/Vector/IR/VectorOps.td
2443–2447

This should be AnyVectorOf Or Scalar type of thing ?

mlir/lib/Dialect/Vector/IR/VectorOps.cpp
5194–5206 ↗(On Diff #495213)

ah sorry for parroting .. +1 to adding to Tablegen .. here's a potential way

Try Or<[AnyVector.predicate, AnySignlessIntegerOrIndex.predicate, AnyFloat.predicate]> ?

We should have a proper:

def AnyScalar : Or<AnySignlessIntegerOrIndex.predicate, AnyFloat.predicate, AnyComplex.predicate>;
5194–5206 ↗(On Diff #495213)

Note that AnyVectorOfAnyRank is the proper thing to use until all ops support 0-D vectors..

aartbik updated this revision to Diff 495255.Feb 6 2023, 12:48 PM

C++ verification -> declarative verification

Replaced C++ verification with declarative verification. Note that the C++ version was perhaps slightly more precise but we can refine the declarative part as we get better traits.
This at least moves my code away from the now obsoleted C++ way of checking stuff.

PTAL

ThomasRaoux accepted this revision.Feb 6 2023, 1:54 PM
This revision is now accepted and ready to land.Feb 6 2023, 1:54 PM
This revision was landed with ongoing or failed builds.Feb 6 2023, 2:10 PM
This revision was automatically updated to reflect the committed changes.