platform/upstream/llvm.git
5 years ago [TableGen] Refine OpTrait classes and defs to be consistent
Lei Zhang [Wed, 24 Apr 2019 17:53:12 +0000 (10:53 -0700)]
[TableGen] Refine OpTrait classes and defs to be consistent

--

PiperOrigin-RevId: 245075421

5 years ago Introduce functionality for defining region ancestor relation
Alex Zinenko [Wed, 24 Apr 2019 16:24:57 +0000 (09:24 -0700)]
Introduce functionality for defining region ancestor relation

    Add member functions for Regions to query if another Region is a ancestor.  The
    implementation is naive and traverses all parent regions performing one-to-one
    comparisons.  As a side effect, this introduces `getContainingRegion` function
    for Operations and Values to return the Region in which they are defined, and
    for Regions to return the "parent" region if any.

--

PiperOrigin-RevId: 245057980

5 years ago Add MultiResultTraitBase
Lei Zhang [Wed, 24 Apr 2019 15:51:08 +0000 (08:51 -0700)]
Add MultiResultTraitBase

    Similar to MultiOperandTraitBase, this can simply the implementation of
    NResults, AtLeastNResults, and VariadicResults.

--

PiperOrigin-RevId: 245052333

5 years ago Fix flaky Linalg roundtrip test. This removes an invalid "%s" from the second...
River Riddle [Wed, 24 Apr 2019 00:02:06 +0000 (17:02 -0700)]
Fix flaky Linalg roundtrip test. This removes an invalid "%s" from the second mlir-opt command.

--

PiperOrigin-RevId: 244953230

5 years ago Use -force_load instead of -all_load on MacOS
Mehdi Amini [Tue, 23 Apr 2019 23:39:15 +0000 (16:39 -0700)]
Use -force_load instead of -all_load on MacOS

    The -all_load flag will apply to all future libraries added on the command line,
    while the -force_load flag only applies to the next library. Using the latter
    allows to selectively force load the specific libraries we want.

--

PiperOrigin-RevId: 244949770

5 years ago Rename isa_nonnull to isa_and_nonnull to match the upstream llvm name.
River Riddle [Tue, 23 Apr 2019 21:38:26 +0000 (14:38 -0700)]
Rename isa_nonnull to isa_and_nonnull to match the upstream llvm name.

--

PiperOrigin-RevId: 244928036

5 years ago [Linalg] Add basic linalg ops
Nicolas Vasilache [Tue, 23 Apr 2019 20:21:40 +0000 (13:21 -0700)]
[Linalg] Add basic linalg ops

    This CL adds linalg.dot, linalg.matvec and linalg.matmul ops with the proper roundtripping test. These are the first LinalgOp that operate on views and that will lower to library calls.
    Linalg ops exhibit some common properties and behavior that are modeled with Traits.

    A LinalgOp is defined as a generic Op that operates on input and output views (passed as operands) and has the following properties:
    1. a number of input and outputs captured by the `NInputsAndOutputs` trait.
    2. a list of ranks for each operand captured by the `ViewRanks` trait.
    3. a set of parallel, reduction and windowing loops captured by `NLoopTypes` trait.

    These represent are a first set of generic properties that will enable the definition of generic linear algebra operations and the properties necessary for upcoming transformations.

--

PiperOrigin-RevId: 244912754

5 years ago Minor typo in integer type definition.
MLIR Team [Tue, 23 Apr 2019 14:58:03 +0000 (07:58 -0700)]
Minor typo in integer type definition.

--

PiperOrigin-RevId: 244854008

5 years ago Factor out thread-safe uniqu'ing backed by vector in MLIRcontext
Alex Zinenko [Tue, 23 Apr 2019 09:37:07 +0000 (02:37 -0700)]
Factor out thread-safe uniqu'ing backed by vector in MLIRcontext

    Extract common code from getAffineSymbolExpr and getAffineConstantExpr into a
    utility function safeGetOrCreate, similarly to the existing overloads for sets
    and maps.  The position in the vector is used as indexing key.  NFC.

--

PiperOrigin-RevId: 244820859

