Commit Graph

1632 Commits

Author SHA1 Message Date
Chris Lattner 9ec6b5b749 Remove some extraneous const qualifiers on Type, and 0b1 -> 1 in tblgen files. (NFC)
--

PiperOrigin-RevId: 248332674
2019-05-20 13:42:56 -07:00
Nicolas Vasilache a0514338b8 Make Linalg tiling a FunctionPass instead of a ModulePass - NFC
--

PiperOrigin-RevId: 248286354
2019-05-20 13:42:47 -07:00
River Riddle 636b7f6f54 Add a new document detailing the diagnostics infrastructure.
--

PiperOrigin-RevId: 248275851
2019-05-20 13:42:38 -07:00
Stella Laurenzo d4d8dc8db9 Start to introduce the "Quantizer" tool, which is responsible for transforming a computation expressed in floating point to one operating in terms of quantized types (where possible), either using quant-aware-training hints where available or post-training statistics.
This is being integrated from an experimental side repository piece by piece over the course of several patches and will ultimately include full build support, documentation and e2e tests.

--

PiperOrigin-RevId: 248259895
2019-05-20 13:42:30 -07:00
Nicolas Vasilache fa01679e7c Add support for a Linalg base op class
This CL uses a pattern proposed by aminim@ to add a base Linalg op that further dispatches to the proper op implementation.
    This CL adds a LinalgOp which implements isclassof for only a subset of the linalg ops: the ops that behave like a library call for the purpose of transformations like tiling.
    This uses a static dispatch mechanism based on the LinalgLibraryOps.td ops declarations to avoid switch or visitor patterns. This may later be replaced by Tablegen'd dispatch when it is available.

    As a consequence, the list of library like operations in Linalg may now grow without having to modify any of the dispatch or transformation support.

    More details in the concept-based dispatch, as explained by aminim@
    ```
    This is inspired by Sean Parent's: https://sean-parent.stlab.cc/papers-and-presentations/#value-semantics-and-concept-based-polymorphism

    A key difference is that the set of classes erased is statically known, which avoids to use dynamic memory allocation.
    We use a zero-sized templated class to emit the virtual table and generate a singleton object for each instantiation of this class. We pay the cost of initialization once on construction (find which class to dispatch to) and then a virtual dispatch on every call.
    ```

--

PiperOrigin-RevId: 248258921
2019-05-20 13:42:21 -07:00
Jacques Pienaar cde4d5a6d9 Remove unnecessary C++ specifier in CPP files. NFC.
These are only required in .h files to disambiguate between C and C++ header files.

--

PiperOrigin-RevId: 248219135
2019-05-20 13:42:13 -07:00
Nicolas Vasilache 8eb32a9051 Add an AffineExpr matcher
This CL gives a pattern-matching-y look and feel to AffineExpr.
    For now this uses a shared_ptr instead of unique'ing into a bumpPtrAllocator.
    SDBM gives a simple use case with more idiomatic syntax for matchers.

--

PiperOrigin-RevId: 248188075
2019-05-20 13:42:04 -07:00
Stella Laurenzo d4dcf7de9e Move Quantization -> Dialect/QuantOps, FxpMathOps -> Dialect/FxpMathOps.
Adding the additional layer of directory was discussed offline and matches the Target/ tree. The names match the defacto convention we seem to be following where the C++ namespace is ^(.+)Ops/$ matched against the directory name.

    This is in preparation for patching the Quantizer into this tree, which would have been confusing without moving the Quantization dialect to its more proper home. It is left to others to move other dialects if desired.

    Tested:
      ninja check-mlir

--

PiperOrigin-RevId: 248171982
2019-05-20 13:41:55 -07:00
River Riddle 6264fccd3a When converting a location to an SMLoc, advance to the first non-whitespace if the column is unknown(zero). This also fixes a small bug with call stack printing.
Example:
    /tmp/file_C.py:21:5: error: 'foo.bar' op attribute 'something'
        raise app.UsageError('Too many command-line arguments.')
        ^
    /tmp/file_D.py:20:3: note: called from
      if len(argv) > 1:
      ^
    /tmp/file_E.py:19:1: note: called from
    def main(argv):
    ^
    /tmp/file_F.py:24:3: note: called from
      app.run(main)
      ^

--

PiperOrigin-RevId: 248151212
2019-05-20 13:41:46 -07:00
Lei Zhang ed47f59c2f [ODS] Add definition for TypeAttr
--

PiperOrigin-RevId: 248147938
2019-05-20 13:41:38 -07:00
Jacques Pienaar c6c989f179 Move specification of print, parse and verify to Std_Op base.
Removes some boilerplate in ops, add support to refer to C++ class name from parser function specification in ODS.

--

