[PATCH] D80842: [mlir] Add verify method to adaptor

Jacques Pienaar via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri May 29 14:48:50 PDT 2020


jpienaar created this revision.
jpienaar added reviewers: rriddle, mehdi_amini.
Herald added a reviewer: mravishankar.
Herald added subscribers: llvm-commits, jurahul, Kayjukh, frgossen, grosul1, bader, Joonsoo, stephenneuendorffer, liufengdb, aartbik, lucyrfox, mgester, arpith-jacob, csigg, nicolasvasilache, antiagainst, shauheen.
Herald added a reviewer: antiagainst.
Herald added a reviewer: nicolasvasilache.
Herald added a reviewer: herhut.
Herald added a reviewer: aartbik.
Herald added a reviewer: ftynse.
Herald added a project: LLVM.

This allows verifying op-indepent attributes (e.g., attributes that do not require the op to have been created) before constructing an operation. These include checking whether required attributes are defined or constraints on attributes (such as I32 attribute). This is not perfect (e.g., if one had a disjunctive constraint where one part relied on the op and the other doesn't, then this would not try and extract the op independent from the op dependent).

The next step is to move these out to a trait that could be verified earlier than in the generated method. The first use case is for inferring the return type while constructing the op. At that point you don't have an Operation yet and that ends up in one having to duplicate the same checks, e.g., verify that attribute A is defined before querying A in shape function which requires that duplication. Instead this allows one to invoke a method to verify all the traits and, if this is checked first during verification, then all other traits could use attributes knowing they have been verified.

It is a little bit funny to have these on the adaptor, but I see the adaptor as a place to collect information about the op before the op is constructed (e.g., avoiding stringly typed accessors, verifying what is possible to verify before the op is constructed) while being cheap to use even with constructed op (so layer of indirection between the op constructed/being constructed). And from that point of view it made sense to me.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D80842

Files:
  mlir/test/Dialect/GPU/invalid.mlir
  mlir/test/Dialect/LLVMIR/global.mlir
  mlir/test/Dialect/SPIRV/composite-ops.mlir
  mlir/test/Dialect/Vector/invalid.mlir
  mlir/test/IR/invalid-ops.mlir
  mlir/test/mlir-tblgen/op-attribute.td
  mlir/test/mlir-tblgen/predicate.td
  mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D80842.267376.patch
Type: text/x-patch
Size: 23564 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200529/83e73e47/attachment.bin>


More information about the llvm-commits mailing list