5 years ago ExecutionEngine: update to reflect LLVM API changes
Alex Zinenko [Tue, 23 Apr 2019 09:31:59 +0000 (02:31 -0700)]
ExecutionEngine: update to reflect LLVM API changes

    LLVM Orc JIT changed the API for DynamicLibrarySearchGenerator::
    GetForCurrentProcess to only take one value of the DataLayout that it actually
    uses instead of the whole data layout.  Update MLIR ExecutionEngine call to
    this function accordingly.

--

PiperOrigin-RevId: 244820235

5 years ago Fix unused variable warning in opt build
Smit Hinsu [Tue, 23 Apr 2019 07:50:15 +0000 (00:50 -0700)]
Fix unused variable warning in opt build

    TESTED with existing tests

--

PiperOrigin-RevId: 244808731

5 years ago Implement lowering of quant.dcast to the fxpmathops and standard dialect.
Stella Laurenzo [Tue, 23 Apr 2019 00:35:38 +0000 (17:35 -0700)]
Implement lowering of quant.dcast to the fxpmathops and standard dialect.

    Note that I broke this out as a separate pass because intermediate transformations often produce qcast/dcast ops that are integral to the transformation, and it is typical to want to lower any remaining, unmatched casts at the end of quantization. If this flexibility ends up not being needed, they can be collapsed into the same pass. This is included in the same cpp file because all of the math ops will need to defer to emitting quantize/dequantize logic for cases that they cannot be fully lowered to fixed-point math.

    Also, the new convertistof op needs to be evaluated for inclusion in StandardOps.

--

PiperOrigin-RevId: 244768679

5 years ago Apply patterns repeatly if the function is modified
Feng Liu [Mon, 22 Apr 2019 23:06:09 +0000 (16:06 -0700)]
Apply patterns repeatly if the function is modified

    During the pattern rewrite, if the function is changed, i.e. ops created,
    deleted or swapped, the pattern rewriter needs to re-scan the function entirely
    and apply the patterns again, so the patterns whose root ops have been popped
    out from the working list nor an immediate users of the changed ops can be
    reconsidered.

    A command line flag is added to set the max number of iterations rescanning the
    function for pattern match. If the rewrite doesn' converge after this number,
    this compiling will continue and the result can be sub-optimal.

    One unit test is updated because this change fixed the missing optimization opportunities.

--

PiperOrigin-RevId: 244754190

5 years ago [TableGen] Clean up comments regarding op and result
Lei Zhang [Mon, 22 Apr 2019 21:56:54 +0000 (14:56 -0700)]
[TableGen] Clean up comments regarding op and result

    An op can have multiple results. Being explicit that we are binding to the
    whole op instead of one of the results. A way to bind to a specific result
    is yet to come.

--

PiperOrigin-RevId: 244741137

5 years ago [TableGen] Unify cOp and tAttr into NativeCodeCall
Lei Zhang [Mon, 22 Apr 2019 21:13:45 +0000 (14:13 -0700)]
[TableGen] Unify cOp and tAttr into NativeCodeCall

    Both cOp and tAttr were used to perform some native C++ code expression.
    Unifying them simplifies the concepts and reduces cognitive burden.

--

PiperOrigin-RevId: 244731946

5 years ago [TableGen] Capture bound source ops in PatternState
Lei Zhang [Mon, 22 Apr 2019 20:40:30 +0000 (13:40 -0700)]
[TableGen] Capture bound source ops in PatternState

    This allows accessing those bound source ops in result patterns, which can be
    useful for invoking native C++ op creation.

    We bind the op entirely here because ops can have multiple results. Design a
    approach to bind to a specific result is not the concern of this commit.

--

PiperOrigin-RevId: 244724750

5 years ago Update lib path in whole_archive_link.
Jacques Pienaar [Sat, 20 Apr 2019 17:45:59 +0000 (10:45 -0700)]
Update lib path in whole_archive_link.

    The added library path is now specified explicitly wrt top-level build directory.

--

PiperOrigin-RevId: 244507187

