platform/upstream/llvm.git
5 years ago Remove checks guaranteed to be true by the type
Lei Zhang [Wed, 10 Apr 2019 15:00:34 +0000 (08:00 -0700)]
Remove checks guaranteed to be true by the type

    This addresses the compiler wraning of "comparison of unsigned expression
    >= 0 is always true [-Wtype-limits]".

--

PiperOrigin-RevId: 242868703

5 years ago Add parentheses in various asserts to group predicates
Lei Zhang [Wed, 10 Apr 2019 15:00:20 +0000 (08:00 -0700)]
Add parentheses in various asserts to group predicates

    This addresses the "suggest parentheses around ‘&&’ within ‘||’
    [-Wparentheses]" compiler warnings.

--

PiperOrigin-RevId: 242868670

5 years ago Use hexadecimal constants instead of binary constants
Lei Zhang [Wed, 10 Apr 2019 15:00:05 +0000 (08:00 -0700)]
Use hexadecimal constants instead of binary constants

    This addresses the "binary constants are a C++14 feature or GCC
    extension" compiler warnings.

--

PiperOrigin-RevId: 242868639

5 years ago Add conversion of StandardOps and, or and xor to LLVM dialect.
Stephan Herhut [Wed, 10 Apr 2019 09:27:30 +0000 (02:27 -0700)]
Add conversion of StandardOps and, or and xor to LLVM dialect.

--

PiperOrigin-RevId: 242831203

5 years ago Factor code to compute dependence components out of loop fusion pass, and into...
Andy Davis [Tue, 9 Apr 2019 19:21:28 +0000 (12:21 -0700)]
Factor code to compute dependence components out of loop fusion pass, and into a reusable utility function (NFC).

--

PiperOrigin-RevId: 242716259

5 years ago Fix typos in LoopFusion
Amit Sabne [Tue, 9 Apr 2019 16:17:40 +0000 (09:17 -0700)]
Fix typos in LoopFusion

--

PiperOrigin-RevId: 242679298

5 years ago Start a Linalg doc
Nicolas Vasilache [Tue, 9 Apr 2019 08:24:35 +0000 (01:24 -0700)]
Start a Linalg doc

--

PiperOrigin-RevId: 242622278

5 years ago Expose `setupTargetTriple` as a public static method on ExecutionEngine
Mehdi Amini [Tue, 9 Apr 2019 07:19:40 +0000 (00:19 -0700)]
Expose `setupTargetTriple` as a public static method on ExecutionEngine

    This allows client to be able to reuse the same logic to setup a module
    for the ExecutionEngine without instanciating one. One use case is running
    the optimization pipeline but not JIT-ing.

--

PiperOrigin-RevId: 242614380

5 years ago Fix Toy cmake build: add missing includes
Mehdi Amini [Tue, 9 Apr 2019 06:24:25 +0000 (23:24 -0700)]
Fix Toy cmake build: add missing includes

--

PiperOrigin-RevId: 242609231

5 years ago Toy tutorial Chapter 5: Lowering to Linalg and LLVM
Mehdi Amini [Tue, 9 Apr 2019 06:00:49 +0000 (23:00 -0700)]
Toy tutorial Chapter 5: Lowering to Linalg and LLVM

--

PiperOrigin-RevId: 242606796

5 years ago Automated rollback of changelist 242546977.
Mehdi Amini [Tue, 9 Apr 2019 05:37:37 +0000 (22:37 -0700)]
Automated rollback of changelist 242546977.

PiperOrigin-RevId: 242604949

5 years ago Use c++14 for building with CMake
Mehdi Amini [Tue, 9 Apr 2019 02:21:06 +0000 (19:21 -0700)]
Use c++14 for building with CMake

    This is getting rid of some warnings, and C++14 is supposed to be
    the default soon anyway.

--

PiperOrigin-RevId: 242587219

5 years ago [TableGen] Make sure op in pattern has the same number of arguments as definition
Lei Zhang [Mon, 8 Apr 2019 22:14:59 +0000 (15:14 -0700)]
[TableGen] Make sure op in pattern has the same number of arguments as definition

    When an op in the source pattern specifies more arguments than its definition, we
    will have out-of-bound query for op arguments from the definition. That will cause
    crashes. This change fixes it.

--

PiperOrigin-RevId: 242548415

5 years ago De-templatize TensorContractionBase (Linalg example/tutorial)
Nicolas Vasilache [Mon, 8 Apr 2019 22:06:34 +0000 (15:06 -0700)]
De-templatize TensorContractionBase (Linalg example/tutorial)

    TensorContractionBase has become too unwieldy with all the CRTP manipulation once less trivial transformations are implemented.
    This CL drops CRTP for inheritance and uses the same name comparison trick to figure out what to cast into.
    As a byproduct, all the -inl.h files disappear.
    To maintain the separation between directories, a LINALG_STEP variable is introduced

--

PiperOrigin-RevId: 242546977

5 years ago Add TabelGen support to logically AND a list of attribute constraints.
Ashwin Murthy [Mon, 8 Apr 2019 21:32:39 +0000 (14:32 -0700)]
Add TabelGen support to logically AND a list of attribute constraints.

    This is the AllOf version for AttrConstraint and allows specifying the combined constraint during pattern match.

--