PiperOrigin-RevId: 248140977
2019-05-20 13:41:29 -07:00
River Riddle 30356de1db Add initial support to the SourceMgrDiagnosticHandler for printing call stacks.
Example:

    /tmp/file_C.py:17:1: error: 'foo.bar' op attribute 'something' ...
      app.run(main)
    ^
    /tmp/file_D.py:14:1: note: called from
        raise app.UsageError('Too many command-line arguments.')
    ^
    /tmp/file_E.py:12:1: note: called from
    def main(argv):
    ^
    /tmp/file_F.py:13:1: note: called from
      if len(argv) > 1:
    ^

--

PiperOrigin-RevId: 248074804
2019-05-20 13:41:20 -07:00
Stella Laurenzo 1a2ad06bae Fix lingering sign compare warnings in exposed by "ninja check-mlir".
--

PiperOrigin-RevId: 248050178
2019-05-20 13:41:11 -07:00
Nicolas Vasilache cf3959f49d Add a linalg.dim
A linalg.dim operation is used to extract size information from !linalg.view objects passed
    through function call boundaries.

--

PiperOrigin-RevId: 248017488
2019-05-20 13:41:02 -07:00
River Riddle cad382406f Refactor NameLoc so that it also holds a child location. This removes the awkward use of CallSiteLoc as a variable usage location.
--

PiperOrigin-RevId: 248014642
2019-05-20 13:40:52 -07:00
Lei Zhang 635bebaac9 Update "Table-driven Op Definition Specification" doc
This CL turns the previous "Op Definition" doc into a manual for table-driven
    op definition specification by fleshing out more details of existing mechanisms.

--

PiperOrigin-RevId: 248013274
2019-05-20 13:40:43 -07:00
Jacques Pienaar 3427d87719 Fix -Wsign-compare in Toy LateLowering.
--

PiperOrigin-RevId: 248005642
2019-05-20 13:40:33 -07:00
Jacques Pienaar c82e1da268 Remove unused function and avoid unused variable warning. NFC.
--

