platform/upstream/llvm.git
5 years ago Decouple running a conversion from the DialectConversion class. The DialectConver...
River Riddle [Thu, 23 May 2019 16:23:33 +0000 (09:23 -0700)]
Decouple running a conversion from the DialectConversion class. The DialectConversion class is only necessary for type signature changes(block arguments or function arguments). This isn't always desired when performing a dialect conversion. This allows for those conversions without this need to run per function instead of per module.

--

PiperOrigin-RevId: 249657549

5 years ago Fix Linalg lowering to loops
Nicolas Vasilache [Thu, 23 May 2019 14:00:18 +0000 (07:00 -0700)]
Fix Linalg lowering to loops

    This CL makes lowering to loops always be a:
    ```
    %D = linalg.dim %view, constant : !linalg.view<...>
    affine.for %ix = %c0 to %D {
      ...
    }
    ```

    This form composes correctly with tiling and is also the proper way to emit loops from views that across function boundaries.
    The previous version that would extract the range_min/max/step was composing incorrectly with tiling (i.e. would shift by range_min both in the loop bounds and in the slice) and would not work across function boundaries.

    The relevant tests are updated and a new test `dot_view`---which lowers to loops from views passed as function parameters---is added.

    When additional context is available, the linalg.dim operations should be folded away but this is left for a future CL.

--

PiperOrigin-RevId: 249634712

5 years ago Automated rollback of changelist 247713812.
Thomas Joerg [Thu, 23 May 2019 09:16:18 +0000 (02:16 -0700)]
Automated rollback of changelist 247713812.

PiperOrigin-RevId: 249605627

5 years ago Add LLVM::IntToPtrOp and LLVM::PtrToIntOp to LLVM dialect.
Stephan Herhut [Thu, 23 May 2019 09:03:14 +0000 (02:03 -0700)]
Add LLVM::IntToPtrOp and LLVM::PtrToIntOp to LLVM dialect.

--

PiperOrigin-RevId: 249604199

5 years ago Automated rollback of changelist 249538085.
Rob Suderman [Thu, 23 May 2019 00:03:18 +0000 (17:03 -0700)]
Automated rollback of changelist 249538085.

PiperOrigin-RevId: 249550805

5 years ago Added the ability to run a mapping function across the values of an elements
Rob Suderman [Wed, 22 May 2019 22:55:17 +0000 (15:55 -0700)]
Added the ability to run a mapping function across the values of an elements
    attr. This supports both the SplatElementsAttr and DenseElementsAttr for both
    float and integer inputs / outputs.

--

PiperOrigin-RevId: 249538085

5 years ago Add thread-safe utilities to LLVMType to allow constructing llvm types in a multi...
River Riddle [Wed, 22 May 2019 21:56:07 +0000 (14:56 -0700)]
Add thread-safe utilities to LLVMType to allow constructing llvm types in a multi-threaded environment. The LLVMContext is not thread-safe and directly constructing a raw llvm::Type can create situations where the LLVMContext is modified by multiple threads at the same time.

--

PiperOrigin-RevId: 249526233

5 years ago Refactor FunctionAttr to hold the internal function reference by name instead...
River Riddle [Wed, 22 May 2019 20:41:23 +0000 (13:41 -0700)]
Refactor FunctionAttr to hold the internal function reference by name instead of pointer. The one downside to this is that the function reference held by a FunctionAttr needs to be explicitly looked up from the parent module. This provides several benefits though:
    * There is no longer a need to explicitly remap function attrs.
      - This removes a potentially expensive call from the destructor of Function.
      - This will enable some interprocedural transformations to now run intraprocedurally.
      - This wasn't scalable and forces dialect defined attributes to override
        a virtual function.
    * Replacing a function is now a trivial operation.
    * This is a necessary first step to representing functions as operations.

--

PiperOrigin-RevId: 249510802

5 years ago Return nullptr on Region::getContainingOperation()/getContainingFunction() instea...
Mehdi Amini [Wed, 22 May 2019 19:22:51 +0000 (12:22 -0700)]
Return nullptr on Region::getContainingOperation()/getContainingFunction() instead of asserting

    This avoids crashing when trying to dump an operation nested in a region that isn't yet attached to an operation, which is quite useful when debugging.

    This alone won't be enough to print an unlink Operation, it'll display `<<UNLINKED INSTRUCTION>>`.

--

PiperOrigin-RevId: 249496388

5 years ago Make EDSC builder test more robust to the order of evaluation
Alex Zinenko [Wed, 22 May 2019 19:13:54 +0000 (12:13 -0700)]
Make EDSC builder test more robust to the order of evaluation

    EDSC builder test uses FileCheck to match the IR produced by EDSC in the
    textual order.  For mathematical operations, EDSC relies on overloaded
    operators.  Since they are essentially function calls, the order of evaluation
    of their operands is unspecified and differs between compilers.  Do not rely on
    a specific order of operands and just check they are all emitted before the
    last operation.  Give names to matched SSA values in order to make sure the
    right operands are used in relevant places.

--

PiperOrigin-RevId: 249494995