PiperOrigin-RevId: 242540243

5 years ago Add CMakeLists rules for Linalg
Nicolas Vasilache [Mon, 8 Apr 2019 13:47:06 +0000 (06:47 -0700)]
Add CMakeLists rules for Linalg

--

PiperOrigin-RevId: 242454319

5 years ago Add xor bitwise operation to StandardOps.
Stephan Herhut [Mon, 8 Apr 2019 12:53:59 +0000 (05:53 -0700)]
Add xor bitwise operation to StandardOps.

    This adds parsing, printing and some folding/canonicalization.

    Also extends rewriting of subi %0, %0 to handle vectors and tensors.

--

PiperOrigin-RevId: 242448164

5 years ago Fix build for the Linalg example dialect with MacOS
Nicolas Vasilache [Mon, 8 Apr 2019 12:07:01 +0000 (05:07 -0700)]
Fix build for the Linalg example dialect with MacOS

--

PiperOrigin-RevId: 242443831

5 years ago Example Linalg3: manually register the Linalg dialect
Alex Zinenko [Mon, 8 Apr 2019 10:34:11 +0000 (03:34 -0700)]
Example Linalg3: manually register the Linalg dialect

    This dialect does not have a global constructor and has to be registered
    manually in `main`.  Also fix the way it is exercised in the test.

--

PiperOrigin-RevId: 242434886

5 years ago Change initialization syntax for ScopedContext in examples
Alex Zinenko [Mon, 8 Apr 2019 10:11:12 +0000 (03:11 -0700)]
Change initialization syntax for ScopedContext in examples

    For some reason, the OSS build on macOS was not happy with the initialization
    syntax and was attempting to call a copy constructor.  Hotfix it to use a
    different syntax pending further investigation.

--

PiperOrigin-RevId: 242432634

5 years ago Add and and or bitwise operations to StandardOps.
Stephan Herhut [Mon, 8 Apr 2019 07:00:46 +0000 (00:00 -0700)]
Add and and or bitwise operations to StandardOps.

    This adds parsing, printing and some folding/canonicalization.

--

PiperOrigin-RevId: 242409840

5 years ago Fix bug in Toy tutorial where IR emission stopped after any `print`
Mehdi Amini [Mon, 8 Apr 2019 06:30:58 +0000 (23:30 -0700)]
Fix bug in Toy tutorial where IR emission stopped after any `print`

--

PiperOrigin-RevId: 242407970

5 years ago Introduce std.varargs attribute to mark variadic arguments functions
Mehdi Amini [Mon, 8 Apr 2019 00:11:02 +0000 (17:11 -0700)]
Introduce std.varargs attribute to mark variadic arguments functions

    This is only teaching the LLVM converter to propagate the attribute onto
    the function type. MLIR will not recognize this arguments, so it would only
    be useful when calling for example `printf` with the same arguments across
    a module. Since varargs is part of the ABI lowering, this is not NFC.

--

PiperOrigin-RevId: 242382427

5 years ago Do not mark llvm.return, llvm.br, llvm.cond_br operations as having no side effects.
Mehdi Amini [Sun, 7 Apr 2019 21:34:31 +0000 (14:34 -0700)]
Do not mark llvm.return, llvm.br, llvm.cond_br operations as having no side effects.

    The canonicalizer is taking advantage of this to kill them.

--

PiperOrigin-RevId: 242374166

5 years ago Fix Linalg3 lowering to use the floating point element type matching the view
Mehdi Amini [Sun, 7 Apr 2019 20:12:48 +0000 (13:12 -0700)]
Fix Linalg3 lowering to use the floating point element type matching the view

    It used to be hardcoded to f32, but Toy tutorial is using f64.

--

PiperOrigin-RevId: 242370172

5 years ago Add support for f64 type conversion for Linalg dialect to LLVM lowering
Mehdi Amini [Sun, 7 Apr 2019 12:42:21 +0000 (05:42 -0700)]
Add support for f64 type conversion for Linalg dialect to LLVM lowering

--

PiperOrigin-RevId: 242345259

5 years agoFix cond_br example.
Tatiana Shpeisman [Sun, 7 Apr 2019 02:49:38 +0000 (19:49 -0700)]
Fix cond_br example.

PiperOrigin-RevId: 242314071

5 years agoDocumentation fix - use '_' instead of '.' in the type alias example.
Tatiana Shpeisman [Sun, 7 Apr 2019 02:39:53 +0000 (19:39 -0700)]
Documentation fix - use '_' instead of '.' in the type alias example.

PiperOrigin-RevId: 242313674

5 years agoDocumentation fix - complex type is a standard type
Tatiana Shpeisman [Sun, 7 Apr 2019 02:31:19 +0000 (19:31 -0700)]
Documentation fix - complex type is a standard type

PiperOrigin-RevId: 242313280

5 years ago Filter DialectConversion pattern to be considered only if the root kind matches...
Mehdi Amini [Sat, 6 Apr 2019 17:53:00 +0000 (10:53 -0700)]
Filter DialectConversion pattern to be considered only if the root kind matches the operation.

    This is the same logic as the PatterRewriter.

--

PiperOrigin-RevId: 242287241

