Commit Graph

1967 Commits

Author SHA1 Message Date
Jacques Pienaar c914976c72 Allow constant of unit type.
--

PiperOrigin-RevId: 251053682
2019-06-01 20:14:48 -07:00
Jacques Pienaar 482d39eb98 Avoid failure due to incomplete type specification.
--

PiperOrigin-RevId: 251048081
2019-06-01 20:14:39 -07:00
Lei Zhang af98d82476 [spirv] Add a script to update SPIRVBase.td with new enum attributes
This script parses the SPIR-V JSON grammar to extract operand kinds that
    are enums and generate TableGen definitions for them.

    Also added a shell script to point to the correct relative file location
    to simplify command invocation.

--

PiperOrigin-RevId: 251041084
2019-06-01 20:14:28 -07:00
Mehdi Amini 05b0527ab7 Move NamedAttributeList::get() method out-of-line (fix CMake build due to missing include)
--

PiperOrigin-RevId: 251000296
2019-06-01 20:14:19 -07:00
Geoffrey Martin-Noble 8c4ae76b27 Use size_t for tuple type size
This is more consistent with standard containers.

--

PiperOrigin-RevId: 250985851
2019-06-01 20:14:09 -07:00
Geoffrey Martin-Noble daefaded4a Consistently use int64_t for shape-related values in shaped types
We want to support 64-bit shapes (even when the compiler is on a 32-bit architecture). Using int64_t consistently allows us to sidestep the bugginess of unsigned arithmetic.

    Still unsigned: kind, memory space, and bit width. The first two are basically enums. We could have a discussion about the last one, but it's basically just a very large enum as well and we're not doing any math on it, I think.

--

PiperOrigin-RevId: 250985791
2019-06-01 20:13:58 -07:00
Geoffrey Martin-Noble c912981bbd Static cast size_t -> int64_t instead of vice versa for equals comparisons
These were just introduced by a previous CL moving MemRef getRank to return int64_t. size_t could be smaller than 64 bits and in equals comparisons, signed vs unsigned doesn't matter. In these cases, we know right now that the particular int64_t is not larger than max size_t (because it currently comes directly from a size() call), the alternative cast plus equals comparison is always safe, so we might as well do it that way and no longer require reasoning deeper into the callstack.

    We are already assuming that size() calls fit into int64_t in a number of other cases like the aforementioned getRank() (since exabytes of RAM are rare). If we want to avoid this assumption we will have to come up with a principled way to do it throughout.

--

PiperOrigin-RevId: 250980297
2019-06-01 20:13:49 -07:00
River Riddle e7b337acf8 Add support for providing an output stream to the SourceMgrDiagnosticHandlers.
--

PiperOrigin-RevId: 250974331
2019-06-01 20:13:39 -07:00
Amit Sabne 7a43da6060 Loop invariant code motion - remove reliance on getForwardSlice. Add more tests.
--

PiperOrigin-RevId: 250950703
2019-06-01 20:13:30 -07:00
River Riddle 05bb27fac2 NFC: Cleanup method definitions within Parser and add header blocks to improve readability.
--

PiperOrigin-RevId: 250949195
2019-06-01 20:13:19 -07:00
Mehdi Amini 1e104f22eb Fix CMake builds: sources not used in every targets must be marked with LLVM_OPTIONAL_SOURCES
--

PiperOrigin-RevId: 250948796
2019-06-01 20:13:10 -07:00
Geoffrey Martin-Noble 65eae3f75f Get rid of separate getRank() on MemRef now that it subclasses ShapedType
We are moving towards int64_t for these shape/dimension -related values to avoid buginess with unsigned arithmetic

--

PiperOrigin-RevId: 250945322
2019-06-01 20:13:00 -07:00
Geoffrey Martin-Noble ac4b0a1e7b Some cleanup of ShapedType now that MemRef subclasses it.
Extract common methods into ShapedType.
    Simplify methods.
    Remove some extraneous asserts.
    Replace sentinel value with a helper method to check the same.

--

PiperOrigin-RevId: 250945261
2019-06-01 20:12:51 -07:00
Geoffrey Martin-Noble 32de860a09 Make MemRefType subclass ShapedType
MemRefs have the same notion of shape, rank, and fixed element type. This allows us to reuse utilities based on shape for memref.

    All dyn_cast and isa calls for ShapedType have been checked and either modified to explicitly check for vector or tensor, or confirmed to not depend on the result being a vector or tensor.

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

--

PiperOrigin-RevId: 250945184
2019-06-01 20:12:40 -07:00
Geoffrey Martin-Noble 8eca4cc30d Don't use ShapedType to indicate vector or tensor type
MemRefType may soon subclass ShapedType. ShapedType only guarantees that something has a shape (possibly dynamic), rank (or explicitly unranked), and fixed element type.

--

PiperOrigin-RevId: 250940537
2019-06-01 20:12:31 -07:00
River Riddle 37732b1759 Fix an msan warning for use of an uninitialized variable.
--