5 years ago Refactor DialectConversion to operate on functions in-place *without* any cloning...
River Riddle [Wed, 22 May 2019 18:49:04 +0000 (11:49 -0700)]
Refactor DialectConversion to operate on functions in-place *without* any cloning. This works by caching all of the requested pattern rewrite operations, e.g. replace operation, and only applying them on a completely successful conversion.

--

PiperOrigin-RevId: 249490306

5 years ago Update Attribute::getDialect/Type::getDialect to return a non-const dialect refer...
River Riddle [Wed, 22 May 2019 16:56:11 +0000 (09:56 -0700)]
Update Attribute::getDialect/Type::getDialect to return a non-const dialect reference.

--

PiperOrigin-RevId: 249467245

5 years ago NFC: Fix the name of a comment header block in Diagnostics.cpp.
River Riddle [Wed, 22 May 2019 16:52:47 +0000 (09:52 -0700)]
NFC: Fix the name of a comment header block in Diagnostics.cpp.

--

PiperOrigin-RevId: 249466645

5 years ago Add a new interleaveComma that allows specifying a unary function for the contain...
River Riddle [Tue, 21 May 2019 23:30:55 +0000 (16:30 -0700)]
Add a new interleaveComma that allows specifying a unary function for the container elements.

--

PiperOrigin-RevId: 249349269

5 years ago Make static shape tensor container match other container types
Geoffrey Martin-Noble [Tue, 21 May 2019 22:45:25 +0000 (15:45 -0700)]
Make static shape tensor container match other container types

    Suffix with Of and take a list of types. Also give a better description that includes the element type information.

--

PiperOrigin-RevId: 249341159

5 years ago Simplify container type definitions
Geoffrey Martin-Noble [Tue, 21 May 2019 22:44:17 +0000 (15:44 -0700)]
Simplify container type definitions

    The passed element type description is usually unnecessary, and it's just as valid to want to pass a description for the entire container. In either case there's an alternative (Separate element type def or a TypeAlias) and we don't need to pollute the main API.

    To allow for this, I cleaned up the TF op definitions and added some additional utilities.

--

PiperOrigin-RevId: 249340979

5 years ago Make the ParallelDiagnosticHandler used by the pass manager publicly available...
River Riddle [Tue, 21 May 2019 21:29:20 +0000 (14:29 -0700)]
Make the ParallelDiagnosticHandler used by the pass manager publicly available in Diagnostics.h. This provides a common utility for deterministically handling diagnostics in a multi-threaded environment.

--

PiperOrigin-RevId: 249325937

5 years ago Fix a bug in toy LateLowering where a type conversion was using 'cast' instead...
River Riddle [Tue, 21 May 2019 21:24:48 +0000 (14:24 -0700)]
Fix a bug in toy LateLowering where a type conversion was using 'cast' instead of 'dyn_cast'.

--

PiperOrigin-RevId: 249325111

5 years ago Clean up container type names in OpBase
Geoffrey Martin-Noble [Tue, 21 May 2019 17:45:30 +0000 (10:45 -0700)]
Clean up container type names in OpBase

    Establish the following convention:
    1. Container class types end in "Of" (e.g. TensorOf) and take a list of allowed types.
    2. An X container where only a single type is allowed is called TypeX (e.g. I32Tensor).
    3. An X container where any type is allowed is called AnyX (e.g. AnyTensor).

--

PiperOrigin-RevId: 249281018

5 years ago CMake build: force-link SDBM lib into SDBM unit tests
Alex Zinenko [Tue, 21 May 2019 15:56:38 +0000 (08:56 -0700)]
CMake build: force-link SDBM lib into SDBM unit tests

    Otherwise, GCC < 7 does not link in the dialect registration, fails to look up
    the dialect in the context and cannot construct SDBM objects.

--

PiperOrigin-RevId: 249259758

5 years ago Move SDBM uniquer into the SDBM dialect
Alex Zinenko [Tue, 21 May 2019 14:25:55 +0000 (07:25 -0700)]
Move SDBM uniquer into the SDBM dialect

    MLIRContext does not have to be aware of the SDBM unique data structures
    directly.  Move the SDBM storage uniquer from MLIRContext to the SDBM dialect
    instance.  Expressions that previously required a context to be constructed now
    require an instance of the dialect in order to access the uniquer.  While they
    could look up the dialect in the context, it would have introduced a rather
    expensive lookup into each construction.  Instead, the caller is expected to
    obtain the dialect instance and cache it.

--

PiperOrigin-RevId: 249245199

5 years ago Move SDBM infrastructure into a new SDBM dialect
Alex Zinenko [Tue, 21 May 2019 14:22:35 +0000 (07:22 -0700)]
Move SDBM infrastructure into a new SDBM dialect

    We now have sufficient extensibility in dialects to move attribute components
    such as SDBM out of the core IR into a dedicated dialect and make them
    optional.  Introduce an SDBM dialect and move the code.  This is a mostly
    non-functional change.

--

PiperOrigin-RevId: 249244802