5 years ago Provide a default implementation for matching: most DialectOpConversion implement...
Mehdi Amini [Sat, 6 Apr 2019 17:27:56 +0000 (10:27 -0700)]
Provide a default implementation for matching: most DialectOpConversion implementations are unconditionally matching.

    This will help removing boilerplate.

--

PiperOrigin-RevId: 242285885

5 years ago Change the asmprinter to use pretty syntax for dialect types when it can,
Chris Lattner [Sat, 6 Apr 2019 06:56:49 +0000 (23:56 -0700)]
Change the asmprinter to use pretty syntax for dialect types when it can,
    making the IR dumps much nicer.

    This is part 2/3 of the path to making dialect types more nice.  Part 3/3 will
    slightly generalize the set of characters allowed in pretty types and make it
    more principled.

--

PiperOrigin-RevId: 242249955

5 years ago Introduce support for parsing pretty dialect types, currently with a very
Chris Lattner [Sat, 6 Apr 2019 02:36:42 +0000 (19:36 -0700)]
Introduce support for parsing pretty dialect types, currently with a very
    restricted grammar.  This will make certain common types much easier to read.

    This is part tensorflow/mlir#1 of 2, which allows us to accept the new syntax.  Part 2 will
    change the asmprinter to automatically use it when appropriate, which will
    require updating a bunch of tests.

    This is motivated by the EuroLLVM tutorial and cleaning up the LLVM dialect aesthetics a bit more.

--

PiperOrigin-RevId: 242234821

5 years agoRemove/replace TPU-specific instruction references and memref spaces in LangRef.md
Andy Davis [Sat, 6 Apr 2019 01:34:49 +0000 (18:34 -0700)]
Remove/replace TPU-specific instruction references and memref spaces in LangRef.md
Remove undesigned/unimplemented operations: reshape and view.
Add new LangRefDeletions.md file in /experimental to store things removed from public LangRef.md

PiperOrigin-RevId: 242230200

5 years ago Add iterator support to DenseIntElementsAttr and DenseFPElementsAttr. This avoids...
River Riddle [Fri, 5 Apr 2019 23:11:24 +0000 (16:11 -0700)]
Add iterator support to DenseIntElementsAttr and DenseFPElementsAttr. This avoids the need to load all of the values from a DenseElementsAttr inorder to process them.

--

PiperOrigin-RevId: 242212741

5 years ago Add attr constraint support to constrain IntegerArray attribute values at a speci...
Ashwin Murthy [Fri, 5 Apr 2019 22:51:47 +0000 (15:51 -0700)]
Add attr constraint support to constrain IntegerArray attribute values at a specified index.

--

PiperOrigin-RevId: 242209394

5 years ago Post commit cleanups to the Linalg dialect
Nicolas Vasilache [Fri, 5 Apr 2019 20:20:05 +0000 (13:20 -0700)]
Post commit cleanups to the Linalg dialect

--

PiperOrigin-RevId: 242181687

