[all-commits] [llvm/llvm-project] b0921f: [mlir] Add verify method to adaptor

Jacques Pienaar via All-commits all-commits at lists.llvm.org
Fri Jun 5 09:48:09 PDT 2020


  Branch: refs/heads/master
  Home:   https://github.com/llvm/llvm-project
  Commit: b0921f68e1eeb3ac0cf4e178014237e14c20be03
      https://github.com/llvm/llvm-project/commit/b0921f68e1eeb3ac0cf4e178014237e14c20be03
  Author: Jacques Pienaar <jpienaar at google.com>
  Date:   2020-06-05 (Fri, 05 Jun 2020)

  Changed paths:
    M mlir/docs/OpDefinitions.md
    M mlir/test/Dialect/GPU/invalid.mlir
    M mlir/test/Dialect/LLVMIR/global.mlir
    M mlir/test/Dialect/SPIRV/composite-ops.mlir
    M mlir/test/Dialect/Vector/invalid.mlir
    M mlir/test/IR/invalid-ops.mlir
    M mlir/test/mlir-tblgen/op-attribute.td
    M mlir/test/mlir-tblgen/predicate.td
    M mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp

  Log Message:
  -----------
  [mlir] Add verify method to adaptor

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.

Differential Revision: https://reviews.llvm.org/D80842




More information about the All-commits mailing list