5 years ago SDBMExpr: factor uniqu'ing out of MLIRContext.cpp
Alex Zinenko [Tue, 21 May 2019 14:22:00 +0000 (07:22 -0700)]
SDBMExpr: factor uniqu'ing out of MLIRContext.cpp

    SDBM expressions are designed as components of an attribute, similarly to
    affine expressions.  As such, they need to be unique'd in the MLIRContext.
    When SDBM expressions were implemented, uniqu'ing objects in a context required
    to modify MLIRContext implementation.  This is no longer the case as generic
    StorageUniquer has been introduced.  Port the SDBMExpr uniqu'ing to use a newly
    introduced uniquer and remove SDBM construction from MLIRContext.cpp.

--

PiperOrigin-RevId: 249244739

5 years ago Fix -Wsign-compare in OperationSupportTest.cpp
Alex Zinenko [Tue, 21 May 2019 14:07:17 +0000 (07:07 -0700)]
Fix -Wsign-compare in OperationSupportTest.cpp

    A couple of warnings was produced when compiling this test due to comaprisons
    with a signed literal.  Used unsigned literals instead.

--

PiperOrigin-RevId: 249242970

5 years ago Linalg: avoid deriving from MultiOperandTraitBase multiple times
Lei Zhang [Tue, 21 May 2019 11:42:04 +0000 (04:42 -0700)]
Linalg: avoid deriving from MultiOperandTraitBase multiple times

    The Op Definition Generator will automatically insert the VariadicOperands
    trait if an op has variadic operands or results. It already derives from
    MultiOperandTraitBase.

--

PiperOrigin-RevId: 249227268

5 years ago Small cleanup.
Thomas Joerg [Tue, 21 May 2019 08:38:53 +0000 (01:38 -0700)]
Small cleanup.
    * Use `cast` rather than `dyn_cast` to get an assertion failure rather than a segfault in case of a type mismatch.
    * Use stream operators to `emitOpError`s.

--

PiperOrigin-RevId: 249208135

5 years ago AffineExpr: factor uniqu'ing out of MLIRContext.cpp
Alex Zinenko [Tue, 21 May 2019 08:34:13 +0000 (01:34 -0700)]
AffineExpr: factor uniqu'ing out of MLIRContext.cpp

    Affine expressions are designed as components of an attribute and are unique'd
    in the MLIRContext.  When affine expressions were implemented, uniqu'ing
    objects in a context required to modify MLIRContext implementation.  This is no
    longer the case as generic StorageUniquer has been introduced.  Port the
    AffineExpr construction to use the new infrastructure by introducing an
    affineUniquer into the MLIRContext.

--

PiperOrigin-RevId: 249207539

5 years ago Drop AffineExpr::Null
Alex Zinenko [Tue, 21 May 2019 08:33:53 +0000 (01:33 -0700)]
Drop AffineExpr::Null

    Similarly to other value-type wrappers, the default constructor of AffineExpr
    constructs a null object and removes the need for an explicit ::Null
    constructor.  Drop it and remove the only user which can trivially rely on the
    default constructor.

--

PiperOrigin-RevId: 249207502

5 years ago Change getParent() to be a const function. This is only necessary because ilist_n...
Youlong Cheng [Tue, 21 May 2019 06:10:10 +0000 (23:10 -0700)]
Change getParent() to be a const function. This is only necessary because ilist_node_with_parent specifically requires a 'getParent() const' method. If/When ilist_node removes this constraint we should drop the const to fit the rest of the MLIR const model.

--

PiperOrigin-RevId: 249193257

5 years ago Upstream the Quantizer tool (part 4).
Stella Laurenzo [Tue, 21 May 2019 01:27:38 +0000 (18:27 -0700)]
Upstream the Quantizer tool (part 4).

    This adds the basic passes needed and ties them into mlir-opt. Also adds two specific unit tests that exercise them.

    Next step is a standalone quantizer tool and additional cleanup.
    Tested:
      ninja check-mlir

--

PiperOrigin-RevId: 249167690

5 years ago When changing the type of a Function, also update the type of the respective...
River Riddle [Mon, 20 May 2019 22:21:22 +0000 (15:21 -0700)]
When changing the type of a Function, also update the type of the respective FunctionAttr.

--

PiperOrigin-RevId: 249137558

5 years ago [LoopFusion] Don't count terminator op in compute cost.
MLIR Team [Mon, 20 May 2019 21:18:43 +0000 (14:18 -0700)]
[LoopFusion] Don't count terminator op in compute cost.

--

PiperOrigin-RevId: 249124895

5 years ago Use lambdas for nesting edsc constructs.
Nicolas Vasilache [Mon, 20 May 2019 20:32:35 +0000 (13:32 -0700)]
Use lambdas for nesting edsc constructs.

    Using ArrayRef introduces issues with the order of evaluation between a constructor and
    the arguments of the subsequent calls to the `operator()`.
    As a consequence the order of captures is not well-defined can go wrong with certain compilers (e.g. gcc-6.4).
    This CL fixes the issue by using lambdas in lieu of ArrayRef.

--

PiperOrigin-RevId: 249114775