5 years ago Use StringRef::drop_while() to simplify a while loop
Lei Zhang [Sat, 20 Apr 2019 11:05:38 +0000 (04:05 -0700)]
Use StringRef::drop_while() to simplify a while loop

--

PiperOrigin-RevId: 244488612

5 years ago Add references to the EuroLLVM talks in the README
Mehdi Amini [Fri, 19 Apr 2019 22:26:52 +0000 (15:26 -0700)]
Add references to the EuroLLVM talks in the README

--

PiperOrigin-RevId: 244433092

5 years ago Simplify and enable pretty-parsing/printing of the uniform quantized types.
Stella Laurenzo [Fri, 19 Apr 2019 21:41:31 +0000 (14:41 -0700)]
Simplify and enable pretty-parsing/printing of the uniform quantized types.

    The per-layer format is now like:
      !quant.uniform<i8<-8:7>:f32, 9.987200e-01:127>
    and per-axis is:
      !quant.uniform<i8:f32:1, {2.0e+2,0.99872:120}>

    I used the following sed script to update the unit tests (invoked with commands like `sed -i -r -f fix_quant.sed $(find . -name '*.mlir')`).
    ---
    # Per-layer
    s|\!quant<"uniform\[([iu][0-9]+):([fb]+[0-9]+)\]\{([^\}]+)\}\s*">|!quant.uniform<\1:\2, \3>|g
    s|\!quant<"uniform\[([iu][0-9]+)\(([^\)]+)\):([fb]+[0-9]+)\]\{([^\}]+)\}\s*">|!quant.uniform<\1<\2>:\3, \4>|g

    # Per-axis
    s|\!quant<"uniform\[([iu][0-9]+):([fb]+[0-9]+)(:[0-9]+)?\]\{([^\}]+)\}\s*">|!quant.uniform<\1:\2\3, {\4}>|g
    s|\!quant<"uniform\[([iu][0-9]+)\(([^\)]+)\):([fb]+[0-9]+)(:[0-9]+)?\]\{([^\}]+)\}\s*">|!quant.uniform<\1<\2>:\3\4, {\5}>|g
    ---
    I fixed up the one file of error cases manually.
    Since this is a one time syntax fix, I am not persisting the script anywhere.

--

PiperOrigin-RevId: 244425331

5 years ago [Linalg] Add a slice op
Nicolas Vasilache [Fri, 19 Apr 2019 19:55:34 +0000 (12:55 -0700)]
[Linalg] Add a slice op

    This CL adds a linalg.slice op with the proper roundtripping test.
    A slice op allows taking subviews that may be rank-reducing (if some indexing is of index type) or not (if all indexings are of linalg.range type).

    A slice must be constructed directly from a base view (no chains of slices may exist in the IR). Helper functions that fold will be provided for construction if/when necessary.

    This also renames base_view to view.

--

PiperOrigin-RevId: 244406827

5 years ago [Linalg] Add a view type with base_view op
Nicolas Vasilache [Fri, 19 Apr 2019 16:56:11 +0000 (09:56 -0700)]
[Linalg] Add a view type with base_view op

    This CL adds a linalg.view<?x?xf32> type and base_view op with the proper roundtripping test. The parser will be improved in a subsequent CL once portions of the mlir::Parser are exposed.

    For now this only supports dynamic views, static views will be introduced at a later time when they are needed.

--

PiperOrigin-RevId: 244374180

5 years ago Implement lowering of element-wise fixed point add and mul to the standard dialect.
Stella Laurenzo [Fri, 19 Apr 2019 00:06:05 +0000 (17:06 -0700)]
Implement lowering of element-wise fixed point add and mul to the standard dialect.

    This also does the following:
      - Removes the poc POT add implementation in favor of a version that does not rescale.
      - Adds a handful of FxpMathOps which are needed (these are for comment and we may want to move them to the StandardOps dialect).
      - Adds a canonicalizer to the StorageCastOp, which removes some cruft once conversions have been done.
      - Adds a couple of predicates to OpBase.

--

PiperOrigin-RevId: 244287706

5 years ago Fix typo (transpose -> reshape).
Guangda Lai [Thu, 18 Apr 2019 22:27:32 +0000 (15:27 -0700)]
Fix typo (transpose -> reshape).

