Commit Graph

1597 Commits

Author SHA1 Message Date
River Riddle e05eda9d22 Simplify the emission of a few op parser diagnostics. This also adds the ability to stream an attribute into a Diagnostic.
--

PiperOrigin-RevId: 247359911
2019-05-10 19:25:12 -07:00
River Riddle a4b56174bd Move the definitions of AllocOp and DeallocOp to tablegen.
--

PiperOrigin-RevId: 247359472
2019-05-10 19:25:03 -07:00
River Riddle 4bc23a40f4 Add a utility diagnostic handler class, SourceMgrDiagnosticHandler, to interface with llvm::SourceMgr. This lowers the barrier of entry for tools to get rich diagnostic handling when using llvm::SourceMgr.
--

PiperOrigin-RevId: 247358610
2019-05-10 19:24:54 -07:00
River Riddle 334d57ef41 Add an AttrBase class to simplify defining derived Attributes. This class serves the same purpose as TypeBase, and thus the duplicated functionality has been split into a new support class 'StorageUserBase'.
--

PiperOrigin-RevId: 247358373
2019-05-10 19:24:46 -07:00
River Riddle 8ad3320557 Rename DialectTypeRegistry to DialectSymbolRegistry in preparation for dialect defined attributes.
--

PiperOrigin-RevId: 247357665
2019-05-10 19:24:38 -07:00
River Riddle e088f93f0d Simplify the parser/printer of ConstantOp now that all attributes have types. This has the added benefit of removing type redundancy from the pretty form. As a consequence, IntegerAttr/FloatAttr will now always print the type even if it is i64/f64.
--

PiperOrigin-RevId: 247295828
2019-05-10 19:24:30 -07:00
MLIR Team b4684e229b Add utility to accept any tensor type.
--

PiperOrigin-RevId: 247264423
2019-05-10 19:24:22 -07:00
Jacques Pienaar a1b24a0e08 Verify that attribute type and constant op return type matches.
--

PiperOrigin-RevId: 247263129
2019-05-10 19:24:14 -07:00
River Riddle ce4fa9f652 Add support for using the new diagnostics infrastructure in the parser. This also adds support for streaming in ranges(e.g. ArrayRef) into a diagnostic with an optional element delimiter.
--

PiperOrigin-RevId: 247239436
2019-05-10 19:24:05 -07:00
River Riddle fa6eb9bfaf Add a new ClassID utility class that allows for generating unique identifiers for class types. This replaces the duplicated functionality of AnalysisID/PassID/etc.
--

PiperOrigin-RevId: 247237835
2019-05-10 19:23:57 -07:00
Lei Zhang 323e1bf7f8 Inline a string used in lambda function to fix capture error
The string was referenced but not captured in the lambda, which causes
    a failure when compiling with MSVC.

    This issue was discovered by @loic-joly-sonarsource with a proposed fix
    in https://github.com/tensorflow/mlir/pull/22.

--

PiperOrigin-RevId: 247085897
2019-05-10 19:23:49 -07:00
Thomas Joerg cffed537a1 Fix a few typos in the Toy tutorial documentation
--

PiperOrigin-RevId: 247047009
2019-05-10 19:23:40 -07:00
Thomas Joerg b28bafd74f Add operations to produce block/index ids and dimensions to the gpu dialect.
--

PiperOrigin-RevId: 246976227
2019-05-10 19:23:32 -07:00
River Riddle b7dc252683 NFC: Make ParseResult public and update the OpAsmParser(and thus all of the custom operation parsers) to use it instead of bool.
--

PiperOrigin-RevId: 246955523
2019-05-10 19:23:24 -07:00
River Riddle 6ccf90147c NFC: Convert the ParseResult enum into a simple struct wrapper around LogicalResult. This allows for using the existing infrastructure for LogicalResult while retaining the ability to easily chain together parse rules. This will also simplify the transition of the parser to use the new diagnostics infrastructure.
--

PiperOrigin-RevId: 246955372
2019-05-10 19:23:15 -07:00
River Riddle ae9f4f2157 Simplify the emission of various diagnostics created in Analysis/ and Transforms/ by using the new diagnostic infrastructure.
--