PiperOrigin-RevId: 247991231
2019-05-20 13:40:23 -07:00
River Riddle bc5c7378b2 Add a utility method to MLIRContext get a registered dialect with the derived type instead of the string name. The derived dialect type must provide a static 'getDialectNamespace' method.
This means that we can now do something like:
      ctx->getRegisteredDialect<LLVMDialect>();

    as opposed to:
      static_cast<LLVMDialect *>(ctx->getRegisteredDialect("llvm");

--

PiperOrigin-RevId: 247989896
2019-05-20 13:40:13 -07:00
River Riddle d39a30626e Use the DialectSymbolRegistry to reserve space in the Attribute::Kind enum to allow for dialects to define attribute kinds. The currently defined attributes kinds have now been moved to StandardAttributes.
--

PiperOrigin-RevId: 247988373
2019-05-20 13:40:03 -07:00
River Riddle 5d7546470d Move MemRefCastOp and TensorCastOp to the Op Definition Generation framework.
--

PiperOrigin-RevId: 247981385
2019-05-20 13:39:53 -07:00
River Riddle 17cc065da0 Move the definition of Return op to the Op Definition Generation framework.
--

PiperOrigin-RevId: 247980849
2019-05-20 13:39:43 -07:00
River Riddle e18a55f142 NFC: Cleanup the definitions of the Location classes.
--

PiperOrigin-RevId: 247979132
2019-05-20 13:39:32 -07:00
River Riddle bc30a01b62 Change a few errors emitted by the parser to be notes instead.
--

PiperOrigin-RevId: 247978922
2019-05-20 13:39:23 -07:00
Andy Davis 59100a0177 Move Affine Expressions and Affine Structures documentation from LangRef to Affine Dialect doc.
--

PiperOrigin-RevId: 247971222
2019-05-20 13:39:13 -07:00
Nicolas Vasilache 5c64d2a6c4 Pipe Linalg to a cblas call via mlir-cpu-runner
This CL extends the execution engine to allow the additional resolution of symbols names
    that have been registered explicitly. This allows linking static library symbols that have not been explicitly exported with the -rdynamic linking flag (which is deemed too intrusive).

--

PiperOrigin-RevId: 247969504
2019-05-20 13:39:02 -07:00
Tamas Berghammer 9cc5747a7b Add test for affine-loop-tile pass with a loop of trip count 1
--

PiperOrigin-RevId: 247950156
2019-05-20 13:38:52 -07:00
Jacques Pienaar 2d20cbd1fd Update cmakelist to reflect renamed filename.
--

PiperOrigin-RevId: 247946677
2019-05-20 13:38:42 -07:00
River Riddle 6a6cb40f23 Refactor the includes of Function.h now that the dependency on Operation has been removed. The dependency was on the op casting methods, which have now moved out of Operation, used by the walker.
--

PiperOrigin-RevId: 247944666
2019-05-20 13:38:32 -07:00
Alex Zinenko 3d62ef8018 Update region documentation
Restructure the Regions section in LangRef to avoid having a wall of text and
    reflect a recent evolution of the design.  Unspecify region types, that are put
    on hold until use cases arise.

    Update the Rationale doc with a list of design decisions related to regions.
    Separately list the design alternatives that were considered and discarded due
    to the lack of existing use cases.

--

PiperOrigin-RevId: 247943144
2019-05-20 13:38:22 -07:00
Andy Davis 90d4023c9b Factor out loop interchange code from LoopFusion into LoopUtils (NFC).
--

PiperOrigin-RevId: 247926512
2019-05-20 13:38:12 -07:00
River Riddle d7c467ded1 Remove the explicit "friend Operation" statement from each of the derived operations now that op casting is no longer inside of Operation.
--

PiperOrigin-RevId: 247791672
2019-05-20 13:38:02 -07:00
River Riddle d5b60ee840 Replace Operation::isa with llvm::isa.
--

PiperOrigin-RevId: 247789235
2019-05-20 13:37:52 -07:00
River Riddle adca3c2edc Replace Operation::cast with llvm::cast.
--

PiperOrigin-RevId: 247785983
2019-05-20 13:37:42 -07:00
River Riddle c5ecf9910a Add support for using llvm::dyn_cast/cast/isa for operation casts and replace usages of Operation::dyn_cast with llvm::dyn_cast.
--

PiperOrigin-RevId: 247780086
2019-05-20 13:37:31 -07:00
MLIR Team 41d90a85bd Automated rollback of changelist 247778391.
PiperOrigin-RevId: 247778691
2019-05-20 13:37:20 -07:00
River Riddle 02e03b9bf4 Add support for using llvm::dyn_cast/cast/isa for operation casts and replace usages of Operation::dyn_cast with llvm::dyn_cast.
--

PiperOrigin-RevId: 247778391
2019-05-20 13:37:10 -07:00
River Riddle 360f8a209e Rename Op::isClassFor to Op::classof to match the LLVM isa/dyn_cast standard naming scheme.
--

PiperOrigin-RevId: 247771192
2019-05-20 13:36:59 -07:00
River Riddle e686a11523 Remove several heavy includes from Diagnostics.h by a moving a couple of fields/methods to the .cpp file.
--

PiperOrigin-RevId: 247768443
2019-05-20 13:36:48 -07:00
Chris Lattner 81e478adca rename -memref-dependence-check to -test-memref-dependence-check since it
generates remarks for testing, it isn't itself a transformation.

    While there, upgrade its diagnostic emission to use the streaming interface.

    Prune some unnecessary #includes.

--

PiperOrigin-RevId: 247768062
2019-05-20 13:36:38 -07:00
River Riddle fe7b23792d Remove some unnecessary or duplicated header includes from IR/.
--

PiperOrigin-RevId: 247762545
2019-05-20 13:36:28 -07:00
Chris Lattner 0134b5df3a Cleanups and simplifications to code, noticed by inspection. NFC.
--

PiperOrigin-RevId: 247758075
2019-05-20 13:36:17 -07:00
Mehdi Amini ecd4c7d67a Revert "Pass for outlining gpu.launch operation bodies into kernel functions called by gpu.launch_func operations"
OSS build was broken (missing CMakeLists.txt changes and compilation failures on Ubuntu)

Automated rollback of changelist 247564213.

PiperOrigin-RevId: 247713812
2019-05-10 21:26:30 -07:00
River Riddle 85bf79851e Change the diagnostic handler to accept Diagnostic instead of location/message/kind. This opens the door for many more powerful use cases: fixits, colors, etc.
--

PiperOrigin-RevId: 247705673
2019-05-10 19:30:56 -07:00
Lei Zhang df5000fd31 [TableGen] Return base attribute's name for anonymous OptionalAttr/DefaultValuedAttr
--

PiperOrigin-RevId: 247693280
2019-05-10 19:30:48 -07:00
River Riddle 4a6264f5c5 Move the definitions for CallOp and IndirectCallOp to the Op Definition Generator.
--

PiperOrigin-RevId: 247686419
2019-05-10 19:30:40 -07:00
River Riddle 77c333ca62 Move the definitions of BranchOp, DimOp, and ExtractElementOp to Op Definition Generator.
--

PiperOrigin-RevId: 247686212
2019-05-10 19:30:31 -07:00
River Riddle 53a3483cc8 Ensure that all attributes are registered with a dialect. This is one of the final steps towards allowing dialects to define their own attributes, but there are still several things missing before this is fully supported(e.g. parsing/printing ).
--

PiperOrigin-RevId: 247684322
2019-05-10 19:30:23 -07:00
River Riddle aa99db1809 Add support to the SourceMgrDiagnosticHandlers to auto-load new source files seen in diagnostics.
--

PiperOrigin-RevId: 247681779
2019-05-10 19:30:15 -07:00
Mehdi Amini ff5d021c39 Add llvm_unreachable in unreachable path to silence GCC warning (NFC)
The switch is supposed to be fully covered, but GCC warns that:
     "control reaches end of non-void function"

--

PiperOrigin-RevId: 247672430
2019-05-10 19:30:06 -07:00