--

PiperOrigin-RevId: 244270801

5 years ago [Linalg] Add a simple buffer type with alloc/dealloc ops
Nicolas Vasilache [Thu, 18 Apr 2019 20:56:18 +0000 (13:56 -0700)]
[Linalg] Add a simple buffer type with alloc/dealloc ops

    This CL adds a linalg.buffer<f32> type and buffer_alloc / buffer_dealloc ops with the proper roundtripping test.

--

PiperOrigin-RevId: 244252306

5 years ago Start a Linalg dialect
Nicolas Vasilache [Thu, 18 Apr 2019 15:25:54 +0000 (08:25 -0700)]
Start a Linalg dialect

    This CL starts implementing a Linalg dialect with the objective of supporting
    optimizing compilation of loops and library calls for a subset of common linear
    algebra operations.

    This CL starts by simply adding a linalg.range type and an operation with the
    proper roundtripping test.

--

PiperOrigin-RevId: 244189468

5 years ago Fix MLIRTableGenTests target_link_libraries typo
Lei Zhang [Thu, 18 Apr 2019 12:10:03 +0000 (05:10 -0700)]
Fix MLIRTableGenTests target_link_libraries typo

--

PiperOrigin-RevId: 244168112

5 years ago [TableGen] Simplify NOperands trait generation
Lei Zhang [Thu, 18 Apr 2019 11:04:57 +0000 (04:04 -0700)]
[TableGen] Simplify NOperands trait generation

--

PiperOrigin-RevId: 244162515

5 years ago Simplify build instructions.
Jacques Pienaar [Thu, 18 Apr 2019 03:56:00 +0000 (20:56 -0700)]
Simplify build instructions.

--

PiperOrigin-RevId: 244120877

5 years ago Use proper C++ casts in Types.h
Nicolas Vasilache [Wed, 17 Apr 2019 21:41:33 +0000 (14:41 -0700)]
Use proper C++ casts in Types.h

    This CL reduces the amount of warning spew when compiling with CMake on Linux.

--

PiperOrigin-RevId: 244070668

5 years ago Use proper C++ casts in Location.h
Nicolas Vasilache [Wed, 17 Apr 2019 21:38:45 +0000 (14:38 -0700)]
Use proper C++ casts in Location.h

    This CL reduces the amount of warning spew when compiling with CMake on Linux.

--

PiperOrigin-RevId: 244070052

5 years ago Fix LLVM_DEBUG instances
Amit Sabne [Wed, 17 Apr 2019 20:39:41 +0000 (13:39 -0700)]
Fix LLVM_DEBUG instances

--

PiperOrigin-RevId: 244058051

5 years ago Loop invariant code motion.
Amit Sabne [Wed, 17 Apr 2019 19:18:37 +0000 (12:18 -0700)]
Loop invariant code motion.

--

PiperOrigin-RevId: 244043679

5 years ago Move QuantTypes out of QuantOps to match the file structures of other dialects
Feng Liu [Wed, 17 Apr 2019 15:31:39 +0000 (08:31 -0700)]
Move QuantTypes out of QuantOps to match the file structures of other dialects

    This CL also moved the UniformSupport.cpp and FakeQuantSupport.cpp into utils because they are not really the core of the IR.

--

PiperOrigin-RevId: 244001666

5 years ago Bring naming of some quant ops in alignment with docs and introduce a few necessa...
Stella Laurenzo [Wed, 17 Apr 2019 01:36:24 +0000 (18:36 -0700)]
Bring naming of some quant ops in alignment with docs and introduce a few necessary additional ops (stats_ref, stats, coupled_ref).

--

PiperOrigin-RevId: 243919195

5 years ago Add NewLine for Attribute dump()
MLIR Team [Tue, 16 Apr 2019 23:47:41 +0000 (16:47 -0700)]
Add NewLine for Attribute dump()

--

PiperOrigin-RevId: 243904869