PiperOrigin-RevId: 246955332
2019-05-10 19:23:07 -07:00
Geoffrey Martin-Noble c34386e3e5 CmpFOp. Add float comparison op
This closely mirrors the llvm fcmp instruction, defining 16 different predicates

    Constant folding is unsupported for NaN and Inf because there's no way to represent those as constants at the moment

--

PiperOrigin-RevId: 246932358
2019-05-10 19:22:58 -07:00
Geoffrey Martin-Noble c4891378e2 Add split-input-file to constant fold test
Better to keep tests as separate as possible

--

PiperOrigin-RevId: 246900564
2019-05-10 19:22:50 -07:00
River Riddle 983e0eea95 Simplify several usages of attributes now that they always have a type and, transitively, access to the context.
This also fixes a bug where FunctionAttrs were not being remapped for function and function argument attributes.

--

PiperOrigin-RevId: 246876924
2019-05-10 19:22:41 -07:00
River Riddle 94afc426e2 Refactor the support for AffineMap and IntegerSet aliases in the parser into more general support for attribute aliases.
`#` alias `=` attribute-value

    This also allows for dialects to define aliases for attributes in the AsmPrinter. The printer supports two types of attribute aliases, 'direct' and 'kind'.

    * Direct aliases are synonymous with the current support for type aliases, i.e. this maps an alias to a specific instance of an attribute.

    // A direct alias ("foo_str") for the string attribute "foo".
    #foo_str = "foo"

    * Kind aliases generates unique names for all instances of a given attribute kind. The generated aliases are of the form: `alias[0-9]+`.

    // A kind alias ("strattr") for all string attributes could generate.
    #strattr0 = "foo"
    #strattr1 = "bar"
    ...
    #strattrN = "baz"

--

PiperOrigin-RevId: 246851916
2019-05-10 19:22:32 -07:00
River Riddle 3df7a80265 Simplify the emission of various diagnostics emitted by the different dialects (Affine/Standard/etc.) by using the new stream interface instead of Twine.
--

PiperOrigin-RevId: 246842016
2019-05-10 19:22:24 -07:00
Mehdi Amini fb8a0fc25e Fix MacOS build: static constexpr must be defined
This can be removed in C++17.

--

PiperOrigin-RevId: 246827022
2019-05-06 08:30:26 -07:00
MLIR Team 535a845011 Fix the indentation of CHECKs in test/GPU/ops.mlir.
--

PiperOrigin-RevId: 246809906
2019-05-06 08:30:17 -07:00
MLIR Team 465df0d916 Add the "gpu.launch_func" op to the GPU dialect.
The idea is to lower `gpu.launch` operations into `gpu.launch_func` operations by outlining the kernel body into a function, which is closer to the NVVM model.

--

PiperOrigin-RevId: 246806890
2019-05-06 08:30:07 -07:00
Alex Zinenko b7b75cf74c GPU dialect: introduce custom syntax for gpu.launch
This syntax removes boilerplate and verbose list of region arguments in the
    header of the entry block.  It groups operands into segments related to GPU
    blocks, GPU threads as well as the operands that are forwarded to the kernel.
    The two former segments are also used to give names to the region arguments
    that are used for GPU blocks and threads inside the kernel body region.

--

PiperOrigin-RevId: 246792329
2019-05-06 08:29:57 -07:00
Alex Zinenko d3380a504f Change syntax of regions in the generic form of operations
The generic form of operations currently supports optional regions to be
    located after the operation type.  As we are going to add a type to each
    region in a leading position in the region syntax, similarly to functions, it
    becomes ambiguous to have regions immediately after the operation type.  Put
    regions between operands the optional list of successors in the generic
    operation syntax and wrap them in parentheses.  The effect on the exisitng IR
    syntax is minimal since only three operations (`affine.for`, `affine.if` and
    `gpu.kernel`) currently use regions.

--