5 years ago Add new utilities for RTTI Operation casting: dyn_cast_or_null and isa_nonnull
River Riddle [Fri, 5 Apr 2019 19:24:03 +0000 (12:24 -0700)]
Add new utilities for RTTI Operation casting: dyn_cast_or_null and isa_nonnull
    * dyn_cast_or_null
      - This will first check if the operation is null before trying to 'dyn_cast':

        Value *v = ...;
        if (auto forOp = dyn_cast_or_null<AffineForOp>(v->getDefiningOp()))
          ...
    * isa_nonnull
      - This will first check if the pointer is null before trying to 'isa':

        Value *v = ...;
        if (isa_nonnull<AffineForOp>(v->getDefiningOp());
          ...

--

PiperOrigin-RevId: 242171343

5 years ago Add methods for building array attributes in Builder
Lei Zhang [Fri, 5 Apr 2019 19:19:22 +0000 (12:19 -0700)]
Add methods for building array attributes in Builder

    I32/I64/F32/F64/Str array attributes are commonly used in ops. It helps
    to have handy methods for them.

--

PiperOrigin-RevId: 242170569

5 years ago Tidy up the links in the documents and fix any broken ones.
River Riddle [Fri, 5 Apr 2019 15:19:42 +0000 (08:19 -0700)]
Tidy up the links in the documents and fix any broken ones.

--

PiperOrigin-RevId: 242127863

5 years ago Linalg3 example: implement JIT-compilation and execution
Alex Zinenko [Fri, 5 Apr 2019 15:18:13 +0000 (08:18 -0700)]
Linalg3 example: implement JIT-compilation and execution

    Use MLIR's ExecutionEngine to demonstrate how one can implement a simple
    JIT-compiler and executor after fully lowering the Linalg dialect to the LLVM
    IR dialect, using the direct conversion (not going through standard
    loads/stores).

--

PiperOrigin-RevId: 242127690

5 years ago ExecutionEngine: allow for running MLIR passes during JIT-compilation
Alex Zinenko [Fri, 5 Apr 2019 15:15:41 +0000 (08:15 -0700)]
ExecutionEngine: allow for running MLIR passes during JIT-compilation

    The existing implementation of the ExecutionEngine unconditionally runs a list
    of "default" MLIR passes on the module upon creation.  These passes include,
    among others, dialect conversions from affine to standard and from standard to
    LLVM IR dialects.  In some cases, these conversions might have been performed
    before ExecutionEngine is created.  More advanced use cases may be performing
    additional transformations that the "default" passes will conflict with.
    Provide an overload for ExecutionEngine::create that takes a PassManager
    configured with the passes to run on the module.  If it is not provided, do not
    run any passes.  The engine will not be created if the input module, after the
    pass manager, has any other dialect than the LLVM IR dialect.

--

PiperOrigin-RevId: 242127393

5 years ago Fix CMake build: reflect that a new file Utils/ConstantFoldUtils.cpp was added
Mehdi Amini [Fri, 5 Apr 2019 14:39:48 +0000 (07:39 -0700)]
Fix CMake build: reflect that a new file Utils/ConstantFoldUtils.cpp was added

--

PiperOrigin-RevId: 242123122

5 years ago Add mentions of requirements before the build instructions
Mehdi Amini [Fri, 5 Apr 2019 14:30:16 +0000 (07:30 -0700)]
Add mentions of requirements before the build instructions

    The `Getting Started` instructions requires git, ninja, and a working C++ host toolchain.

--

PiperOrigin-RevId: 242121953

5 years ago [TableGen] Support array attribute subclasses and constraints
Lei Zhang [Fri, 5 Apr 2019 14:22:28 +0000 (07:22 -0700)]
[TableGen] Support array attribute subclasses and constraints

    To support automatically constraint composition of ArrayAttr, a new
    predicate combiner, Concat, is introduced. It prepends a prefix and
    appends a postfix to a child predicate's final predicate string.

--

PiperOrigin-RevId: 242121186

5 years ago Fix CMake build: account for renamed files and add missing include on MacOS
Mehdi Amini [Fri, 5 Apr 2019 10:52:59 +0000 (03:52 -0700)]
Fix CMake build: account for renamed files and add missing include on MacOS

--

PiperOrigin-RevId: 242101364

5 years ago Linalg portion of the tutorial - part 4
Nicolas Vasilache [Fri, 5 Apr 2019 02:57:42 +0000 (19:57 -0700)]
Linalg portion of the tutorial - part 4

    This CL adds declarative tiling support in the linalg dialect by providing:
    1. loop tiling on linalg ops by simply calling into mlir::tile
    2. view tiling on linalg ops by:
      a. computing the subview between for each tile dimension based on the loop tile size and the mapping of loops to operand ranges.
      b. declaring that the tiled form of a tensorcontraction is the same tensorcontraction on subviews, which essentially gives us a recursive form.

    Point 2.b is potentially subject to change in the future.

--

PiperOrigin-RevId: 242058658

5 years ago NFC: Fix a few typos in the tutorials and one in the comment of FunctionAttr...
River Riddle [Fri, 5 Apr 2019 01:34:41 +0000 (18:34 -0700)]
NFC: Fix a few typos in the tutorials and one in the comment of FunctionAttr::dropFunctionReference.

--

PiperOrigin-RevId: 242050934

5 years ago Add Chapter 4 for the Toy tutorial: shape inference, function specialization...
Mehdi Amini [Fri, 5 Apr 2019 01:31:31 +0000 (18:31 -0700)]
Add Chapter 4 for the Toy tutorial: shape inference, function specialization, and basic combines

--

PiperOrigin-RevId: 242050514

5 years ago Add mention that we don't (yet) accept contributions in the README
Mehdi Amini [Fri, 5 Apr 2019 01:22:17 +0000 (18:22 -0700)]
Add mention that we don't (yet) accept contributions in the README

--

PiperOrigin-RevId: 242049527

5 years ago Linalg portion of the tutorial - part 3-3
Nicolas Vasilache [Fri, 5 Apr 2019 00:54:41 +0000 (17:54 -0700)]
Linalg portion of the tutorial - part 3-3

    This CL adds the last bit to convert from linalg.LoadOp and linalg.StoreOp to the affine dialect, as well as a unit test to exercise the conversion.

--

PiperOrigin-RevId: 242045826

5 years ago NFC: Replace usages of iterator_range<operand_iterator> with operand_range.
River Riddle [Thu, 4 Apr 2019 23:24:10 +0000 (16:24 -0700)]
NFC: Replace usages of iterator_range<operand_iterator> with operand_range.

--

PiperOrigin-RevId: 242031201

5 years ago Introduce a new class, MultiOperandTraitBase, to deduplicate the operand accessor...
River Riddle [Thu, 4 Apr 2019 23:01:45 +0000 (16:01 -0700)]
Introduce a new class, MultiOperandTraitBase, to deduplicate the operand accessors for traits with multiple operands.

    As part of this cleanup, NOperands<0>::Impl and NOperands<1>::Impl are typedef'd to ZeroOperands and OneOperand respectively.

--

PiperOrigin-RevId: 242027189

5 years ago NFC: Fix erroneous use of 'OpaqueType' with 'Type' when setting the ToyTypeKind...
River Riddle [Thu, 4 Apr 2019 22:30:34 +0000 (15:30 -0700)]
NFC: Fix erroneous use of 'OpaqueType' with 'Type' when setting the ToyTypeKind, as well as a few mistakes in Chapter 2 of the Toy tutorial.

--

PiperOrigin-RevId: 242021477

5 years ago Create a LoopUtil function to return perfectly nested loop set
MLIR Team [Thu, 4 Apr 2019 22:19:17 +0000 (15:19 -0700)]
Create a LoopUtil function to return perfectly nested loop set

--

PiperOrigin-RevId: 242019230

5 years ago Iterate on the operations to fold in TestConstantFold in reverse to remove the...
River Riddle [Thu, 4 Apr 2019 21:42:18 +0000 (14:42 -0700)]
Iterate on the operations to fold in TestConstantFold in reverse to remove the need for ConstantFoldHelper to have a flag for insertion at the head of the entry block. This also fixes an asan bug in TestConstantFold due to the iteration order of operations and ConstantFoldHelper's constant insertion placement.

    Note: This now means that we cannot fold chains of operations, i.e. where constant foldable operations feed into each other. Given that this is a testing pass solely for constant folding, this isn't really something that we want anyways. Constant fold tests should be simple and direct, with more advanced folding/feeding being tested with the canonicalizer.

--

PiperOrigin-RevId: 242011744

5 years ago Fix a few warnings for missing parentheses around '||' and extra semicolons.
River Riddle [Thu, 4 Apr 2019 20:25:29 +0000 (13:25 -0700)]
Fix a few warnings for missing parentheses around '||' and extra semicolons.

--

PiperOrigin-RevId: 241994767

5 years ago Deduplicate constant folding logic in ConstantFold and GreedyPatternRewriteDriver
Lei Zhang [Thu, 4 Apr 2019 18:40:57 +0000 (11:40 -0700)]
Deduplicate constant folding logic in ConstantFold and GreedyPatternRewriteDriver

    There are two places containing constant folding logic right now: the ConstantFold
    pass and the GreedyPatternRewriteDriver. The logic was not shared and started to
    drift apart. We were testing constant folding logic using the ConstantFold pass,
    but lagged behind the GreedyPatternRewriteDriver, where we really want the constant
    folding to happen.

    This CL pulled the logic into utility functions and classes for sharing between
    these two places. A new ConstantFoldHelper class is created to help constant fold
    and de-duplication.

    Also, renamed the ConstantFold pass to TestConstantFold to make it clear that it is
    intended for testing purpose.

--

PiperOrigin-RevId: 241971681

5 years ago Remove the non-postorder walk functions from Function/Block/Instruction and renam...
River Riddle [Thu, 4 Apr 2019 18:13:02 +0000 (11:13 -0700)]
Remove the non-postorder walk functions from Function/Block/Instruction and rename walkPostOrder to walk.

--

PiperOrigin-RevId: 241965239

5 years ago Fix bug in LoopTiling where creation of tile-space loop upper bound did not handl...
Andy Davis [Thu, 4 Apr 2019 17:42:45 +0000 (10:42 -0700)]
Fix bug in LoopTiling where creation of tile-space loop upper bound did not handle symbol operands correctly.

--

PiperOrigin-RevId: 241958502

5 years ago Adds dependence analysis support for iteration domains with local variables ...
Andy Davis [Thu, 4 Apr 2019 17:35:51 +0000 (10:35 -0700)]
Adds dependence analysis support for iteration domains with local variables (enables dependence analysis of loops with non-unit step).

--

PiperOrigin-RevId: 241957023

5 years ago [TableGen] Enforce constraints on attributes
Lei Zhang [Thu, 4 Apr 2019 16:25:38 +0000 (09:25 -0700)]
[TableGen] Enforce constraints on attributes

    Previously, attribute constraints are basically unused: we set true for almost
    anything. This CL refactors common attribute kinds and sets constraints on
    them properly. And fixed verification failures found by this change.

    A noticeable one is that certain TF ops' attributes are required to be 64-bit
    integer, but the corresponding TFLite ops expect 32-bit integer attributes.
    Added bitwidth converters to handle this difference.

--

PiperOrigin-RevId: 241944008

5 years ago [TableGen] Add PatternSymbolResolver for resolving symbols bound in patterns
Lei Zhang [Thu, 4 Apr 2019 12:44:58 +0000 (05:44 -0700)]
[TableGen] Add PatternSymbolResolver for resolving symbols bound in patterns

    We can bind symbols to op arguments/results in source pattern and op results in
    result pattern. Previously resolving these symbols is scattered across
    RewriterGen.cpp. This CL aggregated them into a `PatternSymbolResolver` class.

    While we are here, this CL also cleans up tests for patterns to make them more
    focused. Specifically, one-op-one-result.td is superseded by pattern.td;
    pattern-tAttr.td is simplified; pattern-bound-symbol.td is added for the change
    in this CL.

--

PiperOrigin-RevId: 241913973

5 years ago [TableGen] Rework verifier generation and error messages
Lei Zhang [Thu, 4 Apr 2019 11:29:58 +0000 (04:29 -0700)]
[TableGen] Rework verifier generation and error messages

    Previously we bundle the existence check and the MLIR attribute kind check
    in one call. Further constraints (like element bitwidth) have to be split
    into following checks. That is not a nice separation given that we have more
    checks for constraints. Instead, this CL changes to generate a local variable
    for every attribute, check its existence first, then check the constraints.

    Creating a local variable for each attribute also avoids querying it multiple
    times using the raw getAttr() API. This is a win for both performance the
    readability of the generated code.

    This CL also changed the error message to be more greppable by delimiting
    the error message from constraints with boilerplate part with colon.

--

PiperOrigin-RevId: 241906132

5 years ago Example Linalg3: support Load/Store conversion from Linalg to LLVM IR dialect
Alex Zinenko [Thu, 4 Apr 2019 08:43:21 +0000 (01:43 -0700)]
Example Linalg3: support Load/Store conversion from Linalg to LLVM IR dialect

    Load and Store Linalg operations are converter to their LLVM IR counterparts
    preceded by a sequence of operations that recover the effective address of the
    accessed element.  The address is computed given the subscripts and the view
    descriptor as

        base_pointer + base_offset + SUM_i subscript_i * stride_i.

    Manual testing shows that the resulting LLVM IR for the matrix multiplication
    example can be compiled and executed, producing correct results.

--

PiperOrigin-RevId: 241889003

5 years ago Fix Toy Ch3 testing with CMake
Mehdi Amini [Thu, 4 Apr 2019 02:16:32 +0000 (19:16 -0700)]
Fix Toy Ch3 testing with CMake

    Mainly a missing dependency caused the tests to pass if one already built
    the repo, but not from a clean (or incremental) build.

--

PiperOrigin-RevId: 241852313

5 years ago Chapter 3 for Toy tutorial: introduction of a dialect
Mehdi Amini [Thu, 4 Apr 2019 01:45:01 +0000 (18:45 -0700)]
Chapter 3 for Toy tutorial: introduction of a dialect

--

PiperOrigin-RevId: 241849162

5 years ago [README] Fix links, minor edits.
Dan Zheng [Thu, 4 Apr 2019 01:27:23 +0000 (18:27 -0700)]
[README] Fix links, minor edits.

    Fix links without breaking g3doc.
    Minor stylistic edits.

--

PiperOrigin-RevId: 241846985

5 years ago [README] Minor edits.
Dan Zheng [Thu, 4 Apr 2019 00:50:41 +0000 (17:50 -0700)]
[README] Minor edits.

    Minor stylistic edits.
    Use standard "TensorFlow" spelling.

--

PiperOrigin-RevId: 241842272

5 years ago Add CMakeLists.txt for Quantization and FxpMathOps dialects (and misc fixes to...
Stella Laurenzo [Thu, 4 Apr 2019 00:43:00 +0000 (17:43 -0700)]
Add CMakeLists.txt for Quantization and FxpMathOps dialects (and misc fixes to build with OSS setup).

    Tested:
      cmake -G Ninja ../llvm/ -DLLVM_BUILD_EXAMPLES=ON
      ninja check-mlir

--

PiperOrigin-RevId: 241841296

5 years ago Rename UnknownType to OpaqueType (NFC)
Mehdi Amini [Wed, 3 Apr 2019 23:49:01 +0000 (16:49 -0700)]
Rename UnknownType to OpaqueType (NFC)

    This came up in a review of the tutorial, it was suggested that "opaque" is more
    descriptive than "unknown" here.

--

PiperOrigin-RevId: 241832927

5 years ago Move the top-level `tutorial` as `Linalg` nested in the examples folder
Mehdi Amini [Wed, 3 Apr 2019 23:38:53 +0000 (16:38 -0700)]
Move the top-level `tutorial` as `Linalg` nested in the examples folder

--

PiperOrigin-RevId: 241831176

5 years ago Split the Quantization dialect.
Stella Laurenzo [Wed, 3 Apr 2019 23:07:37 +0000 (16:07 -0700)]
Split the Quantization dialect.

    - Retains Quantization types and predicates.
    - Retains utilities and example (testable) passes/ops.
    - Retains unit tests for example passes/ops.
    - Moves fixed point ops (and corresponding real ops) to FxpMathOps.
    - Moves real -> fixed point pass to FxpMathOps.
    - Sever the dependency on the TF dialect from Quantization. These dialects should now be open-sourcable.

--

PiperOrigin-RevId: 241825598

5 years ago Fix the alignment issue in the DenseElementsAttr buffer allocation
Feng Liu [Wed, 3 Apr 2019 22:19:56 +0000 (15:19 -0700)]
Fix the alignment issue in the DenseElementsAttr buffer allocation

    Currently, we only make the initial address aligned with 64-bit address but
    allocate the buffer with the real size. This can cause issue when we extract
    the value by the `readBits` method, which needs to read the memory in the
    granularity of APINT_WORD_SIZE. In this CL, we rounded the allocation size to
    the multiplies of APINT_WORD_SIZE to fix the issue.

--

PiperOrigin-RevId: 241816656

5 years ago Added memref to OpBase.td as specific memref types should be supported by default.
Rob Suderman [Wed, 3 Apr 2019 21:30:17 +0000 (14:30 -0700)]
Added memref to OpBase.td as specific memref types should be supported by default.

--

PiperOrigin-RevId: 241806461

5 years agoRemove links to internal google docs, updating them to point to GitHub.
Smit Hinsu [Wed, 3 Apr 2019 21:05:23 +0000 (14:05 -0700)]
Remove links to internal google docs, updating them to point to GitHub.

PiperOrigin-RevId: 241801638

5 years ago Remove links to internal google docs, updating them to point to GitHub.
Chris Lattner [Wed, 3 Apr 2019 21:00:30 +0000 (14:00 -0700)]
Remove links to internal google docs, updating them to point to GitHub.

--

PiperOrigin-RevId: 241800478

5 years agoRefactor Quantization.md to separate TFLite native quantization scheme from the more...
Stella Laurenzo [Wed, 3 Apr 2019 19:40:30 +0000 (12:40 -0700)]
Refactor Quantization.md to separate TFLite native quantization scheme from the more experimental, generalized scheme.

PiperOrigin-RevId: 241785572

5 years ago Linalg portion of the tutorial - part 3-2
Nicolas Vasilache [Wed, 3 Apr 2019 19:33:01 +0000 (12:33 -0700)]
Linalg portion of the tutorial - part 3-2

    This CL adds support for lowering tensor contractions to loops declaratively.
    This is done thanks to two properties of the such operations:
    1. the definition of an AffineMap getLoopsToOperandRangesMap for each op which maps iteration space dimensions to ranges of the view operands, in their order of occurrence;
    2. the definition of a scalar implementation for each op which creates the computation inside the loops given enclosing parallel and reduction loops,

    All the other properties are derived in a generic fashion from these 2 properties and a few analyses.

    A lowerToLoops transformation is added as well as a test that exercises it.

--

PiperOrigin-RevId: 241783992

5 years ago [TableGen] Allow additional result patterns not directly used for replacement
Lei Zhang [Wed, 3 Apr 2019 19:29:14 +0000 (12:29 -0700)]
[TableGen] Allow additional result patterns not directly used for replacement

    This CL looses the requirement that all result patterns in a rewrite rule must
    replace a result of the root op in the source pattern. Now only the last N
    result pattern-generated ops are used to replace a N-result source op.

    This allows to generate additional ops to aid building up final ops used to
    replace the source op.

--

PiperOrigin-RevId: 241783192

5 years agoInitial release of the Quantization dialect
Stella Laurenzo [Wed, 3 Apr 2019 18:16:32 +0000 (11:16 -0700)]
Initial release of the Quantization dialect

Includes a draft of documentation for the quantization setup.

Given how many comments such docs have garnered in the past, I've biased towards a lightly edited first-draft so that people can argue about terminology, approach and structure without having spent too much time on it.

Note that the sections under "Uniform quantization" were cribbed nearly verbatim from internal documentation that Daniel wrote.

PiperOrigin-RevId: 241768668

5 years ago [TableGen] Fix convertFromStorage for OptionalAttr
Lei Zhang [Wed, 3 Apr 2019 17:48:07 +0000 (10:48 -0700)]
[TableGen] Fix convertFromStorage for OptionalAttr

    OptionalAttr is just wrapping around the actual attribute; so it should just use
    the actual attribute's `convertFromStorage` to read the value and wrap it around
    with `Optional<>` to return. Previously it was mandating how the actual attribute
    reads the value with `{0}.getValue()`.

--

PiperOrigin-RevId: 241762355

5 years ago Tutorial Linalg1: implement conversion to the LLVM Dialect
Alex Zinenko [Wed, 3 Apr 2019 17:38:47 +0000 (10:38 -0700)]
Tutorial Linalg1: implement conversion to the LLVM Dialect

    Implement conversion from the Linalg dialect to the LLVM dialect using a simple
    set of DialectOpConverters and by plugging them into the dialect conversion
    infrastructure.  View and Range Linalg types are converted into descriptors
    that store the dynamic values in an LLVM aggregate type, similarly to memrefs.
    Slice operations create new descriptors based on the original descriptors and
    thus remove the constraint on ViewTypes not being acceptable as function
    arguments.

--

PiperOrigin-RevId: 241760189

5 years agoAdd mention of the TensorFlow Code of Conduct in the Readme
Mehdi Amini [Wed, 3 Apr 2019 16:40:08 +0000 (09:40 -0700)]
Add mention of the TensorFlow Code of Conduct in the Readme

PiperOrigin-RevId: 241748009

5 years ago Add missing source file in CMakeLists.txt
Mehdi Amini [Wed, 3 Apr 2019 16:29:52 +0000 (09:29 -0700)]
Add missing source file in CMakeLists.txt

--

PiperOrigin-RevId: 241746122

5 years ago [TableGen] Remove asserts for attributes in aggregate builders
Lei Zhang [Wed, 3 Apr 2019 16:29:25 +0000 (09:29 -0700)]
[TableGen] Remove asserts for attributes in aggregate builders

    Attributes can have default values or be optional. Checking the validity of
    attributes in aggregate builder should consider that. And to be accurate,
    we should check all required attributes are indeed provided in the list.
    This is actually duplicating the work done by verifier. Checking the validity
    of attributes should be the responsiblity of verifiers. This CL removes
    the assertion for attributes in aggregate builders for the above reason.
    (Assertions for operands/results are still kept since they are trivial.)

    Also added more tests for aggregate builders.

--

PiperOrigin-RevId: 241746059

5 years ago Fix CMake build
Mehdi Amini [Wed, 3 Apr 2019 16:20:26 +0000 (09:20 -0700)]
Fix CMake build

    Some files were not built anymore internally but still referenced
    from CMake. Delete them and unreference them in the CMake files.

--

PiperOrigin-RevId: 241744718

5 years ago Update Readme to mention that the TensorFlow specific will be upstreamed later
Mehdi Amini [Wed, 3 Apr 2019 15:28:29 +0000 (08:28 -0700)]
Update Readme to mention that the TensorFlow specific will be upstreamed later

--

PiperOrigin-RevId: 241735845

5 years ago Drop MLIREmitter-based version of the EDSC
Alex Zinenko [Wed, 3 Apr 2019 13:11:03 +0000 (06:11 -0700)]
Drop MLIREmitter-based version of the EDSC

    This version has been deprecated and can now be removed completely since the
    last remaining user (Python bindings) migrated to declarative builders.
    Several functions in lib/EDSC/Types.cpp construct core IR objects for the C
    bindings.  Move these functions into lib/EDSC/CoreAPIs.cpp until we decide
    where they should live.

    This completes the migration from the delayed-construction EDSC to Declarative
    Builders.

--

PiperOrigin-RevId: 241716729

5 years ago Python bindings: drop MLIREmitter and related functionality
Alex Zinenko [Wed, 3 Apr 2019 12:43:44 +0000 (05:43 -0700)]
Python bindings: drop MLIREmitter and related functionality

    This completes the transition of Python bindings to use the declarative
    builders infrastructure instead of the now-deprecated EDSC emitter
    infrastructure.  The relevant unit tests have been replicated using the new
    functionality and the remaining end-to-end compilation tests have been updated
    accordingly.  The latter show an improvement in brevity and readability.

--

PiperOrigin-RevId: 241713489

5 years ago Python bindings: support __floordiv__ for index types
Alex Zinenko [Wed, 3 Apr 2019 12:39:02 +0000 (05:39 -0700)]
Python bindings: support __floordiv__ for index types

    The original reimplementation of EDSC as declarative builders and the
    subsequent rework of Python bindings forbade to use the (true) division
    operator for values of the index types without providing an alternative.  Index
    types only support floor and ceil division through affine maps.  Expose this to
    Python bindings through a `__floordiv__` function on `ValueHandle`s.

--

PiperOrigin-RevId: 241713093

5 years ago Remove section of the README copied from the Rationale document, it does not...
Mehdi Amini [Wed, 3 Apr 2019 08:47:13 +0000 (01:47 -0700)]
Remove section of the README copied from the Rationale document, it does not fit here.

--

PiperOrigin-RevId: 241687723

5 years ago Fix test that fails on non-determinism in LowerVectorTransfers
Nicolas Vasilache [Wed, 3 Apr 2019 07:46:40 +0000 (00:46 -0700)]
Fix test that fails on non-determinism in LowerVectorTransfers

    This CL fixes the non-determinism across compilers in an edsc::select expression used in LowerVectorTransfers. This is achieved by factoring the expression out of the function call to ensure a deterministic order of evaluation.
    Since the expression is now factored out, fewer IR is generated and the test is updated accordingly.

--

PiperOrigin-RevId: 241679962

5 years agoFix path for the examples in Toy tutorial Ch1
Mehdi Amini [Wed, 3 Apr 2019 01:14:56 +0000 (18:14 -0700)]
Fix path for the examples in Toy tutorial Ch1

PiperOrigin-RevId: 241643625

5 years ago Add link to the Toy tutorial in the Readme
Mehdi Amini [Wed, 3 Apr 2019 01:07:26 +0000 (18:07 -0700)]
Add link to the Toy tutorial in the Readme

--

PiperOrigin-RevId: 241642739

5 years ago Add fake-use for variable in LLVMDialect.cpp to fix opt build.
River Riddle [Tue, 2 Apr 2019 22:50:51 +0000 (15:50 -0700)]
Add fake-use for variable in LLVMDialect.cpp to fix opt build.

--

PiperOrigin-RevId: 241620442

5 years ago Fix minor typo (triggered a GCC warning, NFC)
Mehdi Amini [Tue, 2 Apr 2019 22:41:22 +0000 (15:41 -0700)]
Fix minor typo (triggered a GCC warning, NFC)

--

PiperOrigin-RevId: 241618796

5 years ago Introduce custom format for the LLVM IR Dialect
Alex Zinenko [Tue, 2 Apr 2019 22:33:54 +0000 (15:33 -0700)]
Introduce custom format for the LLVM IR Dialect

    Historically, the LLVM IR dialect has been using the generic form of MLIR
    operation syntax.  It is verbose and often redundant.  Introduce the custom
    printing and parsing for all existing operations in the LLVM IR dialect.
    Update the relevant documentation and tests.

--

PiperOrigin-RevId: 241617393

5 years ago Add -DLLVM_BUILD_EXAMPLES to the mlir build instruction: this enables the tutoria...
Mehdi Amini [Tue, 2 Apr 2019 22:15:20 +0000 (15:15 -0700)]
Add -DLLVM_BUILD_EXAMPLES to the mlir build instruction: this enables the tutorial examples

    Seems like a better default for getting started.

--

PiperOrigin-RevId: 241614043

5 years ago Fix Toy tutorial gcc 7 build (NFC)
Mehdi Amini [Tue, 2 Apr 2019 22:13:26 +0000 (15:13 -0700)]
Fix Toy tutorial gcc 7 build (NFC)

--

PiperOrigin-RevId: 241613710