Commit Graph

1666 Commits

Author SHA1 Message Date
Thomas Joerg 29712d7ffa Add gpu.launch_func builder taking KernelDim3 arguments (NFC).
--

PiperOrigin-RevId: 247577649
2019-05-10 19:27:48 -07:00
Thomas Joerg 0a21ab70fa Pass for outlining gpu.launch operation bodies into kernel functions called by gpu.launch_func operations.
--

PiperOrigin-RevId: 247564213
2019-05-10 19:27:40 -07:00
Mehdi Amini 051925bd34 Remove unused PassID member from PassRegistry (NFC)
Fix clang warning

--

PiperOrigin-RevId: 247558931
2019-05-10 19:27:32 -07:00
Mehdi Amini e0949c9cdb Remove unused MLIRContext member from MutableAffineMap class (NFC)
Fix clang warning

--

PiperOrigin-RevId: 247558650
2019-05-10 19:27:24 -07:00
Mehdi Amini 52d0dbbd2a Make header-defined method inline instead of static (NFC)
This is fixing a clang warning when this header is included in a file
    that does not use this function.

--

PiperOrigin-RevId: 247557803
2019-05-10 19:27:16 -07:00
Mehdi Amini 6459c821bf Fix class/struct mismatch between declaration/definition (NFC)
Fix clang warnings

--

PiperOrigin-RevId: 247557395
2019-05-10 19:27:07 -07:00
Mehdi Amini 211ceb9fd5 Add override keyword on overidden virtual method (NFC)
Fix clang warnings

--

PiperOrigin-RevId: 247556495
2019-05-10 19:26:59 -07:00
River Riddle 5fd4ec1b78 Move the diagnostic verification functionality out of mlir-opt and into a new llvm::SourceMgr diagnostic handler 'SourceMgrDiagnosticVerifierHandler'. This will allow for other tools to reuse the 'expected-*' functionality.
--

PiperOrigin-RevId: 247514684
2019-05-10 19:26:51 -07:00
Lei Zhang b0be00c746 Only forbid mixing tensor and vector when considering broadcasting behavior
The previous approach is too restrictive; we end up forbidding all dialect-specific
    types as element types. Changed to not consider element types entirely.

--

PiperOrigin-RevId: 247486537
2019-05-10 19:26:43 -07:00
River Riddle 0e481bae68 Add support in the SourceMgrDiagnosticHandler for handling source managers with multiple buffers.
--

PiperOrigin-RevId: 247482733
2019-05-10 19:26:35 -07:00
Nicolas Vasilache b4c06416df Move edsc python tests to Filecheck
--

PiperOrigin-RevId: 247479507
2019-05-10 19:26:27 -07:00
Nicolas Vasilache 33449c3e6c Pipe Linalg to LLVM via mlir-cpu-runner
This CL adds support for functions in the Linalg dialect to run with mlir-cpu-runner.
    For this purpose, this CL adds BufferAllocOp, BufferDeallocOp, LoadOp and StoreOp to the Linalg dialect as well as their lowering to LLVM. To avoid collisions with mlir::LoadOp/StoreOp (which should really become mlir::affine::LoadOp/StoreOp), the mlir::linalg namespace is added.

    The execution uses a dummy linalg_dot function that just returns for now. In the future a proper library call will be used.

--

PiperOrigin-RevId: 247476061
2019-05-10 19:26:18 -07:00
Nicolas Vasilache 07f777f6cd Fix OSS build (Linux)
--

PiperOrigin-RevId: 247472005
2019-05-10 19:26:10 -07:00
River Riddle a054f7af95 Update mlir::interleaveComma to work on ranges with types other than Container<T>.
--

PiperOrigin-RevId: 247468184
2019-05-10 19:26:01 -07:00
Andy Davis 0412bf6f09 Add memref dimension bounds as upper/lower bounds on MemRefRegion constraints, to guard against potential over-approximation from projection.
--

PiperOrigin-RevId: 247431201
2019-05-10 19:25:53 -07:00
Andy Davis 6254a42d58 Fix bug in DmaGenerate pass where MemRefRegion union was not propagated to read region.
Also cleaned up dma-generate.mlir a bit.

--

PiperOrigin-RevId: 247417358
2019-05-10 19:25:44 -07:00
Alex Zinenko dbb9608de8 Conversion to LLVM Dialect: integrate TypeConverter into LLVMLowering
Historically, the conversion from standard and built-in types to the LLVM IR
    dialect types was performed by a dedicated class, TypeConverter.  This class
    served to contain references to the LLVM IR dialect and to the LLVM IR Module
    to allow querying the data layout.  Recently, the LLVMLowering class was
    introduced to make the conversion to the LLVM IR dialect extensible to other
    source dialects.  This class also includes the references to the LLVM IR
    dialect and module.  TypeConverter was extended with basic support for
    dialect-specific type conversion through callbacks.  This is not sufficient in
    cases where dialect-specific types appear inside other types, such as function
    or container types.

    Integrate TypeConverter into LLVMLowering.  Whenever a subtype needs to be
    converted during standard type conversion (e.g. an argument or a result of a
    FunctionType), the conversion will call to the virtual function
    `LLVMLowering::convertType`, which can be extended to support dialect-specific
    types.

    Provide a new LLVMOpConversion class that serves as a base class for all
    conversions to the LLVM IR dialect and gives them access to LLVMLowering for
    the purpose of type conversion.  Update Linalg to LLVM IR lowering to use this
    class.

--

PiperOrigin-RevId: 247407314
2019-05-10 19:25:36 -07:00
Stephan Herhut 45c87e4d3b Fix builder for LLVM::Alloca operation.
--

PiperOrigin-RevId: 247402238
2019-05-10 19:25:28 -07:00
Thomas Joerg 530439075a Add gpu.launch_func builder.
--

PiperOrigin-RevId: 247364893
2019-05-10 19:25:19 -07:00
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