PiperOrigin-RevId: 246787087
2019-05-06 08:29:48 -07:00
Mehdi Amini e2e89f5c83 Specify Regions in LangRef
Region is the generalization of a function body (a list of blocks forming a CFG) to be allowed to be enclosed inside any operation. This nesting of IR is already leveraged in the affine dialect to support `affine.for`, `affine.if`, and `gpu.launch` operations.

--

PiperOrigin-RevId: 246766830
2019-05-06 08:29:38 -07:00
River Riddle 3f27c60688 Add a static utility to FloatAttr for converting an APFloat to double.
--

PiperOrigin-RevId: 246671765
2019-05-06 08:29:28 -07:00
Jacques Pienaar 7fea30b9dd Remove redundant ;
--

PiperOrigin-RevId: 246664861
2019-05-06 08:29:18 -07:00
River Riddle 4ea887be41 Namespaceify a few explicit template specializations to appease errors caused by a bug in gcc versions < 7.0.
(https://gcc.gnu.org/bugzilla/show_bug.cgi?id=56480)

--

PiperOrigin-RevId: 246664463
2019-05-06 08:29:09 -07:00
Jacques Pienaar dcab80115f Add SameOperandsAndResultElementType trait.
This trait only works for tensor and vector types at the moment, verifying that the element type of an op with only tensor and vector types match. Added a unit test for it as there is no op currently in core that uses this trait.

--

PiperOrigin-RevId: 246661697
2019-05-06 08:28:59 -07:00
River Riddle 3b930b0d70 Add explicit friendship with Operation to each derived op class to ensure access to the inherited protected constructor of `Op`. Some compiler versions have different rules for the visibility of inherited constructors.
--

PiperOrigin-RevId: 246661686
2019-05-06 08:28:50 -07:00
Ashwin Murthy b52d6e9148 [TableGen] Couple of small updates to OpBase
Added a definition for the newly added None type.
    Fix TCopVTEtAreSameAt to be a Predicate rather than a PredOpTrait. This makes it more of a primitive and allows flexible composition.

--

PiperOrigin-RevId: 246631975
2019-05-06 08:28:40 -07:00
Mehdi Amini cad369b667 Minor fixes (formatting/typos) to the DeveloperGuide
--

PiperOrigin-RevId: 246621047
2019-05-06 08:28:30 -07:00
Jacques Pienaar 2fe8ae4f6c Fix up some mixed sign warnings.
--

PiperOrigin-RevId: 246614498
2019-05-06 08:28:20 -07:00
Mehdi Amini 4db06d84d8 Automated rollback of changelist 246610168.
PiperOrigin-RevId: 246610394
2019-05-06 08:28:11 -07:00
Mehdi Amini 00dea78fdc Add a section in the DeveloperGuide about avoiding unsigned integer
--

PiperOrigin-RevId: 246610168
2019-05-06 08:28:01 -07:00
Mehdi Amini 1a2f2d1216 Add a section in the DeveloperGuide for the naming convention of command line options
--

PiperOrigin-RevId: 246610123
2019-05-06 08:27:51 -07:00
Jacques Pienaar 78c13b776e Remove erroneous cast.
--

PiperOrigin-RevId: 246600166
2019-05-06 08:27:42 -07:00
River Riddle b2806e197e Remove the ability to directly print affine structures from the OpAsmPrinter. These should go through attributes like most everything else.
--

PiperOrigin-RevId: 246589682
2019-05-06 08:27:32 -07:00
Jacques Pienaar 9233df9045 Fix -Wmismatched-tags warning.
--

PiperOrigin-RevId: 246576348
2019-05-06 08:27:22 -07:00
River Riddle 777e7b4f4f Make the Twine parameter of the current diagnostic emit functions optional. This allows for the ability to exclusively use the new diagnostic interface without breaking all of the existing usages. Several diagnostics emitted in lib/IR have been updated to make use of this functionality.
--

PiperOrigin-RevId: 246546044
2019-05-06 08:27:13 -07:00
River Riddle ffa0246bc2 Add an MLIRContext::emitWarning utility method.
--

PiperOrigin-RevId: 246546015
2019-05-06 08:27:03 -07:00
River Riddle baa656352a Add the ability to attach notes to Diagnostic/InFlightDiagnostic.
Notes are a way to add additional context to a diagnostic, but don't really make sense as standalone diagnostics. Moving forward, notes will no longer be able to be constructed directly and must be attached to a parent Diagnostic.

    Notes can be attached via `attachNote`:

      auto diag = ...;
      diag.attachNote() << "This is a note";

--

PiperOrigin-RevId: 246545971
2019-05-06 08:26:54 -07:00
Nicolas Vasilache 258e8d9ce2 Prepend an "affine-" prefix to Affine pass option names - NFC
Trying to activate both LLVM and MLIR passes in mlir-cpu-runner showed name collisions when registering pass names.
    One possible way of disambiguating that should also work across dialects is to prepend the dialect name to the passes that specifically operate on that dialect.

    With this CL, mlir-cpu-runner tests still run when both LLVM and MLIR passes are registered

--

PiperOrigin-RevId: 246539917
2019-05-06 08:26:44 -07:00
River Riddle ff6e7cf558 Introduce a new API for emitting diagnostics with Diagnostic and InFlightDiagnostic.
The Diagnostic class contains all of the information necessary to report a diagnostic to the DiagnosticEngine. It should generally not be constructed directly, and instead used transitively via InFlightDiagnostic. A diagnostic is currently comprised of several different elements:
    * A severity level.
    * A source Location.
    * A list of DiagnosticArguments that help compose and comprise the output message.
      * A DiagnosticArgument represents any value that may be part of the diagnostic, e.g. string, integer, Type, Attribute, etc.
      * Arguments can be added to the diagnostic via the stream(<<) operator.
    * (In a future cl) A list of attached notes.
      * These are in the form of other diagnostics that provide supplemental information to the main diagnostic, but do not have context on their own.

    The InFlightDiagnostic class represents an RAII wrapper around a Diagnostic that is set to be reported with the diagnostic engine. This allows for the user to modify a diagnostic that is inflight. The internally wrapped diagnostic can be reported directly or automatically upon destruction.

    These classes allow for more natural composition of diagnostics by removing the restriction that the message of a diagnostic is comprised of a single Twine. They should also allow for nice incremental improvements to the diagnostics experience in the future, e.g. formatv style diagnostics.

    Simple Example:

    emitError(loc, "integer bitwidth is limited to " + Twine(IntegerType::kMaxWidth) + " bits");
    emitError(loc) << "integer bitwidth is limited to " << IntegerType::kMaxWidth << " bits";

--

PiperOrigin-RevId: 246526439
2019-05-06 08:26:34 -07:00
Alex Zinenko 8c9fbb7eb8 Accept additional conversions in the LLVM lowering
Extend the LLVM lowering class following the original idea of the "bag of
    conversions".  LLVMLowering class is now exposed as and can be derived from.
    It provides hooks for derived classes to inject operation conversions and to
    convert custom types.  It is under responsibility of the caller to make sure
    patterns don't overlap.

    Update the lowering from the Linalg dialect to the LLVM IR dialect to use this
    new approach.

--

PiperOrigin-RevId: 246492919
2019-05-06 08:26:24 -07:00
MLIR Team 9c66417569 Fix bug in LoopTiling where a loop with trip count of 1 caused a division by zero
--

PiperOrigin-RevId: 246480710
2019-05-06 08:26:15 -07:00
Jacques Pienaar 1e217ccacd Start developer guide doc.
This is just a bare skeleton to start populating developer policies and
    guidelines. LLVM side this would be multiple separate documents (coding
    standard & programmer's manual) but starting with one and we can break it out
    into multiple if the content so dictates.

--

PiperOrigin-RevId: 246433346
2019-05-06 08:26:06 -07:00
Stella Laurenzo c720dd1ab8 Add missing SameValueType trait to a couple of quantization ops.
--

PiperOrigin-RevId: 246422412
2019-05-06 08:25:57 -07:00
Lei Zhang 752ce8e0c8 Be consistent w.r.t. struct/class in forward declaration
This addresses compiler warnings.

--

PiperOrigin-RevId: 246386939
2019-05-06 08:25:47 -07:00
River Riddle b91aea1516 NFC: Move AttributeStorage and AttributeUniquer into a new header AttributeSupport.h in preparation for them to be used by dialect defined attributes.
--

PiperOrigin-RevId: 246385860
2019-05-06 08:25:37 -07:00
Stella Laurenzo 13caf8b310 Add FxpMathOps real_matmul and real_matmul_bias.
Also:
      - cleans up some operand names for consistency
      - remove the broadcast_dims attribute as it isn't used
      - adds an IsNullAttr predicate which is needed to match optional clamp attributes on these kind of ops (needed to simplify some out of tree transforms on the new matmul op)

--

PiperOrigin-RevId: 246370576
2019-05-06 08:25:27 -07:00
Lei Zhang 2d5e7f53cc [TableGen] Add the `TCopVTEtAreSameAt` PredOpTrait
This trait is used for specifying operands at the indices from a given
    list are with the same element type.

--

PiperOrigin-RevId: 246364735
2019-05-06 08:25:18 -07:00
Jacques Pienaar b9b59ef9cd [ODS] Define ConstantOp.
Add ConstantOp's Op Definition Spec. Currently we don't use convertFromStorage in the generated patterns and so needed to add a few casts to support patterns restricted to ElementsAttrs and to compensate for old rules where we defined ConstantOp to have a ElementsAttr to simplify writing the pattern.

--

PiperOrigin-RevId: 246361555
2019-05-06 08:25:08 -07:00
Nicolas Vasilache 8adc3f0ec7 Add a primitive linalg-lower-to-llvm-dialect pass
This CL builds upon ftynse@'s Linalg dialect conversion (in examples/Linalg/Linalg1) and updates it to support buffers and the fully composed form of view and slice operations.
    A new BufferSizeOp is introduced for the purpose of extracting the size information from a buffer.
    This will be useful in a followup CL for an end-to-end LLVM execution path where mlir-cpu-runner will allocate a buffer.

--

PiperOrigin-RevId: 246358593
2019-05-06 08:24:59 -07:00
River Riddle 920b8a9bda Simplify TypeUniquer/AttributeUniquer to not require multiple overloads when constructing a new storage.
--

PiperOrigin-RevId: 246356767
2019-05-06 08:24:50 -07:00
Jacques Pienaar dd726ea99d Update to address missing cmake target & qualify make_pair.
--

PiperOrigin-RevId: 246355137
2019-05-06 08:24:41 -07:00
MLIR Team e3be54cd4a Fix a minor formatting issue.
--

PiperOrigin-RevId: 246307329
2019-05-06 08:24:31 -07:00
MLIR Team bedc5af9ae Fix a typo.
--

PiperOrigin-RevId: 246304098
2019-05-06 08:24:21 -07:00
Geoffrey Martin-Noble 45c8245cca Substitute getI64IntegerAttr for the more verbose code it replaces.
--

PiperOrigin-RevId: 246227344
2019-05-06 08:24:12 -07:00
River Riddle b14c4b4ca8 Add support for basic remark diagnostics. This is the minimal functionality needed to separate notes from remarks. It also provides a starting point to start building out better remark infrastructure.
--

PiperOrigin-RevId: 246175216
2019-05-06 08:24:02 -07:00
River Riddle eaf7f6b671 Start sketching out a new diagnostics infrastructure. Create a new class 'DiagnosticEngine' and move the diagnostic handler support and final diagnostic emission from the MLIRContext to it.
--

PiperOrigin-RevId: 246163897
2019-05-06 08:23:53 -07:00
Nicolas Vasilache 21d9dc4f29 [Linalg] Add a primitive tiling pass
This CL adds a primitive tiling pass for Linalg.
    The tiling pass uses the loopToOperandRangesMaps property which should be ideally Tablegen'd and in-class.

    The tiling specification uses 0 as a convention to skip loops that should not be tiled.

    Tiling proceeds in 3 steps, for each op:
    1. Pad tile sizes with 0 to match the number of loops, this simplifies the implementation and avoids affine map manipulations to align dimensions.
    2. Create loop ranges that represent the min/max/step by which to iterate. This should be later complemented by a range intersection to avoid the out-of-bounds case.
    3. Map the loop ranges to view ranges in order to create subviews on which the op can be called.

    Relevant utility and helper functions are added separately that support writing the transformation in a declarative fashion.
    Simplifying assumptions are made for now on the views and the ranges that are constructed
    in the function and are not passed as function arguments. This restriction will be lifted
    in the future.

--

PiperOrigin-RevId: 246124419
2019-05-06 08:23:43 -07:00
River Riddle 007a4acece Remove NumericAttr. Now that all attributes contain a type, this subclass is no longer necessary.
--

PiperOrigin-RevId: 246061024
2019-05-06 08:23:33 -07:00
Stella Laurenzo e402d4330d Fix namespaces on a few pass factory functions.
--

PiperOrigin-RevId: 246035278
2019-05-06 08:23:23 -07:00
River Riddle 17d3acf40c Ensure that every Attribute contains a Type. If an Attribute does not provide a type explicitly, the type is defaulted to NoneType.
--

PiperOrigin-RevId: 246021088
2019-05-06 08:23:14 -07:00
Smit Hinsu 0bd0571e72 Reserve the required capacity to avoid pointer invalidations for translation functions
--

PiperOrigin-RevId: 245992152
2019-05-06 08:23:04 -07:00
River Riddle 0f89ef30b7 Refactor Attribute uniquing to use StorageUniquer instead of being hard coded in the MLIRContext. This allows for attributes to be uniqued similarly to types. This is the second step towards allowing dialects to define attributes.
--

PiperOrigin-RevId: 245974705
2019-05-06 08:22:50 -07:00
Rob Suderman 72ce58e23e ExtractElementsOp asserts for >1 operator however it actually expects
>0 operators.

--

PiperOrigin-RevId: 245966586
2019-05-06 08:22:30 -07:00
Stephan Herhut 5d7231d812 Add transformation of the NVVM dialect to an LLVM module. Only handles
the generation of intrinsics out of NVVM index ops for now.

--

PiperOrigin-RevId: 245933152
2019-05-06 08:22:14 -07:00
Jacques Pienaar 041e961802 Add extraClassDeclaration field for ops.
Simple mechanism to allow specifying arbitrary function declarations. The modelling will not cover all cases so allow a means for users to declare a method function that they will define in their C++ files. The goal is to allow full C++ flexibility as the goal is to cover cases not modelled.

--

PiperOrigin-RevId: 245889819
2019-05-06 08:21:58 -07:00
Stella Laurenzo 9ecf6887d6 Add an "any" quantized type, which contains the underlying type correlation but does not specify any mapping.
Also fixes some comments that were stale after the last syntax upgrade.

--

PiperOrigin-RevId: 245853462
2019-05-06 08:21:42 -07:00
Jacques Pienaar 9fd1957852 Fix opt build failure.
--

PiperOrigin-RevId: 245844236
2019-05-06 08:21:25 -07:00
Jacques Pienaar 3ea13d2db0 Fixup MLIRGPU to mlir-opt in cmake.
--

PiperOrigin-RevId: 245820077
2019-05-06 08:21:09 -07:00
Nicolas Vasilache 56c7a957bf Parsing support for Range, View and Slice operations
This CL implements the previously unsupported parsing for Range, View and Slice operations.
    A pass is introduced to lower to the LLVM.
    Tests are moved out of C++ land and into mlir/test/Examples.
    This allows better fitting within standard developer workflows.

--

PiperOrigin-RevId: 245796600
2019-05-06 08:20:55 -07:00
Nicolas Vasilache c5abd6b6c9 Link MLIRSupport to IR in OSS
The missing dependency breaks linking on Linux.

--

PiperOrigin-RevId: 245773637
2019-05-06 08:20:38 -07:00
Jacques Pienaar 0ea6154b2a Add Dialect in op definition to capture prefix and documentation.
Enables specifying the documentation for dialect along with defining the ops of the dialect. The doc generator will be expanded in follow up to emit the documentation in the autogenerated files. This is precursor to allowing common base for all ops in a dialect.

    All the dialect documentation is super sparse and just added as placeholder.

    I was tempted (and started) to move ConstantOp to be generated too, but this will be easier post adding extra_methods, so deferring until then.

--

PiperOrigin-RevId: 245759984
2019-05-06 08:20:24 -07:00
Alex Zinenko aae8a7446e Start GPU Dialect
Define a new dialect related to GPU kernels.  Currently, it only contains a
    single operation for launching a kernel on a three-dimensional grid of thread
    blocks, following a model similar to that of CUDA.  In particular, the body of
    the kernel contains operations executed by each thread and uses region
    arguments to accept thread and block identifiers (similar to how the loop body
    region accepts the induction value).

--

PiperOrigin-RevId: 245713728
2019-05-06 08:20:08 -07:00
Mehdi Amini 4c74f1bf38 Rename "convert-to-llvmir" to "lower-to-llvm" (NFC)
--

PiperOrigin-RevId: 245649493
2019-05-06 08:19:52 -07:00
Smit Hinsu c9b0540b9c Make identity cast operations with the same operand and result types legal
Instead, fold such operations. This way callers don't need to conditionally create cast operations depending on if a value already has the target type.

    Also, introduce areCastCompatible to allow cast users to verify that the generated op will be valid before creating the operation.

    TESTED with unit tests

--

PiperOrigin-RevId: 245606133
2019-05-06 08:19:37 -07:00
River Riddle 1316db3baa Add support for a NoneType.
none-type ::= `none`

    The `none` type is a unit type, i.e. a type with exactly one possible value, where its value does not have a defined dynamic representation.

--

PiperOrigin-RevId: 245599248
2019-05-06 08:19:20 -07:00
River Riddle a8ef8fa182 Update the wording of a comment in the LangRef now that multi-threading is no longer an anticipated feature.
--

PiperOrigin-RevId: 245586656
2019-05-06 08:19:03 -07:00
Alex Zinenko 54ee709e88 Add LLVM Conversion Tutorial
Add a tutorial document explaining how to define a conversion from the Linalg
    dialect to the LLVM IR dialect, bypassing the Affine dialect.  It defines a
    dynamic representation for a range and a view for the sake of type conversion.
    Operation conversion becomes straightforward given the dynamic representation.
    The code in the tutorial is better structured and better document that what we
    currently have in the example, which will be updated separately.

--

PiperOrigin-RevId: 245498394
2019-05-06 08:18:47 -07:00
Alex Zinenko 9de199676f Implement the conversion between SDBMExpr and AffineExpr
Since SDBM expressions are a subset of affine expressions, they can be
    converted to affine expressions in a straightforward way.  The inverse
    conversion may fail when the affine expression is not an SDBM.  Implement the
    inverse convresion assuming affine expressions are simplified and
    canonicalizied, detect subtractive and multiplicative forms of the stripe
    operation.

--

PiperOrigin-RevId: 245494735
2019-05-06 08:18:31 -07:00
Alex Zinenko 8a5f88191b Decouple region argument parsing from their type assignment
The parser currently expects region arguments to have a fixed, known type when
    the %-name of the region argument is parsed.  This may not necessarily be the
    case, for example, if the region argument types are the same as the operand
    types, located at the end of the operation.  Furthermore, the parser currently
    stores the values for region arguments internally and attaches them to the next
    parsed region implicitly.  This makes it impossible to attach some of the
    arguments to one region and some other arguments to another region if the
    regions are not textually interleaved with operation arguments.

    Provide `OpAsmParser::parseRegionArgument` that parses an SSA identifier and
    delays its type assignment until the region is parsed, similarly to operands.
    Update `OpAsmParser::parseRegion` to accept a list of pre-parsed SSA
    identifiers and a list of types instead of using SSA identifiers stored in the
    parser.

--

PiperOrigin-RevId: 245491133
2019-05-06 08:18:14 -07:00
River Riddle 40ab8e0fb3 Enable multi-threading in the pass manager by default.
--

PiperOrigin-RevId: 245458081
2019-05-06 08:17:58 -07:00
Alex Zinenko 24d0f60d31 Start building SDBM infrastructure
Striped difference-bound matrix expressions are a subset of affine expressions
    supporting low-complexity algorithms that can be useful for loop
    transformations.  This introduces the basic data data structures for building
    such expressions and unique'ing them in a MLIRContext.

--

PiperOrigin-RevId: 245380206
2019-05-06 08:17:42 -07:00
Stephan Herhut 65ccb8cfd5 Add a new NVVM dialect that extends the LLVM dialect with some NVVM specific operations.
Currently, this is limited to operations that give access to the special registers of
    NVIDIA gpus that represent block and thread indices.

--

PiperOrigin-RevId: 245378632
2019-05-06 08:17:24 -07:00
River Riddle 880df8f6ad Refactor the generic storage object uniquing functionality from TypeUniquer into its own class 'StorageUniquer'. This is the first step in supporting dialect extensible attributes.
--

PiperOrigin-RevId: 245358744
2019-05-06 08:17:08 -07:00
Lei Zhang 6749c21d6e [TableGen] Support multiple variadic operands/results
Certain ops can have multiple variadic operands/results, e.g., `tf.DynamicStitch`.
    Even if an op has only one variadic operand/result, it is not necessarily the
    very last one, e.g., `tf.RaggedGather`. This CL enhances TableGen subsystem to be
    able to represent such cases.

    In order to deduce the operand/result value range for each variadic operand,
    currently we only support variadic operands/results all of the same size.
    So two new traits, `SameVariadicOperandSize` and `SameVariadicResultSize` are
    introduced.

--

PiperOrigin-RevId: 245310628
2019-05-06 08:16:54 -07:00
River Riddle 22ad45a7aa Add support for Unit Attributes.
A unit attribute is an attribute that represents a value of `unit` type. The
    `unit` type allows only one value forming a singleton set. This attribute value
    is used to represent attributes that only have meaning from their existence.

    One example of such an attribute could be the `swift.self` attribute. This attribute indicates that a function parameter is the self/context
    parameter. It could be represented as a boolean attribute(true or false), but a
    value of false doesn't really bring any value. The parameter either is the
    self/context or it isn't.

    ```mlir {.mlir}
    // A unit attribute defined with the `unit` value specifier.
    func @verbose_form(i1 {unitAttr : unit})

    // A unit attribute can also be defined without the `unit` value specifier.
    func @simple_form(i1 {unitAttr})
    ```

--

PiperOrigin-RevId: 245254045
2019-05-06 08:16:39 -07:00
Rob Suderman 69cdceae73 GetMemRefType failed on 0-D tensors. Loosened check to allow tensors with shape
{}.

--

PiperOrigin-RevId: 245104548
2019-05-06 08:16:23 -07:00
Lei Zhang ce12875333 [TableGen] Refine OpTrait classes and defs to be consistent
--

PiperOrigin-RevId: 245075421
2019-05-06 08:16:11 -07:00
Alex Zinenko 4beef47b35 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
2019-05-06 08:16:00 -07:00
Lei Zhang 9f934f2a59 Add MultiResultTraitBase
Similar to MultiOperandTraitBase, this can simply the implementation of
    NResults, AtLeastNResults, and VariadicResults.

--

PiperOrigin-RevId: 245052333
2019-05-06 08:15:50 -07:00
River Riddle 5f801366d1 Fix flaky Linalg roundtrip test. This removes an invalid "%s" from the second mlir-opt command.
--

PiperOrigin-RevId: 244953230
2019-04-23 22:03:31 -07:00
Mehdi Amini 8034407f54 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
2019-04-23 22:03:23 -07:00
River Riddle 1423acc03c Rename isa_nonnull to isa_and_nonnull to match the upstream llvm name.
--

PiperOrigin-RevId: 244928036
2019-04-23 22:03:14 -07:00
Nicolas Vasilache a2e7775441 [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
2019-04-23 22:03:06 -07:00