PiperOrigin-RevId: 250939301
2019-06-01 20:12:21 -07:00
River Riddle 58e40178fc Remove the newline from the mlir-opt 'split-input-file' flag marker. This fixes support for DOS style new lines(/r/n).
--

PiperOrigin-RevId: 250899420
2019-06-01 20:12:11 -07:00
River Riddle 94541563dc Abstract the internal storage of the NamedAttributeList into a new attribute, DictionaryAttr. This attribute maintains a sorted list of NamedAttributes. This will allow for operations/functions to maintain sub dictionaries of attributes.
The syntax is the same as top level attribute dictionaries:
       {sub_dictionary: {fn: @someFn, boolAttr: true}}

--

PiperOrigin-RevId: 250898950
2019-06-01 20:12:01 -07:00
Jacques Pienaar 9c430353ae Disable named attribute in ODG for ArgOrResultElementTypeIs as was taking address of r-value.
--

PiperOrigin-RevId: 250805965
2019-06-01 20:11:51 -07:00
Lei Zhang 3650df50dd [ODS] Support region names and constraints
Similar to arguments and results, now we require region definition in ops to
    be specified as a DAG expression with the 'region' operator. This way we can
    specify the constraints for each region and optionally give the region a name.

    Two kinds of region constraints are added, one allowing any region, and the
    other requires a certain number of blocks.

--

PiperOrigin-RevId: 250790211
2019-06-01 20:11:42 -07:00
Geoffrey Martin-Noble 60d6249fbd Replace checks against numDynamicDims with hasStaticShape
--

PiperOrigin-RevId: 250782165
2019-06-01 20:11:31 -07:00
River Riddle 4fd012cda2 Replace a usage of std::vector with SmallVector to allow constructing with non-constant iterators on MSVC.
--

PiperOrigin-RevId: 250769027
2019-06-01 20:11:22 -07:00
Geoffrey Martin-Noble 97505013c6 Make getRank abort for unranked type
This better matches the other methods in ShapedType which only make sense for ranked types. There's now an explicit hasRank for checking the rank. Actual call sites rarely used the "-1" sentinel to combine checking for rankedness and checking that rank is a certain value. And in most cases they should actually be checking for rankedness at a higher level using type predicates. Using an explicit method is clearer than a sentinel anyway.

--

PiperOrigin-RevId: 250720853
2019-06-01 20:11:12 -07:00
Jacques Pienaar 29073d999c Allow argument and result names replacement in predicates.
This allow specifying $x to refer to an operand's named argument (operand or attribute) or result. Skip variadic operands/results for now pending autogenerated discussion of their accessors.

    This adds a new predicate, following feedback on the naming but does not remove the old one. Post feedback I'll do that, potentially in follow up.

--

PiperOrigin-RevId: 250720003
2019-06-01 20:11:01 -07:00
Jacques Pienaar 077bf9b266 Avoid unspecified files error by explicitly including for now.
--

PiperOrigin-RevId: 250708336
2019-06-01 20:10:52 -07:00
Jacques Pienaar c59538977e Add keywords in target_link_libraries post add_llvm_executable.
--

PiperOrigin-RevId: 250704528
2019-06-01 20:10:42 -07:00
River Riddle 11e485ca19 Replace usages of 'add_executable' with 'add_llvm_executable'.
--

PiperOrigin-RevId: 250691487
2019-06-01 20:10:32 -07:00
Jacques Pienaar 4a697a91de Fix 5 ClangTidy - Readability findings.
* the 'empty' method should be used to check for emptiness instead of 'size'
    * using decl 'CapturableHandle' is unused
    * redundant get() call on smart pointer
    * using decl 'apply' is unused
    * using decl 'ScopeGuard' is unused

--

PiperOrigin-RevId: 250623863
2019-06-01 20:10:22 -07:00
River Riddle 9abdbb3189 NFC: Inline toString as operations can be streamed directly into raw_ostream.
--

PiperOrigin-RevId: 250619765
2019-06-01 20:10:12 -07:00
Geoffrey Martin-Noble d407a85169 Use hasRank instead of comparing rank to -1
--

PiperOrigin-RevId: 250598252
2019-06-01 20:10:03 -07:00
River Riddle e2af847a2e Move CondBranchOp to the ODG framework.
--

PiperOrigin-RevId: 250593367
2019-06-01 20:09:52 -07:00
Geoffrey Martin-Noble 1c681a7caf Exclude all ShapedType subclasses other than TensorType subclasses from having non-scalar elements.
The current logic assumes that ShapedType indicates a vector or tensor, which will not be true soon when MemRef subclasses ShapedType

--

PiperOrigin-RevId: 250586364
2019-06-01 20:09:42 -07:00
Geoffrey Martin-Noble 17022b1bc5 Check for Vector or Tensor Type rather than ShapedType when matching constant splat
Only vectors or tensors can be constant splats (or element attrs). This is in preparation for making MemRef subclass ShapedType

--

PiperOrigin-RevId: 250586281
2019-06-01 20:09:32 -07:00
Geoffrey Martin-Noble 9ebab7bc30 Avoid dyn_cast to ShapedType
ShapedType just indicates shape/rank/element semantics. It's generally not useful for other type checking. This check already checks for vector or tensor type, so we can use a direct cast if we check those first.

    Related to making MemRefType a subclass of ShapedType