5 years ago Add DebugStringHelper, which makes it easier to get a string from a dump method
Yanan Cao [Tue, 16 Apr 2019 23:12:00 +0000 (16:12 -0700)]
Add DebugStringHelper, which makes it easier to get a string from a dump method

--

PiperOrigin-RevId: 243899072

5 years ago Fix SliceAnalysis comment
Nicolas Vasilache [Tue, 16 Apr 2019 21:11:25 +0000 (14:11 -0700)]
Fix SliceAnalysis comment

    The description of the backward slice analysis behavior describes what would happen when creating a backward slice from node 9, not 8.

--

PiperOrigin-RevId: 243876599

5 years ago [TableGen] Fix builder for ops with one variadic input and SameValueType
Lei Zhang [Tue, 16 Apr 2019 20:20:38 +0000 (13:20 -0700)]
[TableGen] Fix builder for ops with one variadic input and SameValueType

    For ops with the SameValueType trait, we generate a builder without requiring
    result type; we get the result type from the operand. However, if the operand
    is variadic, we need to index into the first value in the pack.

--

PiperOrigin-RevId: 243866647

5 years ago Abort via report_fatal_error if dialect has been registered.
Jacques Pienaar [Mon, 15 Apr 2019 23:32:00 +0000 (16:32 -0700)]
Abort via report_fatal_error if dialect has been registered.

    Fixes test in opt mode.

    Closes: tensorflow/mlir#17.

--

PiperOrigin-RevId: 243711043

5 years ago TypedTuple: Add support for tuples with type constraints on the elements.
Geoffrey Martin-Noble [Mon, 15 Apr 2019 21:08:41 +0000 (14:08 -0700)]
TypedTuple: Add support for tuples with type constraints on the elements.

--

PiperOrigin-RevId: 243685631

5 years ago [TableGen] Fix support for ops whose names have a leading underscore
Lei Zhang [Mon, 15 Apr 2019 16:13:22 +0000 (09:13 -0700)]
[TableGen] Fix support for ops whose names have a leading underscore

    TensorFlow ops have the convention to use leading underscore to denote
    internal ops.

--

PiperOrigin-RevId: 243627723

5 years ago Expand the pretty dialect type system to support arbitrary punctuation and
Chris Lattner [Sun, 14 Apr 2019 20:41:09 +0000 (13:41 -0700)]
Expand the pretty dialect type system to support arbitrary punctuation and
    other characters within the <>'s now that we can.  This will allow quantized
    types to use the pretty syntax (among others) after a few changes.

--

PiperOrigin-RevId: 243521268

5 years agoFix CHECK-EMPTY directives without trailing colon
Smit Hinsu [Fri, 12 Apr 2019 17:31:21 +0000 (10:31 -0700)]
Fix CHECK-EMPTY directives without trailing colon

There are no empty lines in output for three of these directives so removed
them and replaced the remaining one with 'CHECK-NOT:' as otherwise it is
failing with the following error.

error: found 'CHECK-EMPTY' without previous 'CHECK: line

TESTED = n/a
PiperOrigin-RevId: 243288605

5 years ago NFC: Simplify named attribute in TableGen generators
Smit Hinsu [Fri, 12 Apr 2019 17:24:59 +0000 (10:24 -0700)]
NFC: Simplify named attribute in TableGen generators

    Now, op attribute names don't have '.' in their names so the special handling for it
    can be removed. Attributes for functions still have dialect prefix with '.' as separator but TableGen does not deal with functions.

    TESTED with existing unit tests

--

PiperOrigin-RevId: 243287462

5 years ago [TableGen] Allocate `Operator` object on heap in `RecordOperatorMap`
Lei Zhang [Fri, 12 Apr 2019 16:52:11 +0000 (09:52 -0700)]
[TableGen] Allocate `Operator` object on heap in `RecordOperatorMap`

    Iterators for a `llvm::DenseMap` can be invalidated when an insertion occurs.
    In Pattern's `collectBoundArguments()`, we recursively handle all nested DAG
    nodes and grow the the `RecordOperatorMap`, while retaining a reference.
    This can cause the reference to be invalid and the program to behave randomly.
    Allocate each `Operator` object specifically to solve this issue.

    Also, `llvm::DenseMap` is a great way to map pointers to pointers, or map
    other small types to each other. This avoids placing the `Operator` object
    directly into the map.