5 years ago Fix MacOS test: use %shlibext in lit command line to expand to .dylib on MacOS...
Mehdi Amini [Mon, 20 May 2019 20:25:35 +0000 (13:25 -0700)]
Fix MacOS test: use %shlibext in lit command line to expand to .dylib on MacOS and .so on Linux

--

PiperOrigin-RevId: 249113478

5 years ago Define a string join tablegen utility
Geoffrey Martin-Noble [Mon, 20 May 2019 18:00:24 +0000 (11:00 -0700)]
Define a string join tablegen utility

--

PiperOrigin-RevId: 249083600

5 years ago Add CMakeLists.txt entry for Linalg/Transforms/LowerToLoops
Nicolas Vasilache [Mon, 20 May 2019 17:49:27 +0000 (10:49 -0700)]
Add CMakeLists.txt entry for Linalg/Transforms/LowerToLoops

--

PiperOrigin-RevId: 249080647

5 years ago Fix automatic description for AnyTypeOf
Geoffrey Martin-Noble [Mon, 20 May 2019 17:32:55 +0000 (10:32 -0700)]
Fix automatic description for AnyTypeOf

    Unfortunately, this now gives a segfault if you pass it an empty list, similar to stringify. Given how fiddly this is, we should probably have a string join helper. I'll fix both of these using better tablegen helpers in a follow-up.

--

PiperOrigin-RevId: 249076849

5 years ago Rename "AnyOf" and "AllOf" combined predicates to "Or" and "And", respectively.
Geoffrey Martin-Noble [Mon, 20 May 2019 17:31:32 +0000 (10:31 -0700)]
Rename "AnyOf" and "AllOf" combined predicates to "Or" and "And", respectively.

    This reduces conflict between these and other type names, where we're moving towards "Of" indicating a container type containing certain types. It also better matches the "Neg" predicate modifier and generally is pretty understandable/readable for predicates.

--

PiperOrigin-RevId: 249076508

5 years ago Delete IntegerBase and FloatBase tablegen classes
Geoffrey Martin-Noble [Mon, 20 May 2019 17:19:38 +0000 (10:19 -0700)]
Delete IntegerBase and FloatBase tablegen classes

    These don't have any behavior and just delegate to Type. The only references are in OpBase.td Since the tablegen type hierarchy is not realized in the generated C++ these also aren't providing value for examining the type hierarchy

--

PiperOrigin-RevId: 249073939

5 years ago [ODS] Allow dialect to specify C++ namespaces
Lei Zhang [Mon, 20 May 2019 16:33:10 +0000 (09:33 -0700)]
[ODS] Allow dialect to specify C++ namespaces

    Previously we force the C++ namespaces to be `NS` if `SomeOp` is defined as
    `NS_SomeOp`. This is too rigid as it does not support nested namespaces
    well. This CL adds a "namespace" field into the Dialect class to allow
    flexible namespaces.

--

PiperOrigin-RevId: 249064981

5 years ago Fix Linalg/llvm_ir test
Nicolas Vasilache [Mon, 20 May 2019 15:48:25 +0000 (08:48 -0700)]
Fix Linalg/llvm_ir test

--

PiperOrigin-RevId: 249057043

5 years ago Fix stride computation bug when lowering linalg.view to llvm
Nicolas Vasilache [Mon, 20 May 2019 15:26:11 +0000 (08:26 -0700)]
Fix stride computation bug when lowering linalg.view to llvm

--

PiperOrigin-RevId: 249053115

5 years ago Add lowering of LinalgLibraryOps to linalg.load + linalg.store.
Nicolas Vasilache [Mon, 20 May 2019 15:04:40 +0000 (08:04 -0700)]
Add lowering of LinalgLibraryOps to linalg.load + linalg.store.

    This CL adds a pass to lower out of dot,matvec,matmul etc and into a combination of affine.for, linalg.load and linalg.store operations.
    Such operations can then later lowered to LLVM.
    This CL essentially performs op expansion using EDSCs and factors out a few common utils from Tiling.cpp.

--

PiperOrigin-RevId: 249049518

5 years ago Use FileCheck to test SDBM
Alex Zinenko [Mon, 20 May 2019 08:44:37 +0000 (01:44 -0700)]
Use FileCheck to test SDBM

    SDBM has an output format representing the unterlying matrix and stripe
    expressions.  Move the SDBM tests from unit testing framework to
    FileCheck-based tests, printing them to the standard output and using FileCheck
    to test the output.  Tests that check the API proper (e.g. that SDBM
    expressions have a specific subtype) and that rely on non-syntatic properties
    (equality of the set of constraints) are not ported.

--

PiperOrigin-RevId: 249006055

5 years ago ExecutionEngine: drop PassManager integration
Alex Zinenko [Mon, 20 May 2019 08:31:29 +0000 (01:31 -0700)]
ExecutionEngine: drop PassManager integration

    Originally, ExecutionEngine was created before MLIR had a proper pass
    management infrastructure or an LLVM IR dialect (using the LLVM target
    directly).  It has been running a bunch of lowering passes to convert the input
    IR from Standard+Affine dialects to LLVM IR and, later, to the LLVM IR dialect.
    This is no longer necessary and is even undesirable for compilation flows that
    perform their own conversion to the LLVM IR dialect.  Drop this integration and
    make ExecutionEngine accept only the LLVM IR dialect.  Users of the
    ExecutionEngine can call the relevant passes themselves.