--

PiperOrigin-RevId: 250583231
2019-06-01 20:09:22 -07:00
Geoffrey Martin-Noble 66e84bf88c Make it clear that ElementsAttr is only for static shaped vectors or tensors.
This is in preparation for making MemRef a subclass of ShapedType, but also UnrankedTensor should already be excluded.

--

PiperOrigin-RevId: 250580197
2019-06-01 20:09:12 -07:00
MLIR Team 5a91b9896c Remove "size" property of affine maps.
--

PiperOrigin-RevId: 250572818
2019-06-01 20:09:02 -07:00
Andy Davis 1de0f97fff LoopFusionUtils CL 2/n: Factor out and generalize slice union computation.
*) Factors slice union computation out of LoopFusion into Analysis/Utils (where other iteration slice utilities exist).
    *) Generalizes slice union computation to take the union of slices computed on all loads/stores pairs between source and destination loop nests.
    *) Fixes a bug in FlatAffineConstraints::addSliceBounds where redundant constraints were added.
    *) Takes care of a TODO to expose FlatAffineConstraints::mergeAndAlignIds as a public method.

--

PiperOrigin-RevId: 250561529
2019-06-01 20:08:52 -07:00
Geoffrey Martin-Noble a7b862240c Change "may never" to "must never"
"may never" indicates that it's allowed to never hold a value. I believe the intent here is that it is not allowed to ever hold a value.

--

PiperOrigin-RevId: 250560623
2019-06-01 20:08:42 -07:00
River Riddle bffba61d48 Add whole_archive_link support for MSVC.
This issue was discovered by @loic-joly-sonarsource with a proposed fix
    in https://github.com/tensorflow/mlir/pull/22.

--

PiperOrigin-RevId: 250558504
2019-06-01 20:08:32 -07:00
Geoffrey Martin-Noble 16ebc48c9d Change elements literal parsing to not rely on shaped type being a vector or tensor.
This is in preparation for making MemRef a ShapedType. In general, a shaped type should be anything with shape, rank, and element type properties, so use sites shouldn't assume more than that.

    I also pulled the trailing comma parsing out the parseElementsLiteralType (new name) method. It seems weird to have the method parse the type + a trailing comma, even if all call sites currently need that. It's surprising behavior without looking at the implementation.

--

PiperOrigin-RevId: 250558363
2019-06-01 20:08:22 -07:00
River Riddle 1ebbb135cc Disable the mlir-cpu-runner tests on win32. llvm orc does not support the COFF rtld.
--

PiperOrigin-RevId: 250556116
2019-06-01 20:08:12 -07:00
River Riddle 1fd1c7a8bb Replace the Function reference methods from the OpAsmParser/OpAsmPrinter with usages of FunctionAttr.
--

PiperOrigin-RevId: 250555680
2019-06-01 20:08:03 -07:00
River Riddle c455ecef22 Add an example of accessing the impl storage to the 'DefiningAttributesAndTypes' document.
--

PiperOrigin-RevId: 250553898
2019-06-01 20:07:51 -07:00
River Riddle 06b0db5311 Remove the Toy/* file path from the location check lines. This assumes a specific file path format that breaks on MSVC.
--

PiperOrigin-RevId: 250549223
2019-06-01 20:07:40 -07:00
River Riddle 661f062f6b NFC: Switch std::vector to SmallVector. This fixes a compiler error on MSVC as the StringMap key dereference method is non-const.
--

PiperOrigin-RevId: 250538085
2019-06-01 20:07:31 -07:00
Ben Vanik aa7ee31cbe [TableGen] Making printer support $cppClass substitution (similar to parser).
--

PiperOrigin-RevId: 250534216
2019-06-01 20:07:21 -07:00
Lei Zhang 22e3aa7594 [spirv] Add ModuleOp
This op defines a SPIR-V module using a MLIR region. The region contains
    one block. Module-level operations, including functions definitions,
    are all placed in this block.

    This CL extracts common definitions from SPIRVOps.td into SPIRVBase.td.
    The new op is placed in SPIRVStructureOps.td.

--

PiperOrigin-RevId: 250522320
2019-06-01 20:07:10 -07:00
Rasmus Munk Larsen e5a6904914 Get rid of redundant verifier, which is implied by the type traits.
--

PiperOrigin-RevId: 250511694
2019-06-01 20:07:01 -07:00
Rasmus Munk Larsen 861c55e150 Add a rank op to MLIR. Example:
%1 = rank %0 : index

--

PiperOrigin-RevId: 250505411
2019-06-01 20:06:51 -07:00
Nicolas Vasilache 0eac031fac Add lowering linalg.for to LLVM IR
This CL adds lowering of linalg.for to LLVM IR and adds an IR test.
    This also replaces the usage of affine.for with linalg.for and enables the LLVM IR path in the integration test.

--

PiperOrigin-RevId: 250503798
2019-06-01 20:06:40 -07:00