--

PiperOrigin-RevId: 243281486

5 years ago [TableGen] Use `tgfmt` to format various predicates and rewrite rules
Lei Zhang [Fri, 12 Apr 2019 13:05:49 +0000 (06:05 -0700)]
[TableGen] Use `tgfmt` to format various predicates and rewrite rules

    This CL changes various predicates and rewrite rules to use $-placeholders and
    `tgfmt` as the driver for substitution. This will make the predicates and rewrite
    rules more consistent regarding their arguments and more readable.

--

PiperOrigin-RevId: 243250739

5 years ago [TableGen] Better support for predicate and rewrite rule specification
Lei Zhang [Fri, 12 Apr 2019 12:57:50 +0000 (05:57 -0700)]
[TableGen] Better support for predicate and rewrite rule specification

    Currently predicates are written with positional placeholders `{N}` and rely on
    `formatv` as the engine to do substitution. The problem with this approach is that
    the definitions of those positional placeholders are not consistent; they are
    entirely up to the defining predicate of question. For example, `{0}` in various
    attribute constraints is used to mean the attribute, while it is used to main the
    builder for certain attribute transformations. This can become very confusing.

    This CL introduces `tgfmt` as a new mechanism to better support for predicate and
    rewrite rule specification. Instead of entirely relying on positional placeholders,
    `tgfmt` support both positional and special placeholders. The former is used for
    DAG operands. The latter, including $_builder, $_op, $_self, are used as special
    "hooks" to entities in the context. With this, the predicate and rewrite rules
    specification can be more consistent is more readable.

--

PiperOrigin-RevId: 243249671

5 years ago Update the Rationale's description about signed/unsigned and int/fp types to...
Chris Lattner [Fri, 12 Apr 2019 05:29:21 +0000 (22:29 -0700)]
Update the Rationale's description about signed/unsigned and int/fp types to be more specific about the fact that this only refers to std operations.  Move these sections closer together.

--

PiperOrigin-RevId: 243204948

5 years ago Update documentation for the DialectOpconversion class: overriding `match()`...
Mehdi Amini [Thu, 11 Apr 2019 20:19:46 +0000 (13:19 -0700)]
Update documentation for the DialectOpconversion class: overriding `match()` is optional

    Recently a default implementation for `match()` was provided (cl/242285885), but the class documentation wasn't updated appropriately.

--

PiperOrigin-RevId: 243128738

5 years ago Add missing dependencies for EDSC and linalg libraries
Lei Zhang [Thu, 11 Apr 2019 19:34:50 +0000 (12:34 -0700)]
Add missing dependencies for EDSC and linalg libraries

    This solves the missing "mlir/StandardOps/Ops.h.inc" issue when building
    a fresh checkout on macOS.

--

PiperOrigin-RevId: 243120388

5 years ago Add support for statically shaped and typed tensors
Geoffrey Martin-Noble [Thu, 11 Apr 2019 00:16:19 +0000 (17:16 -0700)]
Add support for statically shaped and typed tensors

--

PiperOrigin-RevId: 242972594

5 years agoUpdate custom rewrite example, which seems to have drifted a bit from the implementation.
Stella Laurenzo [Wed, 10 Apr 2019 23:53:03 +0000 (16:53 -0700)]
Update custom rewrite example, which seems to have drifted a bit from the implementation.

PiperOrigin-RevId: 242968685

5 years ago Update the FxpMathOps to better reflect what is needed to legalize from XLA.
Stella Laurenzo [Wed, 10 Apr 2019 19:37:45 +0000 (12:37 -0700)]
Update the FxpMathOps to better reflect what is needed to legalize from XLA.

--

PiperOrigin-RevId: 242919924

5 years ago [TableGen] Support naming rewrite rules
Lei Zhang [Wed, 10 Apr 2019 18:37:53 +0000 (11:37 -0700)]
[TableGen] Support naming rewrite rules

--

PiperOrigin-RevId: 242909061

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