--

PiperOrigin-RevId: 249004676

5 years ago Fix debug build: static constexpr data member must have a definition (until C...
Mehdi Amini [Mon, 20 May 2019 06:09:29 +0000 (23:09 -0700)]
Fix debug build: static constexpr data member must have a definition (until C++17)

--

PiperOrigin-RevId: 248990338

5 years ago Add support for streaming an OperationName into a Diagnostic.
River Riddle [Mon, 20 May 2019 05:35:01 +0000 (22:35 -0700)]
Add support for streaming an OperationName into a Diagnostic.

--

PiperOrigin-RevId: 248987646

5 years ago NFC: Tidy up DialectConversion.cpp and rename DialectOpConversion to DialectConv...
River Riddle [Mon, 20 May 2019 03:54:13 +0000 (20:54 -0700)]
NFC: Tidy up DialectConversion.cpp and rename DialectOpConversion to  DialectConversionPattern.

--

PiperOrigin-RevId: 248980810

5 years ago Refactor the DialectConversion process to clone each function and then operate...
River Riddle [Mon, 20 May 2019 00:56:32 +0000 (17:56 -0700)]
Refactor the DialectConversion process to clone each function and then operate in-place, as opposed to incrementally constructing a new function. This is crucial to allowing the use of non type-conversion patterns(normal RewritePatterns) as part of the conversion process.

    The converter now works by inserting fake producer operations when replacing the results of an existing operation with values of a different, now legal, type. These fake operations are guaranteed to never escape the converter.

--

PiperOrigin-RevId: 248969130

5 years ago Allow a function to take the name of another existing function.
River Riddle [Mon, 20 May 2019 00:41:19 +0000 (17:41 -0700)]
Allow a function to take the name of another existing function.

--

PiperOrigin-RevId: 248968285

5 years ago Add support for streaming Operations into Diagnostics.
River Riddle [Mon, 20 May 2019 00:29:51 +0000 (17:29 -0700)]
Add support for streaming Operations into Diagnostics.

--

PiperOrigin-RevId: 248967563

5 years ago Update the rewrite methods of each of the DialectConversion patterns to notify...
River Riddle [Sun, 19 May 2019 23:43:08 +0000 (16:43 -0700)]
Update the rewrite methods of each of the DialectConversion patterns to notify the PatternRewriter that the operation is being replaced.

--

PiperOrigin-RevId: 248965082

5 years ago Add a utility function 'Operation::replaceUsesOfWith' to replace uses of a value...
River Riddle [Sun, 19 May 2019 22:42:49 +0000 (15:42 -0700)]
Add a utility function 'Operation::replaceUsesOfWith' to replace uses of a value within a single operation.

--

PiperOrigin-RevId: 248961779

5 years ago Move the ConversionListBuilder utility to PatternMatch.h and rename it to Rewrite...
River Riddle [Sat, 18 May 2019 20:23:38 +0000 (13:23 -0700)]
Move the ConversionListBuilder utility to PatternMatch.h and rename it to RewriteListBuilder. It has no specific functionality for DialectOpConversion patterns and can be useful for RewritePatterns in general.

--

PiperOrigin-RevId: 248884466

5 years ago Add user iterators to IRObjects, i.e. Values.
River Riddle [Sat, 18 May 2019 18:09:07 +0000 (11:09 -0700)]
Add user iterators to IRObjects, i.e. Values.

--

PiperOrigin-RevId: 248877752

5 years ago Make shape matching work for any shaped type.
Geoffrey Martin-Noble [Sat, 18 May 2019 12:31:35 +0000 (05:31 -0700)]
Make shape matching work for any shaped type.

    The current implementation makes some assumptions about what can be a shaped type, which aren't really necessary. It also has strange behavior for types that aren't in the limited set it handles (e.g. dialect-defined types)

    Updated the comment to match the implementation.

    This is partially motivated by the desire to make MemRef a subclass of ShapedType

--

PiperOrigin-RevId: 248859674

5 years ago Rewrite the DialectOpConversion patterns to inherit from RewritePattern instead...
River Riddle [Sat, 18 May 2019 05:21:13 +0000 (22:21 -0700)]
Rewrite the DialectOpConversion patterns to inherit from RewritePattern instead of Pattern. This simplifies the infrastructure a bit by being able to reuse PatternRewriter and the RewritePatternMatcher, but also starts to lay the groundwork for a more generalized legalization framework that can operate on DialectOpConversions as well as normal RewritePatterns.

--

PiperOrigin-RevId: 248836492

5 years ago Clean up tablegen vector and tensor types
Geoffrey Martin-Noble [Sat, 18 May 2019 02:45:45 +0000 (19:45 -0700)]
Clean up tablegen vector and tensor types

    There was a weird mix of names, styles, and inheritance here. I think this makes it cleaner and more consistent. We can also have a more principled and far-reaching refactor of some of this naming, but this seems like a good improvement regardless

--

PiperOrigin-RevId: 248827005

5 years ago Upstream the Quantizer tool (part 3).
Stella Laurenzo [Sat, 18 May 2019 00:43:50 +0000 (17:43 -0700)]
Upstream the Quantizer tool (part 3).

    This upstreams the config and constraints for a reference quantization scheme based on the FxpMathOps dialect.

    There are probably two more CLs to get the rest: one with the passes/tests, and one with the tool main() itself.

--

PiperOrigin-RevId: 248817505

5 years ago Add support for saving and restoring the insertion point of a FuncBuilder. This...
River Riddle [Sat, 18 May 2019 00:00:42 +0000 (17:00 -0700)]
Add support for saving and restoring the insertion point of a FuncBuilder. This also updates the edsc::ScopedContext to use a single builder that saves/restores insertion points. This is necessary for using edscs within RewritePatterns.

--

PiperOrigin-RevId: 248812645

5 years ago Refactor PatternRewriter to inherit from FuncBuilder instead of Builder. This...
River Riddle [Fri, 17 May 2019 22:57:49 +0000 (15:57 -0700)]
Refactor PatternRewriter to inherit from FuncBuilder instead of Builder. This is necessary for allowing more complicated rewrites in the future that may do things like update the insertion point (e.g. for rewrites involving regions).

--

PiperOrigin-RevId: 248803153

5 years ago Also visit memref element type in AsmPrinter
Geoffrey Martin-Noble [Fri, 17 May 2019 22:23:44 +0000 (15:23 -0700)]
Also visit memref element type in AsmPrinter

--

PiperOrigin-RevId: 248797935

5 years ago Enable EDSC API test running through lit
Alex Zinenko [Fri, 17 May 2019 22:03:39 +0000 (15:03 -0700)]
Enable EDSC API test running through lit

    EDSC subsystem contains an API test which is a .cpp file calling the API in
    question and producing IR.  This IR is further checked using FileCheck and
    should plug into lit.  Provide a CMakeLists.txt to build the test and modify
    the lit configuration to process the source file.

--

PiperOrigin-RevId: 248794443

5 years ago Allow for the case where ShapedType is a MemRef in fixed point math kernel utils
Geoffrey Martin-Noble [Fri, 17 May 2019 21:32:25 +0000 (14:32 -0700)]
Allow for the case where ShapedType is a MemRef in fixed point math kernel utils

    MemRef may soon be a subclass of ShapedType.

--

PiperOrigin-RevId: 248788950

5 years ago Refactor Attribute and Type to use 'classof' instead of 'kindof' internally....
River Riddle [Fri, 17 May 2019 15:28:41 +0000 (08:28 -0700)]
Refactor Attribute and Type to use 'classof' instead of 'kindof' internally. If a 'classof' method is not defined, a default implementation will invoke 'kindof' on a derived type. This allows for defining supplementary Attribute/Type classes that expose additional functionality, but do not have a specific kind value. An example of this can be seen in the 'Constant(Float|Index|Int)Ops' that derive from 'ConstantOp'.

--

PiperOrigin-RevId: 248724093

5 years ago Fix use of variables only used in asserts.
MLIR Team [Fri, 17 May 2019 13:04:14 +0000 (06:04 -0700)]
Fix use of variables only used in asserts.
    This otherwise triggers "unused variable" errors in optimized build mode.

--

PiperOrigin-RevId: 248706350

5 years ago Overload arithmetic operators for SDBM expressions
Alex Zinenko [Fri, 17 May 2019 12:40:51 +0000 (05:40 -0700)]
Overload arithmetic operators for SDBM expressions

    Provide an "unsafe" version of the overloaded arithmetic operators for SDBM
    expressions.  These operators expect the operands to be of the right SDBM
    expression subtype and assert if they are not.  They also perform simple
    folding operations as well as some semantically correct operations that
    construct an SDBM expression of a different subtype, e.g., a difference
    expression if the RHS of an operator+ is a negated variable.  These operators
    are scoped in a namespace to allow for a future "safe" version of the operators
    that propagates null expressions to denote the error state when expressions
    have wrong subtypes.

--

PiperOrigin-RevId: 248704153

5 years ago Implement SDBM and conversion between SDBM and lists of SDBMExpr
Alex Zinenko [Fri, 17 May 2019 12:25:07 +0000 (05:25 -0700)]
Implement SDBM and conversion between SDBM and lists of SDBMExpr

    Implement the storage class for striped difference-bound matrices (SDBM) as a
    container with a difference bounds matrix and a list of stripe expressions.  An
    SDBM defines an integer set.  Provide conversion mechanisms between lists of
    SDBM expressions treated as equalities with zero or less-than-or-equal
    inequalities with zero.

--

PiperOrigin-RevId: 248702871

5 years ago LLVM API updates.
MLIR Team [Fri, 17 May 2019 03:08:07 +0000 (20:08 -0700)]
LLVM API updates.

--

PiperOrigin-RevId: 248651086

5 years ago Update cmake dependencies.
Jacques Pienaar [Fri, 17 May 2019 03:02:18 +0000 (20:02 -0700)]
Update cmake dependencies.

--

PiperOrigin-RevId: 248650428

5 years ago Fixes a small bug in computing dependence direction vectors, where equality const...
Andy Davis [Thu, 16 May 2019 23:50:35 +0000 (16:50 -0700)]
Fixes a small bug in computing dependence direction vectors, where equality constraint can be created on the wrong loop IVs when source/sink of the dependence are at different loop depths. Adds unit tests for cases where source/sink of the dependence are at varying loop depths.

--

PiperOrigin-RevId: 248627490

5 years ago Simplify the verification of ExtractElementop.
Geoffrey Martin-Noble [Thu, 16 May 2019 22:18:49 +0000 (15:18 -0700)]
Simplify the verification of ExtractElementop.

    Make it clear that it cares about the aggregate type being a vector or tensor and not just that it has a shape.
    Remove redundant validation from the custom method that is now covered by the tablegen'ed verification

    This is related to making MemRefs a ShapedType as well.

--

PiperOrigin-RevId: 248610443

5 years ago Expand ReturnOp error to include types. NFC.
Jacques Pienaar [Thu, 16 May 2019 21:12:18 +0000 (14:12 -0700)]
Expand ReturnOp error to include types. NFC.

    Found it a bit easier to see what mismatches occurred when invoking passes doesn't match.

--

PiperOrigin-RevId: 248597286

5 years ago Don't fail verifying unranked shapes as being the same as this could be valid...
Jacques Pienaar [Thu, 16 May 2019 19:57:35 +0000 (12:57 -0700)]
Don't fail verifying unranked shapes as being the same as this could be valid at runtime.

    tensor<*xf32> could be a tensor<1xf32> at runtime but this verifyShapeMatch would return failure and say function is invalid.

--

PiperOrigin-RevId: 248583038

5 years ago Unify the 'constantFold' and 'fold' hooks on an operation into just 'fold'. This...
River Riddle [Thu, 16 May 2019 19:51:45 +0000 (12:51 -0700)]
Unify the 'constantFold' and 'fold' hooks on an operation into just 'fold'. This new unified fold hook will take constant attributes as operands, and may return an existing 'Value *' or a constant 'Attribute' when folding. This removes the awkward situation where a simple canonicalization like "sub(x,x)->0" had to be written as a canonicalization pattern as opposed to a fold.

--

PiperOrigin-RevId: 248582024

5 years ago Add linalg.range_intersect conversion to LLVM.
Nicolas Vasilache [Thu, 16 May 2019 18:57:36 +0000 (11:57 -0700)]
Add linalg.range_intersect conversion to LLVM.

    This CL adds lowering for linalg.range_intersect into LLVM by computing:
      * new_min <- max (range1.min, range2.min)
      * new_max <- min (range1.max, range2.max)
      * new_step <- range1.step * range2.step

--

PiperOrigin-RevId: 248571810

5 years ago Add a linalg.range_intersect op.
Nicolas Vasilache [Thu, 16 May 2019 15:15:10 +0000 (08:15 -0700)]
Add a linalg.range_intersect op.

    This CL adds an operation whose purpose is to encode boundary conditions directly in the view type. In particular, full/partial tile distinction can
    occur at the level of metadata only.
    This CL also adopts a Linalg_Op pattern that is similar to Std_Op.

--

PiperOrigin-RevId: 248529469

5 years ago Rename VectorOrTensorType to ShapedType
Geoffrey Martin-Noble [Thu, 16 May 2019 07:12:45 +0000 (00:12 -0700)]
Rename VectorOrTensorType to ShapedType

    This is in preparation for making it also support/be a parent class of MemRefType. MemRefs have similar shape/rank/element semantics and it would be useful to be able to use these same utilities for them.

    This CL should not change any semantics and only change variables, types, string literals, and comments. In follow-up CLs I will prepare all callers to handle MemRef types or remove their dependence on ShapedType.

    Discussion/Rationale in https://groups.google.com/a/tensorflow.org/forum/#!topic/mlir/cHLoyfGu8y8

--

PiperOrigin-RevId: 248476449

5 years ago Store the child function analysis maps of a ModuleAnalysisManager by unique_ptr...
River Riddle [Thu, 16 May 2019 03:20:11 +0000 (20:20 -0700)]
Store the child function analysis maps of a ModuleAnalysisManager by unique_ptr instead of by-value.

--

PiperOrigin-RevId: 248456926

5 years ago Add a new tutorial document that details how to define Dialect Attributes and...
River Riddle [Wed, 15 May 2019 22:24:20 +0000 (15:24 -0700)]
Add a new tutorial document that details how to define Dialect Attributes and Types.

--

PiperOrigin-RevId: 248417063

5 years ago Upstreaming Quantizer tool (part 2).
Stella Laurenzo [Wed, 15 May 2019 22:04:20 +0000 (15:04 -0700)]
Upstreaming Quantizer tool (part 2).

    This adds some additional core types and utilities, notably the constraint analysis graph (CAG) structures, associated metadata and configuration policy object base class.

    The CAG is not particularly memory efficient as it stands now. I had started some work to turn it into a form that could be better managed by a bump pointer allocator but abandoned that for now in favor of having something that does semantically what I was going for as a starting point.

--

PiperOrigin-RevId: 248413133

5 years ago Fixed Attributes.h comment typo from vecctor to vector
Rob Suderman [Wed, 15 May 2019 18:18:18 +0000 (11:18 -0700)]
Fixed Attributes.h comment typo from vecctor to vector

--

PiperOrigin-RevId: 248369005

5 years ago Cleanup linalg integration test
Nicolas Vasilache [Wed, 15 May 2019 16:26:27 +0000 (09:26 -0700)]
Cleanup linalg integration test

    This CL performs post-commit cleanups.
    It adds the ability to specify which shared libraries to load dynamically in ExecutionEngine. The linalg integration test is updated to use a shared library.
    Additional minor cleanups related to LLVM lowering of Linalg are also included.

--

PiperOrigin-RevId: 248346589

5 years ago Add support for parsing/printing dialect defined attributes. This also adds suppo...
River Riddle [Wed, 15 May 2019 16:10:52 +0000 (09:10 -0700)]
Add support for parsing/printing dialect defined attributes. This also adds support for a pretty syntax for dialects attributes that is synonymous with the pretty syntax for dialect types. This cl also adds a new attribute 'OpaqueAttr' that allows for roundtripping attributes attached to unregistered dialects.

    Dialect attributes have the following syntax:
       dialect-attribute  ::= `#` dialect-namespace `<` `"` attr-data `"` `>`
       dialect-attribute  ::= `#` alias-name pretty-dialect-sym-body?

--

PiperOrigin-RevId: 248344416

5 years ago Remove some extraneous const qualifiers on Type, and 0b1 -> 1 in tblgen files...
Chris Lattner [Wed, 15 May 2019 14:54:28 +0000 (07:54 -0700)]
Remove some extraneous const qualifiers on Type, and 0b1 -> 1 in tblgen files. (NFC)

--

PiperOrigin-RevId: 248332674

5 years ago Make Linalg tiling a FunctionPass instead of a ModulePass - NFC
Nicolas Vasilache [Wed, 15 May 2019 07:53:01 +0000 (00:53 -0700)]
Make Linalg tiling a FunctionPass instead of a ModulePass - NFC

--

PiperOrigin-RevId: 248286354

5 years ago Add a new document detailing the diagnostics infrastructure.
River Riddle [Wed, 15 May 2019 06:01:35 +0000 (23:01 -0700)]
Add a new document detailing the diagnostics infrastructure.

--

PiperOrigin-RevId: 248275851

5 years ago Start to introduce the "Quantizer" tool, which is responsible for transforming...
Stella Laurenzo [Wed, 15 May 2019 02:50:24 +0000 (19:50 -0700)]
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

5 years ago Add support for a Linalg base op class
Nicolas Vasilache [Wed, 15 May 2019 02:37:48 +0000 (19:37 -0700)]
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

5 years ago Remove unnecessary C++ specifier in CPP files. NFC.
Jacques Pienaar [Tue, 14 May 2019 22:03:48 +0000 (15:03 -0700)]
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

5 years ago Add an AffineExpr matcher
Nicolas Vasilache [Tue, 14 May 2019 19:21:42 +0000 (12:21 -0700)]
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

5 years ago Move Quantization -> Dialect/QuantOps, FxpMathOps -> Dialect/FxpMathOps.
Stella Laurenzo [Tue, 14 May 2019 18:03:55 +0000 (11:03 -0700)]
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

5 years ago When converting a location to an SMLoc, advance to the first non-whitespace if...
River Riddle [Tue, 14 May 2019 16:29:30 +0000 (09:29 -0700)]
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

5 years ago [ODS] Add definition for TypeAttr
Lei Zhang [Tue, 14 May 2019 16:08:41 +0000 (09:08 -0700)]
[ODS] Add definition for TypeAttr

--

PiperOrigin-RevId: 248147938

5 years ago Move specification of print, parse and verify to Std_Op base.
Jacques Pienaar [Tue, 14 May 2019 15:27:32 +0000 (08:27 -0700)]
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

5 years ago Add initial support to the SourceMgrDiagnosticHandler for printing call stacks.
River Riddle [Tue, 14 May 2019 05:24:48 +0000 (22:24 -0700)]
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

5 years ago Fix lingering sign compare warnings in exposed by "ninja check-mlir".
Stella Laurenzo [Tue, 14 May 2019 01:10:48 +0000 (18:10 -0700)]
Fix lingering sign compare warnings in exposed by "ninja check-mlir".

--

PiperOrigin-RevId: 248050178

5 years ago Add a linalg.dim
Nicolas Vasilache [Mon, 13 May 2019 21:59:55 +0000 (14:59 -0700)]
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

5 years ago Refactor NameLoc so that it also holds a child location. This removes the awkward...
River Riddle [Mon, 13 May 2019 21:45:48 +0000 (14:45 -0700)]
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

5 years ago Update "Table-driven Op Definition Specification" doc
Lei Zhang [Mon, 13 May 2019 21:39:27 +0000 (14:39 -0700)]
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