Commit Graph

3735 Commits

Author SHA1 Message Date
Lei Zhang 859e379ffb [mlir][spirv] Explicitly set the size of static arrays 2020-01-17 12:33:05 -05:00
Alex Zinenko f343544b81 [mlir] Generator converting LLVM intrinsics defs to MLIR ODS
Introduce a new generator for MLIR tablegen driver that consumes LLVM IR
intrinsic definitions and produces MLIR ODS definitions. This is useful to
bulk-generate MLIR operations equivalent to existing LLVM IR intrinsics, such
as additional arithmetic instructions or NVVM.

A test exercising the generation is also added. It reads the main LLVM
intrinsics file and produces ODS to make sure the TableGen model remains in
sync with what is used in LLVM.

Differential Revision: https://reviews.llvm.org/D72926
2020-01-17 18:20:24 +01:00
Andy Davis 78f82e162e [VectorOps] Update vector transfer read op comments.
Summary: Update vector transfer read op comments.

Reviewers: nicolasvasilache, aartbik

Reviewed By: nicolasvasilache, aartbik

Subscribers: merge_guards_bot, mehdi_amini, rriddle, jpienaar, burmako, shauheen, antiagainst, arpith-jacob, mgester, lucyrfox, liufengdb, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D72731
2020-01-17 12:07:35 -05:00
Denis Khalikov 29779894af [mlir][spirv] Add lowering from `loop.if` to `spv.selection`
When lowering `loop.if` to `spv.selection` we explicitly create
a selection header block before the control flow diverges and a
merge block where control flow subsequently converges.

Differential Revision: https://reviews.llvm.org/D72836
2020-01-17 12:04:12 -05:00
Alex Zinenko a922e23101 [mlir] Improve documentation in ModuleTranslation MLIR to LLVM IR
Several functions were missing documentation.
2020-01-17 18:03:02 +01:00
Lei Zhang 8bcf976841 [mlir][spirv] Add `const` qualifier for static arrays
This makes the local variable `implies` to have the correct
type to satisfy ArrayRef's constructor:

  /*implicit*/ constexpr ArrayRef(const T (&Arr)[N])

Hopefully this should please GCC 5.

Differential Revision: https://reviews.llvm.org/D72924
2020-01-17 11:45:41 -05:00
Lei Zhang 267483ac70 [mlir][spirv] Support implied extensions and capabilities
In SPIR-V, when a new version is introduced, it is possible some
existing extensions will be incorporated into it so that it becomes
implicitly declared if targeting the new version. This affects
conversion target specification because we need to take this into
account when allowing what extensions to use.

For a capability, it may also implies some other capabilities,
for example, the `Shader` capability implies `Matrix` the capability.
This should also be taken into consideration when preparing the
conversion target: when we specify an capability is allowed, all
its recursively implied capabilities are also allowed.

This commit adds utility functions to query implied extensions for
a given version and implied capabilities for a given capability
and updated SPIRVConversionTarget to use them.

This commit also fixes a bug in availability spec. When a symbol
(op or enum case) can be enabled by an extension, we should drop
it's minimal version requirement. Being enabled by an extension
naturally means the symbol can be used by *any* SPIR-V version
as long as the extension is supported. The grammar still encodes
the 'version' field for such cases, but it should be interpreted
as a different way: rather than meaning a minimal version
requirement, it says the symbol becomes core at that specific
version.

Differential Revision: https://reviews.llvm.org/D72765
2020-01-17 08:01:57 -05:00
Lei Zhang 37dfc64687 Revert "[mlir][ods] Support dialect specific content emission via hooks"
This reverts commit 397215cc30 because
this feature needs more discussion.
2020-01-17 07:56:21 -05:00
Lei Zhang 961174f878 [mlir][spirv] Fix SPV_MM_Vulkan extension reqirements
SPV_MM_Vulkan can be enabled by the SPV_KHR_vulkan_memory_model extension.

Differential Revision: https://reviews.llvm.org/D72764
2020-01-16 21:32:01 -05:00
Lei Zhang ccedb918bb [mlir][spirv] Use symbolize functions in enum attribute predicates
By default, for an enum attribute, we will generate a list of equality
comparisons for all supported cases inside it's predicate. This list
can be fairly large for certain SPIR-V enum attributes. Instead, we
already have such a list generated by EnumsGen in the symbolize
functions. Leverage that to simplify the generated C++ code.

Differential Revision: https://reviews.llvm.org/D72763
2020-01-16 21:32:01 -05:00
Lei Zhang 6a97013590 [mlir][spirv] Add implied capabilities and availability for capabilities
Certain SPIR-V capabilities are only available in certain SPIR-V versions
or extensions. Also a SPIR-V capability may implicitly declares other
capabilities.

This commit updates gen_spirv_dialect.py to support generating such
information into SPIRVBase.td. It requires us to topologically sort
all capabilities because now a capability can refer to another one.

This commits also registers a few extensions because their symbols are
used by capability availability.

Note that this commit hasn't updated SPIRVConversionTarget to take
into consideration such relationship yet. That will be done in a
following-up commit.

Differential Revision: https://reviews.llvm.org/D72760
2020-01-16 21:32:01 -05:00
Geoffrey Martin-Noble 933b421256 [mlir] Add missing dependency on LinalgUtils
Differential Revision: https://reviews.llvm.org/D72821
2020-01-16 23:41:26 +00:00
David Blaikie 65eb74e94b PointerLikeTypeTraits: Standardize NumLowBitsAvailable on static constexpr rather than anonymous enum
This is (more?) usable by GDB pretty printers and seems nicer to write.

There's one tricky caveat that in C++14 (LLVM's codebase today) the
static constexpr member declaration is not a definition - so odr use of
this constant requires an out of line definition, which won't be
provided (that'd make all these trait classes more annoyidng/expensive
to maintain). But the use of this constant in the library implementation
is/should always be in a non-odr context - only two unit tests needed to
be touched to cope with this/avoid odr using these constants.

Based on/expanded from D72590 by Christian Sigg.
2020-01-16 15:30:50 -08:00
Alex Zinenko a4a42160c4 [mlir] support translation of multidimensional vectors to LLVM IR
Summary:
MLIR unlike LLVM IR supports multidimensional vector types. Such types are
lowered to nested LLVM IR arrays wrapping an LLVM IR vector for the innermost
dimension of the MLIR vector. MLIR supports constants of such types using
ElementsAttr for values. Introduce support for converting ElementsAttr into
LLVM IR Constant Aggregates recursively. This enables translation of
multidimensional vector constants from MLIR to LLVM IR.

Differential Revision: https://reviews.llvm.org/D72846
2020-01-17 00:05:37 +01:00
Kazuaki Ishizaki 73f371c31d [mlir] NFC: Fix trivial typos
Summary: Fix trivial typos

Differential Revision: https://reviews.llvm.org/D72672
2020-01-16 23:58:58 +01:00
Nicolas Vasilache 2b81d3c6c6 [mlir][Linalg] Fix Linalg EDSC builders
Summary:
This diff fixes the fact that the method `mlir::edsc::makeGenericLinalgOp`
incorrectly adds 2 blocks to Linalg ops.

Tests are updated accordingly.

Reviewers: ftynse, hanchung, herhut, pifon2a, asaadaldien

Reviewed By: asaadaldien

Subscribers: merge_guards_bot, mehdi_amini, rriddle, jpienaar, burmako, shauheen, antiagainst, arpith-jacob, mgester, lucyrfox, liufengdb, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D72780
2020-01-16 10:14:59 -05:00
Hiroshi Inoue 58265ad42a [mlir] fix broken links to Glossary
Differential Revision: https://reviews.llvm.org/D72697
2020-01-16 14:15:34 +09:00
Jacques Pienaar fa26a37d36 [mlir] Add shaped container component type interface
Summary:
* Add shaped container type interface which allows infering the shape, element
  type and attribute of shaped container type separately. Show usage by way of
  tensor type inference trait which combines the shape & element type in
  infering a tensor type;
  - All components need not be specified;
  - Attribute is added to allow for layout attribute that was previously
    discussed;
* Expand the test driver to make it easier to test new creation instances
  (adding new operands or ops with attributes or regions would trigger build
  functions/type inference methods);
  - The verification part will be moved out of the test and to verify method
    instead of ops implementing the type inference interface in a follow up;
* Add MLIRContext as arg to possible to create type for ops without arguments,
  region or location;
* Also move out the section in OpDefinitions doc to separate ShapeInference doc
  where the shape function requirements can be captured;
  - Part of this would move to the shape dialect and/or shape dialect ops be
    included as subsection of this doc;
* Update ODS's variable usage to match camelBack format for builder,
  state and arg variables;
  - I could have split this out, but I had to make some changes around
    these and the inconsistency bugged me :)

Differential Revision: https://reviews.llvm.org/D72432
2020-01-15 13:28:39 -08:00
Benjamin Kramer 0133cc60e4 Revert "[mlir] Create a gpu.module operation for the GPU Dialect."
This reverts commit 4624a1e8ac. Causing
problems downstream.
2020-01-15 17:52:17 +01:00
Nicolas Vasilache 88380b91c8 [mlir][Linalg] NFC - Hotfix for gcc-5 build 2020-01-15 11:13:20 -05:00
Nicolas Vasilache 7741de9435 [mlir][Linalg] NFC - Cleanup Linalg Pass locations and namespacing
Summary:
This diff moves the conversion pass declaration closer to its definition
and makes the namespacing of passes consistent with the rest of the
infrastructure (i.e. `mlir::linalg::createXXXPass` -> `mlir::createXXXPass`).

Reviewers: ftynse, jpienaar, mehdi_amini

Subscribers: rriddle, burmako, shauheen, antiagainst, arpith-jacob, mgester, lucyrfox, aartbik, liufengdb, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D72766
2020-01-15 11:06:28 -05:00
Nicolas Vasilache ad7f4c11eb [mlir][Linalg] NFC - Hotfix for gcc-5 build 2020-01-15 10:41:23 -05:00
Nicolas Vasilache 89b395fe79 [mlir][EDSC] Refactor dependencies involving EDSCs.
Summary: This diff removes the dependency of LinalgOps and VectorOps on EDSCs.

Reviewers: jpienaar, ftynse

Reviewed By: ftynse

Subscribers: merge_guards_bot, mgorny, mehdi_amini, rriddle, burmako, shauheen, antiagainst, csigg, arpith-jacob, mgester, lucyrfox, herhut, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D72481
2020-01-15 09:34:29 -05:00
Alex Zinenko dc553ce646 [mlir] LLVM import: handle function-typed constants
The current implementation of the LLVM-to-MLIR translation could not handle
functions used as constant values in instructions. The handling is added
trivially as `llvm.mlir.constant` can define constants of function type using
SymbolRef attributes, which works even for functions that have not been
declared yet.
2020-01-15 15:01:49 +01:00
Ahmed Taei ab03564706 [mlir] : Fix ViewOp shape folder for identity affine maps
Summary: Fix the ViewOpShapeFolder in case of no affine mapping associated with a Memref construct identity mapping.

Reviewers: nicolasvasilache

Subscribers: mehdi_amini, rriddle, jpienaar, burmako, shauheen, antiagainst, arpith-jacob, mgester, lucyrfox, liufengdb, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D72735
2020-01-15 00:54:00 +00:00
Lei Zhang 47c6ab2b97 [mlir][spirv] Properly support SPIR-V conversion target
This commit defines a new SPIR-V dialect attribute for specifying
a SPIR-V target environment. It is a dictionary attribute containing
the SPIR-V version, supported extension list, and allowed capability
list. A SPIRVConversionTarget subclass is created to take in the
target environment and sets proper dynmaically legal ops by querying
the op availability interface of SPIR-V ops to make sure they are
available in the specified target environment. All existing conversions
targeting SPIR-V is changed to use this SPIRVConversionTarget. It
probes whether the input IR has a `spv.target_env` attribute,
otherwise, it uses the default target environment: SPIR-V 1.0 with
Shader capability and no extra extensions.

Differential Revision: https://reviews.llvm.org/D72256
2020-01-14 19:18:42 -05:00
River Riddle fa9dd8336b [mlir] Refactor ModuleState into AsmState and expose it to users.
Summary:
This allows for users to cache printer state, which can be costly to recompute. Each of the IR print methods gain a new overload taking this new state class.

Depends On D72293

Reviewed By: jpienaar

Differential Revision: https://reviews.llvm.org/D72294
2020-01-14 15:23:31 -08:00
River Riddle 20c6e07494 [mlir] Enable printing of FuncOp in the generic form.
Summary:
This was previously disabled as FunctionType TypeAttrs could not be roundtripped in the IR. This has been fixed, so we can now generically print FuncOp.

Depends On D72429

Reviewed By: jpienaar, mehdi_amini

Differential Revision: https://reviews.llvm.org/D72642
2020-01-14 15:10:07 -08:00
Nicolas Vasilache f52d71736b [mlir][Linalg] Update the semantics, verifier and test for Linalg with tensors.
Summary:
This diff fixes issues with the semantics of linalg.generic on tensors that appeared when converting directly from HLO to linalg.generic.
The changes are self-contained within MLIR and can be captured and tested independently of XLA.

The linalg.generic and indexed_generic are updated to:

To allow progressive lowering from the value world (a.k.a tensor values) to
the buffer world (a.k.a memref values), a linalg.generic op accepts
mixing input and output ranked tensor values with input and output memrefs.

```
%1 = linalg.generic #trait_attribute %A, %B {other-attributes} :
  tensor<?x?xf32>,
  memref<?x?xf32, stride_specification>
  -> (tensor<?x?xf32>)
```

In this case, the number of outputs (args_out) must match the sum of (1) the
number of output buffer operands and (2) the number of tensor return values.
The semantics is that the linalg.indexed_generic op produces (i.e.
allocates and fills) its return values.

Tensor values must be legalized by a buffer allocation pass before most
transformations can be applied. Such legalization moves tensor return values
into output buffer operands and updates the region argument accordingly.

Transformations that create control-flow around linalg.indexed_generic
operations are not expected to mix with tensors because SSA values do not
escape naturally. Still, transformations and rewrites that take advantage of
tensor SSA values are expected to be useful and will be added in the near
future.

Subscribers: bmahjour, mehdi_amini, rriddle, jpienaar, burmako, shauheen, antiagainst, arpith-jacob, mgester, lucyrfox, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D72555
2020-01-14 17:25:28 -05:00
River Riddle 1bd14ce392 [mlir] Use double format when parsing bfloat16 hexadecimal values
Summary: bfloat16 doesn't have a valid APFloat format, so we have to use double semantics when storing it. This change makes sure that hexadecimal values can be round-tripped properly given this fact.

Reviewed By: mehdi_amini

Differential Revision: https://reviews.llvm.org/D72667
2020-01-14 13:56:22 -08:00
Benjamin Kramer df186507e1 Make helper functions static or move them into anonymous namespaces. NFC. 2020-01-14 14:06:37 +01:00
Alex Zinenko d6ea8ff0d7 [mlir] Fix translation of splat constants to LLVM IR
Summary:
When converting splat constants for nested sequential LLVM IR types wrapped in
MLIR, the constant conversion was erroneously assuming it was always possible
to recursively construct a constant of a sequential type given only one value.
Instead, wait until all sequential types are unpacked recursively before
constructing a scalar constant and wrapping it into the surrounding sequential
type.

Subscribers: mehdi_amini, rriddle, jpienaar, burmako, shauheen, antiagainst, nicolasvasilache, arpith-jacob, mgester, lucyrfox, aartbik, liufengdb, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D72688
2020-01-14 12:37:47 +01:00
Tres Popp 4624a1e8ac [mlir] Create a gpu.module operation for the GPU Dialect.
Summary:
This is based on the use of code constantly checking for an attribute on
a model and instead represents the distinct operaion with a different
op. Instead, this op can be used to provide better filtering.

Reviewers: herhut, mravishankar, antiagainst, rriddle

Reviewed By: herhut, antiagainst, rriddle

Subscribers: liufengdb, aartbik, jholewinski, mgorny, mehdi_amini, rriddle, jpienaar, burmako, shauheen, antiagainst, nicolasvasilache, csigg, arpith-jacob, mgester, lucyrfox, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D72336
2020-01-14 12:05:47 +01:00
Adrian 5a6eae3dea [mlir] Ran git-clang-format.
Summary:
I forgot to ran git-clang-format before committing.
2020-01-14 11:44:45 +01:00
Adrian Kuegel 018b042593 [mlir] Add loop.parallel, loop.reduce and loop.reduce.return operations.
Summary:
These operations can be used to specify a loop nest with a body that can
contain reductions. The iteration space can be iterated in any order.

RFC: https://groups.google.com/a/tensorflow.org/d/topic/mlir/pwtSgiKFPis/discussion

Differential Revision: https://reviews.llvm.org/D72394
2020-01-14 11:35:41 +01:00
Sam McCall 547abdd921 [mlir] Fix -Wunused 2020-01-14 10:07:51 +01:00
Daniel Galvez a7cac2bd4b [MLIR] Fix broken link locations after move to monorepo
I used the codemod python tool to do this with the following commands:

codemod 'tensorflow/mlir/blob/master/include' 'llvm/llvm-project/blob/master/mlir/include'
codemod 'tensorflow/mlir/blob/master' 'llvm/llvm-project/blob/master/mlir'
codemod 'tensorflow/mlir' 'llvm-project/llvm'

Differential Revision: https://reviews.llvm.org/D72244
2020-01-14 07:15:02 +00:00
Aart Bik 3818101f7f [mlir] [VectorOps] fixed typo in verifier of slice op
Reviewers: nicolasvasilache, andydavis1, rriddle

Reviewed By: nicolasvasilache, rriddle

Subscribers: merge_guards_bot, mehdi_amini, rriddle, jpienaar, burmako, shauheen, antiagainst, nicolasvasilache, arpith-jacob, mgester, lucyrfox, liufengdb, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D72664
2020-01-13 18:53:15 -08:00
River Riddle 03edd6d6a6 [mlir] NFC: Remove unused variable. 2020-01-13 16:15:06 -08:00
River Riddle 9b92e4fbdb [mlir] Add support for attaching a visibility to symbols.
Summary:
The visibility defines the structural reachability of the symbol within the IR. Symbols can define one of three visibilities:

* Public
The symbol \may be accessed from outside of the visible IR. We cannot assume that we can observe all of the uses of this symbol.

* Private
The symbol may only be referenced from within the operations in the current symbol table, via SymbolRefAttr.

* Nested
The symbol may be referenced by operations in symbol tables above the current symbol table, as long as each symbol table parent also defines a non-private symbol. This allows or referencing the symbol from outside of the defining symbol table, while retaining the ability for the compiler to see all uses.

These properties help to reason about the properties of a symbol, and will be used in a follow up to implement a dce pass on dead symbols.

A few examples of what this would look like in the IR are shown below:

  module @public_module {
    // This function can be accessed by 'live.user'
    func @nested_function() attributes { sym_visibility = "nested" }

    // This function cannot be accessed outside of 'public_module'
   func @private_function() attributes { sym_visibility = "private" }
  }

  // This function can only be accessed from within this module.
  func @private_function() attributes { sym_visibility = "private" }

  // This function may be referenced externally.
  func @public_function()

  "live.user"() {uses = [@public_module::@nested_function,
                                      @private_function,
                                      @public_function]} : () -> ()

Depends On D72043

Reviewed By: mehdi_amini

Differential Revision: https://reviews.llvm.org/D72044
2020-01-13 16:10:13 -08:00
River Riddle c774840492 [mlir] Update the CallGraph for nested symbol references, and simplify CallableOpInterface
Summary:
This enables tracking calls that cross symbol table boundaries. It also simplifies some of the implementation details of CallableOpInterface, i.e. there can only be one region within the callable operation.

Depends On D72042

Reviewed By: jpienaar

Differential Revision: https://reviews.llvm.org/D72043
2020-01-13 15:51:28 -08:00
River Riddle 6fca03f0ca [mlir] Update the use-list algorithms in SymbolTable to support nested references.
Summary: This updates the use list algorithms to support querying from a specific symbol, allowing for the collection and detection of nested references. This works by walking the parent "symbol scopes" and applying the existing algorithm at each level.

Reviewed By: jpienaar

Differential Revision: https://reviews.llvm.org/D72042
2020-01-13 15:23:28 -08:00
River Riddle cb89c7e3f7 [mlir] Remove unnecessary assert for single region.
This was left over debugging.
2020-01-13 13:55:50 -08:00
River Riddle 4268e4f4b8 [mlir] Change the syntax of AffineMapAttr and IntegerSetAttr to avoid conflicts with function types.
Summary: The current syntax for AffineMapAttr and IntegerSetAttr conflict with function types, making it currently impossible to round-trip function types(and e.g. FuncOp) in the IR. This revision changes the syntax for the attributes by wrapping them in a keyword. AffineMapAttr is wrapped with `affine_map<>` and IntegerSetAttr is wrapped with `affine_set<>`.

Reviewed By: nicolasvasilache, ftynse

Differential Revision: https://reviews.llvm.org/D72429
2020-01-13 13:24:39 -08:00
Benjamin Kramer a2cd4fe6bf Unbreak the mlir build after 202ab273e6 2020-01-13 19:18:43 +01:00
Lorenzo Chelini 81e7922e83 [mlir] m_Constant()
Summary: Introduce m_Constant() which allows matching a constant operation without forcing the user also to capture the attribute value.

Differential Revision: https://reviews.llvm.org/D72397
2020-01-13 17:22:01 +01:00
Julian Gross 202ab273e6 [mlir] Added missing GPU lowering ops.
Summary:
This diff adds missing GPU lowering ops to MLIR.

Reviewers: herhut, pifon2a, ftynse

Tags: #pre-merge_beta_testing, #llvm

Differential Revision: https://reviews.llvm.org/D72439
2020-01-13 17:10:54 +01:00
Nicolas Vasilache e653d306ce [mlir][Linalg] Update ReshapeOp::build to be more idiomatic
Summary:
This diff makes it easier to create a `linalg.reshape` op
and adds an EDSC builder api test to exercise the new builders.

Reviewers: ftynse, jpienaar

Subscribers: mehdi_amini, rriddle, burmako, shauheen, antiagainst, arpith-jacob, mgester, lucyrfox, aartbik, liufengdb, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D72580
2020-01-13 10:56:07 -05:00
Pruthvi 3cad8ada49 Add zero_extendi and sign_extendi to intrinsic namespace
Summary:
- update zero_extendi and sign_extendi in edsc/intrinsic namespace
- Builder API test for zero_extendi and sign_extendi

Differential Revision: https://reviews.llvm.org/D72298
2020-01-13 10:23:21 +01:00
River Riddle 2bdf33cc4c [mlir] NFC: Remove Value::operator* and Value::operator-> now that Value is properly value-typed.
Summary: These were temporary methods used to simplify the transition.

Reviewed By: antiagainst

Differential Revision: https://reviews.llvm.org/D72548
2020-01-11 08:54:39 -08:00
Benjamin Kramer 7c7ca51583 Remove copy ctors identical to the default one. NFC.
Those do nothing but make the type no longer trivial to the compiler.
2020-01-11 16:54:53 +01:00
Lei Zhang 397215cc30 [mlir][ods] Support dialect specific content emission via hooks
Thus far we can only generate the same set of methods even for
operations in different dialects. This is problematic for dialects that
want to generate additional operation class methods programmatically,
e.g., a special builder method or attribute getter method. Apparently
we cannot update the OpDefinitionsGen backend every time when such
a need arises. So this CL introduces a hook into the OpDefinitionsGen
backend to allow dialects to emit additional methods and traits to
operation classes.

Differential Revision: https://reviews.llvm.org/D72514
2020-01-10 18:39:28 -05:00
Lei Zhang ca4a55fabb [mlir] NFC: put C++ code emission classes in their own files
This exposes thse classes so that they can be used in interfaces.

Differential Revision: https://reviews.llvm.org/D72514
2020-01-10 18:38:59 -05:00
Denis Khalikov 0b032d7ba7 [mlir][spirv] Fix typos related to (de)serialization.
Fix typos related to (de)serialization of spv.selection.

Differential Revision: https://reviews.llvm.org/D72503
2020-01-10 12:01:28 -05:00
Benjamin Kramer e49c3c8f2e Sprinkle some constexpr on default ctors so the compiler can diagnose unused instances. NFCI. 2020-01-10 14:59:24 +01:00
Nico Weber 01662aeb5d fix another typo to cycle bots 2020-01-09 23:36:34 -05:00
River Riddle 68c8b6c4cd [mlir] Use getDenseElementBitwidth instead of Type::getElementTypeBitWidth.
Summary: Some data values have a different storage width than the corresponding MLIR type, e.g. bfloat is currently stored as a double.

Reviewed By: nicolasvasilache

Differential Revision: https://reviews.llvm.org/D72478
2020-01-09 14:51:44 -08:00
Eric Schweitz 016bf03ef6 [mlir] add a missing dependency for Linalg conversion
We were seeing some occasional build failures that would come and go.
It appeared to be this missing dependence.

Differential Revision: https://reviews.llvm.org/D72419
2020-01-09 23:00:41 +01:00
Kern Handa ea67737b16 [mlir] mlir-cpu-runner test's cblas_interface should export functions on Windows
This change fixes the build on Windows, so that cblas_interface.dll
exports functions correctly and an implib is created and installed
correctly.

Currently, LLVM cannot be consumed on Windows after it has been
installed in a location because cblas_interface.lib is not
created/installed, thus failing the import check in `LLVMExports.cmake`.

Differential Revision: https://reviews.llvm.org/D72384
2020-01-09 22:55:46 +01:00
River Riddle fc3367dd5e [mlir] NFC: Move the state for managing SSA value names out of OperationPrinter and into a new class SSANameState.
Summary:
This reduces the complexity of OperationPrinter and simplifies the code by quite a bit. The SSANameState is now held by ModuleState. This is in preparation for a future revision that molds ModuleState into something that can be used by users for caching the printer state, as well as for implementing printAsOperand style methods.

Depends On D72292

Reviewed By: antiagainst

Differential Revision: https://reviews.llvm.org/D72293
2020-01-09 12:48:35 -08:00
Hiroshi Inoue 4a83f1e171 [mlir] fix test failure in EDSC/builder-api-test
This patch fixes a test failure on a non-intel (PowerPC64) box.
The two affine.load are independent and hence llvm may reorder them.
The CHECK lines are modified for supporting reordered case.

Differential Revision: https://reviews.llvm.org/D72435
2020-01-09 13:11:42 +00:00
Alex Zinenko 08778d8c4f [mlir][GPU] introduce utilities for promotion to workgroup memory
Introduce a set of function that promote a memref argument of a `gpu.func` to
workgroup memory using memory attribution. The promotion boils down to
additional loops performing the copy from the original argument to the
attributed memory in the beginning of the function, and back at the end of the
function using all available threads. The loop bounds are specified so as to
adapt to any size of the workgroup. These utilities are intended to compose
with other existing utilities (loop coalescing and tiling) in cases where the
distribution of work across threads is uneven, e.g. copying a 2D memref with
only the threads along the "x" dimension. Similarly, specialization of the
kernel to specific launch sizes should be implemented as a separate pass
combining constant propagation and canonicalization.

Introduce a simple attribute-driven pass to test the promotion transformation
since we don't have a heuristic at the moment.

Differential revision: https://reviews.llvm.org/D71904
2020-01-09 10:06:00 +01:00
Nicolas Vasilache 2d515e49d8 [mlir][VectorOps] Implement insert_strided_slice conversion
Summary:
This diff implements the progressive lowering of insert_strided_slice.
Two cases appear:
1. when the source and dest vectors have different ranks, extract the dest
subvector at the proper offset and reduce to case 2.
2. when they have the same rank N:
  a. if the source and dest type are the same, the insertion is trivial:
     just forward the source
  b. otherwise, iterate over all N-1 D subvectors and create an
     extract/insert_strided_slice/insert replacement, reducing the problem
     to vecotrs of the same N-1 rank.

This combines properly with the other conversion patterns to lower all the way to LLVM.

Reviewers: ftynse, rriddle, AlexEichenberger, andydavis1, tetuante, nicolasvasilache

Reviewed By: andydavis1

Subscribers: merge_guards_bot, mehdi_amini, jpienaar, burmako, shauheen, antiagainst, arpith-jacob, mgester, lucyrfox, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D72317
2020-01-09 03:13:01 -05:00
Nicolas Vasilache 65678d9384 [mlir][VectorOps] Implement strided_slice conversion
Summary:
This diff implements the progressive lowering of strided_slice to either:
  1. extractelement + insertelement for the 1-D case
  2. extract + optional strided_slice + insert for the n-D case.

This combines properly with the other conversion patterns to lower all the way to LLVM.

Appropriate tests are added.

Reviewers: ftynse, rriddle, AlexEichenberger, andydavis1, tetuante

Reviewed By: andydavis1

Subscribers: merge_guards_bot, mehdi_amini, jpienaar, burmako, shauheen, antiagainst, arpith-jacob, mgester, lucyrfox, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D72310
2020-01-09 03:03:51 -05:00
Ahmed Taei f84d320052 [MLIR] Don't use SSA names directly for std.view canonicalization test
Reviewers: rriddle, nicolasvasilache

Subscribers: mehdi_amini, jpienaar, burmako, shauheen, antiagainst, arpith-jacob, mgester, lucyrfox, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D72408
2020-01-08 14:39:35 -08:00
Ahmed Taei 1e25109f93 Canonicalize static alloc followed by memref_cast and std.view
Summary: Rewrite alloc, memref_cast, std.view into allo, std.view by droping memref_cast.

Reviewers: nicolasvasilache

Subscribers: mehdi_amini, rriddle, jpienaar, burmako, shauheen, antiagainst, arpith-jacob, mgester, lucyrfox, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D72379
2020-01-08 11:50:33 -08:00
Stella Stamenova 48b14e58ab [MLIR] Fix ML IR build on Windows with Visual Studio
Summary: Right now the path for each lib in whole_archive_link when MSVC is used as the compiler is not a full path - and it's not even the correct path when VS is used to build. This patch sets the lib path to a full path using CMAKE_CFG_INTDIR which means the path will be correct regardless of whether ninja, make or VS is used and it will always be a full path.

Reviewers: denis13, jpienaar

Reviewed By: jpienaar

Subscribers: mgorny, mehdi_amini, rriddle, jpienaar, burmako, shauheen, antiagainst, nicolasvasilache, arpith-jacob, mgester, lucyrfox, llvm-commits, asmith

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D72403
2020-01-08 10:40:04 -08:00
River Riddle 659f7d463b [mlir] NFC: Move the state for managing aliases out of ModuleState and into a new class AliasState.
Summary: This reduces the complexity of ModuleState and simplifies the code. A future revision will mold ModuleState into something that can be used by users for caching of printer state, as well as for implementing printAsOperand style methods.

Reviewed By: antiagainst

Differential Revision: https://reviews.llvm.org/D72292
2020-01-08 10:34:35 -08:00
Nicolas Vasilache 766ce87e9b [mlir][Linalg] Lower linalg.reshape to LLVM for the static case
Summary:
This diff adds lowering of the linalg.reshape op to LLVM.

A new descriptor is created with fields initialized as follows:
1. allocatedPTr, alignedPtr and offset are copied from the source descriptor
2. sizes are copied from the static destination shape
3. strides are copied from the static strides collected with `getStridesAndOffset`

Only the static case in which the target view conforms to strided memref
semantics is supported. Other cases are left for future work and will be added on
a per-need basis.

Reviewers: ftynse, mravishankar

Subscribers: mehdi_amini, rriddle, jpienaar, burmako, shauheen, antiagainst, arpith-jacob, mgester, lucyrfox, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D72316
2020-01-08 13:07:41 -05:00
Denis Khalikov eac01f63a6 [mlir][spirv] Add lowering for std.fpext, std.fptrunc, std.sitofp.
Differential Revision: https://reviews.llvm.org/D72137
2020-01-07 22:13:07 -05:00
Lei Zhang dab2921f77 Revert "[mlir][spirv] Add lowering for std.fpext, std.fptrunc, std.sitofp."
This reverts commit 7e7f849a6d because
it recorded the wrong commit author.
2020-01-07 22:11:17 -05:00
Denis Khalikov dd495e8a87 [mlir][spirv] Add lowering for std cmp ops.
Differential Revision: https://reviews.llvm.org/D72296
2020-01-07 21:51:51 -05:00
Denis Khalikov 9883b14cd1 [mlir][spirv] Add lowering for standard bit ops
Differential Revision: https://reviews.llvm.org/D72205
2020-01-07 21:45:54 -05:00
Lei Zhang 7e7f849a6d [mlir][spirv] Add lowering for std.fpext, std.fptrunc, std.sitofp.
Differential Revision: https://reviews.llvm.org/D72137
2020-01-07 21:28:49 -05:00
Nicolas Vasilache e3750cafdb [mlir][Linalg] Add a linalg.reshape op
Summary:
This diff adds a new operation to linalg to allow reshaping of an
existing view into a new view in the same buffer at the same offset.

More specifically:
The `linalg.reshape` op produces a new view whose sizes are a reassociation
of the original `view`. Depending on whether or not the reassociated
MemRefType is contiguous, the resulting memref may require explicit alloc
and copies.

A reassociation is defined as a continous grouping of dimensions and is
represented with a affine map array attribute. In the future, non-continous
groupings may be allowed (i.e. permutations, reindexings etc).

For now, it is assumed that either:
  1. a reassociation produces and consumes contiguous MemRefType or,
  2. the reshape op will be folded into its consumers (by changing the shape
     of the computations).
All other cases are undefined behavior and a reshape op may not lower to
LLVM if it cannot be proven statically that it does not require alloc+copy.

A reshape may either collapse or expand dimensions, depending on the
relationship between source and target memref ranks. The verification rule
is that the reassociation maps are applied to the memref with the larger
rank to obtain the memref with the smaller rank. In the case of a dimension
expansion, the reassociation maps can be interpreted as inverse maps.

Examples:

```mlir
   // Dimension collapse (i, j) -> i' and k -> k'
   %1 = linalg.reshape %0 [(i, j, k) -> (i, j),
                           (i, j, k) -> (k)] :
     memref<?x?x?xf32, stride_spec> into memref<?x?xf32, stride_spec_2>
```

```mlir
   // Dimension expansion i -> (i', j') and (k) -> (k')
   %1 = linalg.reshape %0 [(i, j, k) -> (i, j),
                           (i, j, k) -> (k)] :
     memref<?x?xf32, stride_spec> into memref<?x?x?xf32, stride_spec_2>
```

The relevant invalid and roundtripping tests are added.

Reviewers: AlexEichenberger, ftynse, rriddle, asaadaldien, yangjunpro

Subscribers: kiszk, merge_guards_bot, mehdi_amini, jpienaar, burmako, shauheen, antiagainst, arpith-jacob, mgester, lucyrfox, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D72168
2020-01-06 22:21:19 -05:00
Mark de Wever 1d549cff48 [NFC] Fixes -Wrange-loop-analysis warnings
This avoids new warnings due to D68912 adds -Wrange-loop-analysis to -Wall.

Differential Revision: https://reviews.llvm.org/D72210
2020-01-06 17:37:41 +01:00
Nicolas Vasilache d67c4cc2eb [mlir][Linalg] Reimplement and extend getStridesAndOffset
Summary: This diff reimplements getStridesAndOffset in a significantly simpler way by operating on the AffineExpr and calling into simplifyAffineExpr instead of rolling its own saturating arithmetic.

As a consequence it becomes quite simple to extend the behavior of getStridesAndOffset to encompass more cases by manipulating the AffineExpr more directly.
The divisions are still filtered out and continue to yield fully dynamic strides.
Simplifying the divisions is left for a later time if compelling use cases arise.

Relevant tests are added.

Reviewers: ftynse

Subscribers: mehdi_amini, rriddle, jpienaar, burmako, shauheen, antiagainst, arpith-jacob, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D72098
2020-01-06 09:41:38 -05:00
Kern Handa aab72f89b1 [mlir] Update mlir/CMakeLists.txt to install *.def files
This is needed to consume mlir after it has been installed of the source
tree. Without this, consuming mlir results a build error.

Differential Revision: https://reviews.llvm.org/D72232
2020-01-06 10:02:25 +01:00
MaheshRavishankar 8aae6455c0 [mlir][spirv] Update SPIR-V documentation with information about
lowering to SPIR-V dialect.

Add information about
- SPIRVTypeConverter
- SPIRVOpLowering
- Utility functions used in lowering to SPIR-V dialect.
2020-01-05 23:05:37 -08:00
Stella Laurenzo 7d82d20f37 Add missing mlir-headers target and add tablegen'd deps to it.
Summary:
Prior to this, "ninja install-mlir-headers" failed with an error indicating
the missing target. Verified that from a clean build, the installed
headers include generated files.

Subscribers: mgorny, mehdi_amini, rriddle, jpienaar, burmako, shauheen, antiagainst, nicolasvasilache, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D72045
2020-01-03 16:04:40 -08:00
Alexandre Ganea e19188af0a [mlir] Compilation fix: use LLVM_ATTRIBUTE_UNUSED following 6656e961c0
Differential Revision: https://reviews.llvm.org/D72124
2020-01-03 16:31:33 -05:00
River Riddle 0d9ca98c1a [mlir] Fix indexed_accessor_range to properly forward the derived class.
Summary: This fixes the return value of helper methods on the base range class.

Reviewed By: jpienaar

Differential Revision: https://reviews.llvm.org/D72127
2020-01-03 13:30:18 -08:00
Lei Zhang 5d5d5838ce [mlir] Enhance classof() checks in StructsGen
Previously we only check that each field is of the correct
mlir::Attribute subclass. This commit enhances to also consider
the attribute's types, by leveraging the constraints already
encoded in TableGen attribute definitions.

Reviewed By: rsuderman

Differential Revision: https://reviews.llvm.org/D72162
2020-01-03 15:13:16 -05:00
Nicolas Vasilache 786f51dca0 [mlir][Linalg] NFC - Post-commit format fix 2020-01-03 15:10:45 -05:00
Nicolas Vasilache 447dafdfc9 [mlir][Linalg] NFC - Hotfix GenericLoopNestBuilder compilation error on older gcc (-fpermissive)
This fixes the error:
```
  mlir/include/mlir/Dialect/Linalg/Utils/Utils.h:72:3: error:   from definition of 'template<class LoopTy> mlir::edsc::GenericLoopNestRangeBuilder<LoopTy>::GenericLoopNestRangeBuilder(llvm::ArrayRef<mlir::edsc::ValueHandle*>, llvm::ArrayRef<mlir::Value>)' [-fpermissive]
    GenericLoopNestRangeBuilder(ArrayRef<edsc::ValueHandle *> ivs,
```

This was tested independently on a Docker image with gcc-5 by jpienaar@
2020-01-03 15:09:23 -05:00
Lei Zhang 1570084d33 [mlir][spirv] Fix ADDITIONAL_HEADER_DIRS for SPIR-V libraries
SPIRV/ headers live under mlir/Dialect/.

Reviewed By: rriddle

Differential Revision: https://reviews.llvm.org/D72141
2020-01-03 15:06:09 -05:00
Nicolas Vasilache aaaf6c4560 [mlir][Linalg] NFC - Hotfix GenericLoopNestBuilder compilation error (-fpermissive)
This should fix the error:
```
mlir/include/mlir/Dialect/Linalg/Utils/Utils.h:72:3: error:   from definition of 'template<class LoopTy> mlir::edsc::GenericLoopNestRangeBuilder<LoopTy>::GenericLoopNestRangeBuilder(llvm::ArrayRef<mlir::edsc::ValueHandle*>, llvm::ArrayRef<mlir::Value>)' [-fpermissive]
   GenericLoopNestRangeBuilder(ArrayRef<edsc::ValueHandle *> ivs,
```
2020-01-03 14:30:35 -05:00
Ahmed Taei 14ee51581a [mlir][linalg] Lower linalg to affine loops
Reviewers: nicolasvasilache

Reviewed By: nicolasvasilache

Subscribers: mgester, lucyrfox, merge_guards_bot, AlexEichenberger, mravishankar, ftynse, mehdi_amini, rriddle, jpienaar, burmako, shauheen, antiagainst, nicolasvasilache, arpith-jacob, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D72094
2020-01-03 13:21:10 -05:00
Nicolas Vasilache a932f033a3 [mlir][Vector] NFC - Add documentation for the VectorOps dialect. 2020-01-03 13:14:24 -05:00
Lei Zhang b3d2867769 [mlir][spirv] Fix shader ABI attribute prefix and add verification
This commit fixes shader ABI attributes to use `spv.` as the prefix
so that they match the dialect's namespace. This enables us to add
verification hooks in the SPIR-V dialect to verify them.

Reviewed By: mravishankar

Differential Revision: https://reviews.llvm.org/D72062
2020-01-03 07:44:27 -05:00
Kazuaki Ishizaki a050327064 [mlir] NFC: Fix broken links in docs
Summary: This commit fixes missing links that are caused by the repository movement.

Reviewers: Jim, rriddle, jpienaar

Reviewed By: Jim, rriddle, jpienaar

Subscribers: arpith-jacob, mehdi_amini, rriddle, jpienaar, burmako, shauheen, antiagainst, nicolasvasilache, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D72065
2020-01-03 10:26:27 +08:00
River Riddle fd01d8626c [mlir] Rewrite the internal representation of OpResult to be optimized for memory.
Summary:
This changes the implementation of OpResult to have some of the results be represented inline in Value, via a pointer int pair of Operation*+result number, and the rest being trailing objects on the main operation. The full details of the new representation is detailed in the proposal here:
https://groups.google.com/a/tensorflow.org/g/mlir/c/XXzzKhqqF_0/m/v6bKb08WCgAJ

The only difference between here and the above proposal is that we only steal 2-bits for the Value kind instead of 3. This means that we can only fit 2-results inline instead of 6. This allows for other users to steal the final bit for PointerUnion/etc. If necessary, we can always steal this bit back in the future to save more space if 3-6 results are common enough.

Reviewed By: jpienaar

Differential Revision: https://reviews.llvm.org/D72020
2020-01-02 14:40:09 -08:00
Jacques Pienaar 8f1caf518f [mlir] Only generate default for uncovered cases
Have to explicitly check if all cases are covered instead.
2020-01-02 12:55:14 -08:00
Jacques Pienaar f533fa3af5 [mlir] Revert default case that was needed
This one isn't always complete.
2020-01-02 12:32:41 -08:00
Jacques Pienaar 98a88c1bee [mlir] Add parenthesis to avoid -Wparentheses 2020-01-02 12:30:53 -08:00
Jacques Pienaar 3d83d8259c [mlir] Remove redudant default cases
These provide no value and trigger -Wcovered-switch-default.
2020-01-02 12:24:42 -08:00
Lei Zhang 98856b22cd [mlir][spirv] Update SPIR-V enums and ops with availability spec
This commit updates gen_spirv_dialect.py to query the grammar and
generate availability spec for various enum attribute definitions
and all defined ops.

Reviewed By: mravishankar

Differential Revision: https://reviews.llvm.org/D72095
2020-01-02 14:09:02 -05:00
Nicolas Vasilache 2140a973f2 [mlir][Linalg] Extend generic ops to allow tensors
Summary:
    This diff adds support to allow `linalg.generic` and
    `linalg.indexed_generic` to take tensor input and output
    arguments.

    The subset of output tensor operand types must appear
    verbatim in the result types after an arrow. The parser,
    printer and verifier are extended to accomodate this
    behavior.

    The Linalg operations now support variadic ranked tensor
    return values. This extension exhibited issues with the
    current handling of NativeCall in RewriterGen.cpp. As a
    consequence, an explicit cast to `SmallVector<Value, 4>`
    is added in the proper place to support the new behavior
    (better suggestions are welcome).

    Relevant cleanups and name uniformization are applied.

    Relevant invalid and roundtrip test are added.

    Reviewers: mehdi_amini, rriddle, jpienaar, antiagainst, ftynse

    Subscribers: burmako, shauheen, llvm-commits

    Tags: #llvm

    Differential Revision: https://reviews.llvm.org/D72022
2020-01-02 13:54:57 -05:00
Lei Zhang a81cb1b8bf [mlir][spirv] Allow specifying availability on enum attribute cases
Lots of SPIR-V ops take enum attributes and certain enum cases
need extra capabilities or extensions to be available. This commit
extends to allow specifying availability spec on enum cases.
Extra utility functions are generated for the corresponding enum
classes to return the availability requirement. The availability
interface implemention for a SPIR-V op now goes over all enum
attributes to collect the availability requirements.

Reviewed By: mravishankar

Differential Revision: https://reviews.llvm.org/D71947
2020-01-02 13:19:44 -05:00
River Riddle 97864f4f3a Fix some corner cases missed by D71955
* replaceAllUsesWith may be supplied with a null value.
* some compilers fail to implicitly convert single result operations to
OpaqueValue, so add an explicit OpOperand::set(Value) method.
2020-01-02 10:03:42 -08:00
Nico Weber 846bf1d43f fix doc grammar-o to cycle bots 2020-01-02 12:11:59 -05:00
Nicolas Vasilache cd17c06989 [mlir][Linalg] NFC - Make consistent use of op.emitOpError
Summary: This is part of an ongoing cleanup and uniformization work.

Reviewers: ftynse

Subscribers: mehdi_amini, rriddle, jpienaar, burmako, shauheen, antiagainst, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D72084
2020-01-02 10:12:14 -05:00
Nicolas Vasilache a9d9aadcdf [mlir][Linalg] NFC - Cleanup Linalg Declarative Transformations
Summary:
This is part of an ongoing cleanup and uniformization work.

This diff performs 3 types of cleanups:
1. Uniformize transformation names.
2. Replace all pattern operands that need not be captured by `$_`
3. Replace all usage of pattern captured op by the normalized `op` name (instead of positional parameters such as `$0`)

Reviewers: ftynse

Subscribers: mehdi_amini, rriddle, jpienaar, burmako, shauheen, antiagainst, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D72081
2020-01-02 10:11:37 -05:00
Nicolas Vasilache 324fd5902a [mlir][Linalg] NFC - Rename ViewTraits -> StructuredOpTraits
Summary: This is part of an ongoing cleanup and uniformization work.

Reviewers: ftynse

Subscribers: mehdi_amini, rriddle, jpienaar, burmako, shauheen, antiagainst, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D72079
2020-01-02 09:40:25 -05:00
Nicolas Vasilache afc25a43dc [mlir][Linalg] NFC - Rename LinalgGeneric -> GenericLinalg
Summary: This is part of an ongoing cleanup and uniformization work.

Subscribers: mehdi_amini, rriddle, jpienaar, burmako, shauheen, antiagainst, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D72078
2020-01-02 09:30:34 -05:00
Lei Zhang 0359e1d6be [mlir][spirv] NFC: Move shader ABI attributes to a new file
This allows us to include the definitions of these attributes in
other files without pulling in all dependencies for lowering.

Reviewed By: mravishankar

Differential Revision: https://reviews.llvm.org/D72054
2020-01-01 22:43:09 -05:00
Lei Zhang 5d38b2610f [mlir][spirv] Fix links in docs and update dialect docs
Summary:
This commit fixes links to code directories and uses doc links on
mlir.llvm.org where possible. The docs in TableGen dialect definition
is also updated to reflect recent developments.

Reviewed By: mravishankar

Differential Revision: https://reviews.llvm.org/D72051
2020-01-01 22:39:51 -05:00
Fangrui Song eeef50b1fe [mlir] Fix -Wrange-loo-analysis warnings
for (const auto &x : llvm::zip(..., ...))

->

for (auto x : llvm::zip(..., ...))

The return type of zip() is a wrapper that wraps a tuple of references.

> warning: loop variable 'p' is always a copy because the range of type 'detail::zippy<detail::zip_shortest, ArrayRef<long> &, ArrayRef<long> &>' does not return a reference [-Wrange-loop-analysis]
2020-01-01 16:06:04 -08:00
Alexandre Ganea 6656e961c0 [mlir] Fix compilation warnings
Fixes:
- (MSVC) F:\llvm-project\mlir\lib\Dialect\Linalg\Analysis\DependenceAnalysis.cpp(103): warning C4551: function call missing argument list
- (Clang) tools\mlir\lib\Dialect\SPIRV\SPIRVCanonicalization.inc(232,1): warning: unused function 'populateWithGenerated' [-Wunused-function]
2020-01-01 17:29:04 -05:00
Alexandre Ganea 316f6003ef [mlir] Fix linking with LLD
The issue is that /WHOLEARCHIVE is interpreted differently in LLD, which needs the same exact path as the .lib; whereas link.exe can take the library name, withoutout a path or extension, if that was already supplied on the cmd-line. I'll write a follow-up patch to fix the issue in LLD.
2020-01-01 17:29:04 -05:00
Alexandre Ganea 2b223bd1c7 [mlir] Fix warnings when compiling with Clang 9.0
Fixes: warning: comparison of integers of different signs: 'const unsigned int' and '(anonymous namespace)::OperationPrinter::(anonymous enum at F:\llvm-project\mlir\lib\IR\AsmPrinter.cpp:1444:3)' [-Wsign-compare]
2020-01-01 17:29:04 -05:00
Jacques Pienaar 7544cb8807 [mlir][docs] Remove redundant path prefix
./ is not needed.
2019-12-31 11:03:40 -08:00
Jacques Pienaar 430bba2a0f [mlir] Make code blocks more consistent
Use the same form specification for the same type of code.
2019-12-31 09:54:16 -08:00
Nicolas Vasilache f5b7dd3c9e [mlir][Linalg] Delete unused LinalgLibraryOps.td
Summary: This has been previously renamed to LinalgStructuredOps.td

Reviewers: ftynse

Subscribers: mehdi_amini, rriddle, jpienaar, burmako, shauheen, antiagainst, llvm-commits, ftynse

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D72013
2019-12-31 09:58:33 -05:00
River Riddle 0d6ebb4f0d [mlir] Refactor operation results to use a single use list for all results of the operation.
Summary: A new class is added, IRMultiObjectWithUseList, that allows for representing an IR use list that holds multiple sub values(used in this case for OpResults). This class provides all of the same functionality as the base IRObjectWithUseList, but for specific sub-values. This saves a word per operation result and is a necessary step in optimizing the layout of operation results. For now the use list is placed on the operation itself, so zero-result operations grow by a word. When the work for optimizing layout is finished, this can be moved back to being a trailing object based on memory/runtime benchmarking.

Reviewed By: jpienaar

Differential Revision: https://reviews.llvm.org/D71955
2019-12-30 20:50:07 -08:00
Kern Handa cde071c4bf [mlir] Update mlir/CMakeLists.txt to install *.td files
Currently when you build the `install` target, TableGen files don't get
installed.

TableGen files are needed when authoring new MLIR dialects, but right
now they're missing when using the pre-built binaries.

Differential Revision: https://reviews.llvm.org/D71958
2019-12-29 18:05:11 +01:00
Tung Le Duc e5957ac3d7 [mlir] Fix the wrong computation of dynamic strides for lowering AllocOp to LLVM
Leftover change from before the MLIR merge, reviewed at accepted at
https://github.com/tensorflow/mlir/pull/338.
2019-12-28 23:33:28 +01:00
River Riddle f83a8efe87 [mlir] Merge the successor operand count into BlockOperand.
Summary: The successor operand counts are directly tied to block operands anyways, and this simplifies the trailing objects of Operation(i.e. one less computation to perform).

Reviewed By: mehdi_amini

Differential Revision: https://reviews.llvm.org/D71949
2019-12-27 20:35:31 -08:00
Lei Zhang b30d87a90b [mlir][spirv] Add basic definitions for supporting availability
SPIR-V has a few mechanisms to control op availability: version,
extension, and capabilities. These mechanisms are considered as
different availability classes.

This commit introduces basic definitions for modelling SPIR-V
availability classes. Specifically, an `Availability` class is
added to SPIRVBase.td, along with two subclasses: MinVersion
and MaxVersion for versioning. SPV_Op is extended to take a
list of `Availability`. Each `Availability` instance carries
information for generating op interfaces for the corresponding
availability class and also the concrete availability
requirements.

With the availability spec on ops, we can now auto-generate the
op interfaces of all SPIR-V availability classes and also
synthesize the op's implementations of these interfaces. The
interface generation is done via new TableGen backends
-gen-avail-interface-{decls|defs}. The op's implementation is
done via -gen-spirv-avail-impls.

Differential Revision: https://reviews.llvm.org/D71930
2019-12-27 16:25:09 -05:00
Lei Zhang 596012b256 [mlir][spirv] Update docs regarding how to define new ops and types
This commit expands on the steps of defining a new SPIR-V op and
also provides pointers on how to define a new SPIR-V specific type.

Differential Revision: https://reviews.llvm.org/D71928
2019-12-27 15:33:09 -05:00
MaheshRavishankar c3d3569d4c [mlir] Convert std.and/std.or ops to spv.LogicalAnd/spv.LogicalOr
The conversion from std.and/std.or to spv.LogicalAnd/spv.LogicalOr is
only valid for boolean (i1) types. Modify BinaryOpPattern in
StandardToSPIRV.td to allow limiting the type of the operands for
which the pattern is applied.

Differential Revision: https://reviews.llvm.org/D71881
2019-12-27 11:33:17 -08:00
Lei Zhang 69d85f805a [MLIR][spirv] Fix links in docs after repo migration
Summary:
This commit updates links to SPIR-V dialect code to LLVM monorepo
on GitHub. It also points to the operation doc on mlir.llvm.org.

Reviewers: mravishankar, denis13, ftynse

Reviewed By: ftynse

Subscribers: merge_guards_bot, mehdi_amini, rriddle, jpienaar, burmako, shauheen, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D71926
2019-12-27 09:25:38 -05:00
wyzhao 2e5a75581c [mlir] fix typo in a comment
Trivial patch, reviewed and accepted on
https://github.com/tensorflow/mlir/pull/336 before MLIR merge.
2019-12-27 12:15:26 +01:00
Uday Bondhugula be775a0038 [MLIR] [NFC] fix unused var warning
Summary:
Fix this warning:
`
[69/106] Building CXX object tools/mlir/lib/Dialect/StandardOps/CMakeFiles/MLIRStandardOps.dir/Ops.cpp.o
/home/uday/llvm-project/mlir/lib/Dialect/StandardOps/Ops.cpp: In member function ‘virtual mlir::PatternMatchResult {anonymous}::ViewOpShapeFolder::matchAndRewrite(mlir::ViewOp, mlir::PatternRewriter&) const’:
/home/uday/llvm-project/mlir/lib/Dialect/StandardOps/Ops.cpp:2575:14: warning: variable ‘dynamicOffsetOperandCount’ set but not used [-Wunused-but-set-variable]
 2575 |     unsigned dynamicOffsetOperandCount = 0;
`

Reviewers: rriddle, mehdi_amini, ftynse

Reviewed By: ftynse

Subscribers: jpienaar, burmako, shauheen, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D71922
2019-12-27 12:04:46 +01:00
Alex Zinenko cda94d3e8a [mlir] Floating constants for import-llvm
Summary:
`mlir-translate -import-llvm test.ll`  was going into segmentation fault if `test.ll` had `float` or `double` constants.
For example,
```
%3 = fadd double 3.030000e+01, %0
```
Now, it is handled in `Importer::getConstantAsAttr` (similar behaviour as normal integers)
Added tests for FP arithmetic

Reviewers: ftynse, mehdi_amini

Reviewed By: ftynse, mehdi_amini

Subscribers: shauheen, mehdi_amini, rriddle, jpienaar, burmako, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D71912
2019-12-27 11:48:24 +01:00
Eric Christopher 371038e3ff Add an __attribute__((unused)) to populateWithGenerated since it might
not be used where defined and is autogenerated.
2019-12-26 18:48:59 -08:00
Eric Christopher e1838a1789 Fix a -Wcovered-switch-default warning by moving the unreachable out of the
covered switch.
2019-12-26 18:34:41 -08:00
Eric Christopher 3d18ce7154 Remove an unused static function. 2019-12-26 18:34:14 -08:00
Eric Christopher 3009cee75f Fix a -Wcovered-switch-default warning by moving the unreachable out of the
covered switch.
2019-12-26 18:29:54 -08:00
Eric Christopher 30617e4b9c Remove unused static function. 2019-12-26 18:20:15 -08:00
Mehdi Amini b52cb5688b Add a clang-tidy configuration file for MLIR, it is using camelBack for naming at the moment 2019-12-26 21:42:01 +00:00
chelxom d2a8e14177 Fix the MLIR Vim syntax file: the keyword group was missing 2019-12-26 04:50:38 +00:00
Hideto Ueno 1497a4350e [MLIR][NFC] Insert const_cast to avoid warning
Reviewers: rriddle

Reviewed By: rriddle

Subscribers: mehdi_amini

Differential Revision: https://reviews.llvm.org/D71853
2019-12-25 15:51:26 +09:00
Fangrui Song 020ca0cf2f [mlir] Fix -Wunneeded-internal-declaration 2019-12-24 10:33:30 -08:00
Sylvestre Ledru 95b69a7082
mlir README.md: Fix the syntax 2019-12-24 13:31:07 +01:00
Mehdi Amini 34766da067 Add the Apache2 with LLVM exceptions license to MLIR
It seems that every subproject has a license file instead of having a top-level one.
2019-12-24 00:58:06 -08:00
Mehdi Amini c6a5534ea4 Remove static MLIR doc ; they are already on the website 2019-12-24 00:53:35 -08:00
River Riddle 1399281d58 NFC: Rename printOptionValue to printValue to fix MSVC build.
MSVC has trouble resolving the static 'printOptionValue' from the method on llvm:🆑:opt/list. This change renames the static method to avoid this conflict.
2019-12-23 19:35:25 -08:00
Mehdi Amini 5b4a01d4a6 Adjust some MLIR paths and docs 2019-12-24 02:23:01 +00:00
Mehdi Amini ac6dce12e0 Remove pybind11-based bindings
These bindings were added as an experiment, and never had a CMake configuration.
We will bring back python bindings after picking carefully our dependency and the kind
of layering we expect to expose for these bindings.

PiperOrigin-RevId: 286963717
2019-12-23 17:44:06 -08:00
River Riddle 21610e6651 Refactor the way that pass options are specified.
This change refactors pass options to be more similar to how statistics are modeled. More specifically, the options are specified directly on the pass instead of in a separate options class. (Note that the behavior and specification for pass pipelines remains the same.) This brings about several benefits:
* The specification of options is much simpler
* The round-trip format of a pass can be generated automatically
* This gives a somewhat deeper integration with "configuring" a pass, which we could potentially expose to users in the future.

PiperOrigin-RevId: 286953824
2019-12-23 16:48:22 -08:00
River Riddle e62a69561f NFC: Replace ValuePtr with Value and remove it now that Value is value-typed.
ValuePtr was a temporary typedef during the transition to a value-typed Value.

PiperOrigin-RevId: 286945714
2019-12-23 16:36:53 -08:00
River Riddle 5d5bd2e1da Change the `notifyRootUpdated` API to be transaction based.
This means that in-place, or root, updates need to use explicit calls to `startRootUpdate`, `finalizeRootUpdate`, and `cancelRootUpdate`. The major benefit of this change is that it enables in-place updates in DialectConversion, which simplifies the FuncOp pattern for example. The major downside to this is that the cases that *may* modify an operation in-place will need an explicit cancel on the failure branches(assuming that they started an update before attempting the transformation).

PiperOrigin-RevId: 286933674
2019-12-23 16:26:15 -08:00
Lei Zhang a5d5d29125 Update SPIR-V.md
This CL updates SPIR-V.md to reflect recent developments
in the SPIR-V dialect and its conversions.

Along the way, also updates the doc for define_inst.sh.

PiperOrigin-RevId: 286933546
2019-12-23 16:15:52 -08:00
River Riddle ab46543ceb Resubmit: ReImplement the Value classes as value-typed objects wrapping an internal pointer storage.
This will enable future commits to reimplement the internal implementation of OpResult without needing to change all of the existing users. This is part of a chain of commits optimizing the size of operation results.

PiperOrigin-RevId: 286930047
2019-12-23 16:05:05 -08:00
MLIR Team 268365ab01 Automated rollback of commit f603a50109
PiperOrigin-RevId: 286924059
2019-12-23 15:54:44 -08:00
River Riddle f603a50109 ReImplement the Value classes as value-typed objects wrapping an internal pointer storage.
This will enable future commits to reimplement the internal implementation of OpResult without needing to change all of the existing users. This is part of a chain of commits optimizing the size of operation results.

PiperOrigin-RevId: 286919966
2019-12-23 15:44:00 -08:00
Mehdi Amini 56222a0694 Adjust License.txt file to use the LLVM license
PiperOrigin-RevId: 286906740
2019-12-23 15:33:37 -08:00
River Riddle 35807bc4c5 NFC: Introduce new ValuePtr/ValueRef typedefs to simplify the transition to Value being value-typed.
This is an initial step to refactoring the representation of OpResult as proposed in: https://groups.google.com/a/tensorflow.org/g/mlir/c/XXzzKhqqF_0/m/v6bKb08WCgAJ

This change will make it much simpler to incrementally transition all of the existing code to use value-typed semantics.

PiperOrigin-RevId: 286844725
2019-12-22 22:00:23 -08:00
Manuel Freiberger 22954a0e40 Add integer bit-shift operations to the standard dialect.
Rename the 'shlis' operation in the standard dialect to 'shift_left'. Add tests
for this operation (these have been missing so far) and add a lowering to the
'shl' operation in the LLVM dialect.

Add also 'shift_right_signed' (lowered to LLVM's 'ashr') and 'shift_right_unsigned'
(lowered to 'lshr').

The original plan was to name these operations 'shift.left', 'shift.right.signed'
and 'shift.right.unsigned'. This works if the operations are prefixed with 'std.'
in MLIR assembly. Unfortunately during import the short form is ambigous with
operations from a hypothetical 'shift' dialect. The best solution seems to omit
dots in standard operations for now.

Closes tensorflow/mlir#226

PiperOrigin-RevId: 286803388
2019-12-22 10:02:13 -08:00
Alex Zinenko dcc14f0865 Make Type and Attribute classes trivially copyable
This requires using explicitly default copy constructor and copy assignment
operator instead of hand-rolled ones. These classes are indeed cheap to copy
since they are wrappers around a pointer to the implementation. This change
makes sure templated code can use standard type traits to understand that
copying such objects is cheap and appeases analysis tools such as clang-tidy.

PiperOrigin-RevId: 286725565
2019-12-21 09:45:24 -08:00
River Riddle ee71ca1d5c NFC: Move the classes related to Pass options into a new header file PassOptions.h
This will make refactoring and adding additional features to the pass options infrastructure simpler in followup commits.

PiperOrigin-RevId: 286687564
2019-12-20 22:45:52 -08:00
Aart Bik 1d47564a53 [VectorOps] unify vector dialect "subscripts"
PiperOrigin-RevId: 286650682
2019-12-20 15:33:04 -08:00
Aart Bik 67c019ddac [VectorOps] remove redundant returns from invalid ops test
PiperOrigin-RevId: 286640660
2019-12-20 14:27:42 -08:00
Uday Bondhugula e5691c512f fix isValidDim for block arg case
- a block argument associated with an arbitrary op can't be a valid
  dimensional identifier; it has to be the block argument of either
  a function op or an affine.for.

Signed-off-by: Uday Bondhugula <uday@polymagelabs.com>

Closes tensorflow/mlir#331

COPYBARA_INTEGRATE_REVIEW=https://github.com/tensorflow/mlir/pull/331 from bondhugula:valid_dim 3273b4fcbaa31fb7b6671d93c9e42a6b2a6a4e4c
PiperOrigin-RevId: 286593693
2019-12-20 09:44:03 -08:00
Christian Sigg 42d46b4efa Add gpu.shuffle op.
This will allow us to lower most of gpu.all_reduce (when all_reduce
doesn't exist in the target dialect) within the GPU dialect, and only do
target-specific lowering for the shuffle op.

PiperOrigin-RevId: 286548256
2019-12-20 02:52:52 -08:00
Frank Laub 7811ad3c2b Allow dialect to create friendly names for region arguments
This is the block argument equivalent of the existing `getAsmResultNames` hook.

Closes tensorflow/mlir#329

COPYBARA_INTEGRATE_REVIEW=https://github.com/tensorflow/mlir/pull/329 from plaidml:flaub-region-arg-names fc7876f2d1335024e441083cd25263fd6247eb7d
PiperOrigin-RevId: 286523299
2019-12-19 22:16:07 -08:00
Jacques Pienaar b6d54a1ba3 Unique trait list during ODS Operator trait construction
Concatting lists in TableGen is easy, creating unique lists less so. There is no reason for duplicated op traits so we could throw an error instead but duplicates could occur due to concatting different list of traits in ODS (e.g., for convenience reasons), so just dedup them during Operator trait construction instead.

PiperOrigin-RevId: 286488423
2019-12-19 16:44:56 -08:00
Andy Davis 8020ad3e39 [VectorOps] Update vector transfer_read/write ops to operatate on memrefs with vector element type.
Update vector transfer_read/write ops to operatate on memrefs with vector element type.
This handle cases where the memref vector element type represents the minimal memory transfer unit (or multiple of the minimal memory transfer unit).

PiperOrigin-RevId: 286482115
2019-12-19 16:05:32 -08:00
Nicolas Vasilache 6685282253 Restructure and update Linalg ODS and documentation - NFC
This CL allows specifying an additional name for specifying the .td file that is used to generate the doc for a dialect. This is necessary for a dialect like Linalg which has different "types" of ops that are used in different contexts.

This CL also restructures the Linalg documentation and renames LinalgLibraryOps -> LinalgStructuredOps but is otherwise NFC.

PiperOrigin-RevId: 286450414
2019-12-19 13:17:35 -08:00
Andy Davis 1d798b1d27 [VectorOps] Add vector ReshapeOp to the VectorOps dialect.
Adds vector ReshapeOp to the VectorOps dialect. An aggregate vector reshape operation, which aggregates multiple hardware vectors, can enable optimizations during decomposition (e.g. loading one input hardware vector and performing multiple rotate and scatter store operations to the vector output).

PiperOrigin-RevId: 286440658
2019-12-19 12:27:59 -08:00
Alex Zinenko 1bcd8ef32f LLVMFuncOp: implement addEntryBlock
This function has been declared as a part of the LLVMFuncOp interface but never
implemented.

Closes tensorflow/mlir#325.

PiperOrigin-RevId: 286439619
2019-12-19 12:16:51 -08:00
Aart Bik 15f800f4bc [VectorOps] minor cleanup: vector dialect "subscripts" are i32
Introduces some centralized methods to move towards
consistent use of i32 as vector subscripts.

Note: sizes/strides/offsets attributes are still i64
PiperOrigin-RevId: 286434133
2019-12-19 11:51:08 -08:00
Alex Zinenko efadb6b838 Detemplatize ModuleTranslation::lookupValues
This function template has been introduced in the early days of MLIR to work
around the absence of common type for ranges of values (operands, block
argumeents, vectors, etc). Core IR now provides ValueRange for exactly this
purpose. Use it instead of the template parameter.

PiperOrigin-RevId: 286431338
2019-12-19 11:35:57 -08:00
Nicolas Vasilache 50f9be6d2d Add runtime utils support for print_memref_i8
This CL adds print_memref_i8 along with a unit test.

PiperOrigin-RevId: 286299237
2019-12-18 17:32:35 -08:00
Aart Bik a1e84db66e [VectorOps] Replace iostream with stdio in support lib for vector.print
PiperOrigin-RevId: 286252829
2019-12-18 13:24:30 -08:00
Sean Silva 553f794b6f Add a couple useful LLVM_DEBUG's to the inliner.
This makes it easier to narrow down on ops that are preventing inlining.

PiperOrigin-RevId: 286243868
2019-12-18 12:33:30 -08:00
River Riddle 7b3adda8f4 Move the specializations of VectorTransferRewriter::matchAndRewrite back into the anonymous namespace.
This appeases the GCC bug related to specializations in a different namespace.

PiperOrigin-RevId: 286234667
2019-12-18 11:53:57 -08:00
Marcel Koester 6054610bbe Added LLVM ops and lowering phases from standard dialect for FAbs, FCeil, Cos, FNeg, CopySign.
Added test cases for the newly added LLVM operations and lowering features.

Closes tensorflow/mlir#300

COPYBARA_INTEGRATE_REVIEW=https://github.com/tensorflow/mlir/pull/300 from dfki-jugr:std_to_llvm da6168bbc1a369ae2e99ad3881fdddd82f075dd4
PiperOrigin-RevId: 286231169
2019-12-18 11:42:43 -08:00
Aart Bik d9b500d3bb [VectorOps] Add vector.print definition, with lowering support
Examples:

  vector.print %f : f32
  vector.print %x : vector<4xf32>
  vector.print %y : vector<3x4xf32>
  vector.print %z : vector<2x3x4xf32>

LLVM lowering replaces these with fully unrolled calls
into a small runtime support library that provides some
basic printing operations (single value, opening closing
bracket, comma, newline).

PiperOrigin-RevId: 286230325
2019-12-18 11:31:34 -08:00
River Riddle c169852fc5 NFC: Remove forbidden include of <iostream>
See: https://llvm.org/docs/CodingStandards.html#include-iostream-is-forbidden
PiperOrigin-RevId: 286226467
2019-12-18 11:20:31 -08:00
River Riddle 29807ff5e4 Add support for providing a default implementation for an interface method.
This enables providing a default implementation of an interface method. This method is defined on the Trait that is attached to the operation, and thus has all of the same constraints and properties as any other interface method. This allows for interface authors to provide a conservative default implementation for certain methods, without requiring that all users explicitly define it. The default implementation can be specified via the argument directly after the interface method body:

  StaticInterfaceMethod<
    /*desc=*/"Returns whether two array of types are compatible result types for an op.",
    /*retTy=*/"bool",
    /*methodName=*/"isCompatibleReturnTypes",
    /*args=*/(ins "ArrayRef<Type>":$lhs, "ArrayRef<Type>":$rhs),
    /*methodBody=*/[{
      return ConcreteOp::isCompatibleReturnTypes(lhs, rhs);
    }],
    /*defaultImplementation=*/[{
      /// Returns whether two arrays are equal as strongest check for
      /// compatibility by default.
      return lhs == rhs;
    }]

PiperOrigin-RevId: 286226054
2019-12-18 11:09:11 -08:00
Jacques Pienaar d7e2cc9bd1 Update code block designations
'```mlir' is used to indicate the code block is MLIR code/should use MLIR syntax
highlighting, while '{.mlir}' was a markdown extension that used a style file
to color the background differently of the code block. The background color
extension was a custom one that we can retire given we have syntax
highlighting.

Also change '```td' to '```tablegen' to match chroma syntax highlighting
designation.

PiperOrigin-RevId: 286222976
2019-12-18 10:57:59 -08:00
River Riddle 2666b97314 NFC: Cleanup non-conforming usages of namespaces.
* Fixes use of anonymous namespace for static methods.
* Uses explicit qualifiers(mlir::) instead of wrapping the definition with the namespace.

PiperOrigin-RevId: 286222654
2019-12-18 10:46:48 -08:00
Uday Bondhugula 47034c4bc5 Introduce prefetch op: affine -> std -> llvm intrinsic
Introduce affine.prefetch: op to prefetch using a multi-dimensional
subscript on a memref; similar to affine.load but has no effect on
semantics, but only on performance.

Provide lowering through std.prefetch, llvm.prefetch and map to llvm's
prefetch instrinsic. All attributes reflected through the lowering -
locality hint, rw, and instr/data cache.

  affine.prefetch %0[%i, %j + 5], false, 3, true : memref<400x400xi32>

Signed-off-by: Uday Bondhugula <uday@polymagelabs.com>

Closes tensorflow/mlir#225

COPYBARA_INTEGRATE_REVIEW=https://github.com/tensorflow/mlir/pull/225 from bondhugula:prefetch 4c3b4e93bc64d9a5719504e6d6e1657818a2ead0
PiperOrigin-RevId: 286212997
2019-12-18 10:00:04 -08:00
River Riddle 4562e389a4 NFC: Remove unnecessary 'llvm::' prefix from uses of llvm symbols declared in `mlir` namespace.
Aside from being cleaner, this also makes the codebase more consistent.

PiperOrigin-RevId: 286206974
2019-12-18 09:29:20 -08:00
Alex Zinenko 24ab8362f2 Move function template definition to the header file. NFC
The definition of the function template LLVM::ModuleTranslation::lookupValues
has been located in a source file. As long as it has been the only file that
actually called into the function, this did not cause any problem. However, it
creates linking issues if the function is used from other translation units.

PiperOrigin-RevId: 286203078
2019-12-18 09:10:23 -08:00
Jacques Pienaar abcf5ff0cc Fix line break in LangRef
This was munging up the example with the text.

PiperOrigin-RevId: 286201762
2019-12-18 08:59:10 -08:00
Alex Zinenko 40ef46fba4 Harden the requirements to memory attribution types in gpu.func
When memory attributions are present in `gpu.func`, require that they are of
memref type and live in memoryspaces 3 and 5 for workgroup and private memory
attributions, respectively. Adapt the conversion from the GPU dialect to the
NVVM dialect to drop the private memory space from attributions as NVVM is able
to model them as local `llvm.alloca`s in the default memory space.

PiperOrigin-RevId: 286161763
2019-12-18 03:38:55 -08:00
MLIR Team c6c6a74d55 Add support for float and string attributes to the C API and python bindings
PiperOrigin-RevId: 286115042
2019-12-17 20:19:16 -08:00
River Riddle 5a0d4803f7 NFC: Use this-> to appease GCC bug related to template lambda.
GCC is unable to properly implicitly capture 'this' in generic lambdas. This bug is not fixed until 7.1.0:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67274

PiperOrigin-RevId: 286083427
2019-12-17 16:19:47 -08:00
River Riddle 74278dd01e NFC: Use TypeSwitch to simplify existing code.
PiperOrigin-RevId: 286066371
2019-12-17 14:57:41 -08:00
Andy Davis 6fa3bd5b3e Add pattern rewrite which splits a vector TransferWriteOp into slices according to the unrolling/slicing scheme of its InsertSlicesOp operand.
PiperOrigin-RevId: 286042578
2019-12-17 13:17:10 -08:00
Mahesh Ravishankar 319cca3bbe Add missing virtual inliner interface method in SPIR-V dialect.
The inline interface uses two methods to check legality of inling:
1) Can a region be inlined into another.
2) Can an operation be inlined into another.
Setting the former to true, allows the inliner to use the second for
legality checks. Add this method to the SPIR-V dialect inlining
interface.

PiperOrigin-RevId: 286041734
2019-12-17 13:06:05 -08:00
Alex Zinenko 42b3fe8335 Make it possible to override the lowering of MemRef to the LLVM dialect. NFC.
The lowering of MemRef types to the LLVM dialect is connected to the underlying
runtime representation of structured memory buffers. It has changed several
times in the past and reached the current state of a LLVM structured-typed
descriptor containing two pointers and all sizes. In several reported use
cases, a different, often simpler, lowering scheme is required. For example,
lowering statically-shaped memrefs to bare LLVM pointers to simplify aliasing
annotation. Split the pattern population functions into those include
memref-related operations and the remaining ones. Users are expected to extend
TypeConverter::convertType to handle the memref types differently.
PiperOrigin-RevId: 286030610
2019-12-17 12:10:04 -08:00
Alex Zinenko 62f498dcb7 ConversionToLLVMDialect doc: update the syntax for LLVM types
The syntax for LLVM dialect types changed twice since this document was
introduced. First, the quoted types are only prefixed with the dialect name
`!llvm` rather than with `!llvm.type`. Second, for types that are simple enough
(e.g., MLIR identifiers), the pretty form can be used instead of the quoted
form. The relevant commits updated the dialect documentation, but not the
conversion documentation. Use the valid type names in the conversion
documentation.

PiperOrigin-RevId: 286026153
2019-12-17 11:55:11 -08:00
Alex Zinenko 0bdc72d2df StdToLLVM conversion: drop getMemRefElementType utility function
This function has become redundant with MemRefDescriptor::getElementType and is
no longer necessary. Use the MemRefDescriptor pervasively to concentrate
descriptor-related logic in one place and drop the utility function.

PiperOrigin-RevId: 286024168
2019-12-17 11:43:59 -08:00
Alex Zinenko 651eaa03e8 Homogenize the description of the MemRef conversion to the LLVM dialect
The conversion procedure has been updated to reflect the most recent MemRef
descriptor proposal, but the documentation was only updated for the type
conversion, omitting the address computation section. Make sure the two
sections agree.

PiperOrigin-RevId: 286022684
2019-12-17 11:32:50 -08:00
Andy Davis d1fb285b32 Add pattern rewrite to forward vector tuple elements to their users.
User(TupleGetOp(ExtractSlicesOp(InsertSlicesOp(TupleOp(Producer))) -> User(Producer)

PiperOrigin-RevId: 286020249
2019-12-17 11:21:45 -08:00
Jin Mingjian 9f45a22441 fix a typo in OpDefinitions doc
[{ matched with }], rather than ]}

Closes tensorflow/mlir#320

COPYBARA_INTEGRATE_REVIEW=https://github.com/tensorflow/mlir/pull/320 from jinmingjian:patch-1 6b0870d02284f023bda2b28380960eb31d34f3b6
PiperOrigin-RevId: 286007638
2019-12-17 10:25:52 -08:00
River Riddle f44cf23297 Add a new utility class TypeSwitch to ADT.
This class provides a simplified mechanism for defining a switch over a set of types using llvm casting functionality. More specifically, this allows for defining a switch over a value of type T where each case corresponds to a type(CaseT) that can be used with dyn_cast<CaseT>(...). An example is shown below:

// Traditional piece of code:
Operation *op = ...;
if (auto constant = dyn_cast<ConstantOp>(op))
  ...;
else if (auto return = dyn_cast<ReturnOp>(op))
  ...;
else
  ...;

// New piece of code:
Operation *op = ...;
TypeSwitch<Operation *>(op)
  .Case<ConstantOp>([](ConstantOp constant) { ... })
  .Case<ReturnOp>([](ReturnOp return) { ... })
  .Default([](Operation *op) { ... });

Aside from the above, TypeSwitch supports return values, void return, multiple types per case, etc. The usability is intended to be very similar to StringSwitch.

(Using c++14 template lambdas makes everything even nicer)
More complex example of how this makes certain things easier:
LogicalResult process(Constant op);
LogicalResult process(ReturnOp op);
LogicalResult process(FuncOp op);

TypeSwitch<Operation *, LogicalResult>(op)
  .Case<ConstantOp, ReturnOp, FuncOp>([](auto op) { return process(op); })
  .Default([](Operation *op) { return op->emitError() << "could not be processed"; });

PiperOrigin-RevId: 286003613
2019-12-17 10:08:06 -08:00
MLIR Team 6e581e29a4 Integrate from upstream at revision e4fce659a7.
PiperOrigin-RevId: 285982330
2019-12-17 08:13:14 -08:00
Andy Davis 038ad1d856 Add pattern rewrite which splits a vector TransferReadOp into slices according to the unrolling/slicing scheme of its ExtractSlicesOp user.
PiperOrigin-RevId: 285975613
2019-12-17 07:29:06 -08:00
Tres Popp 8d68fe684e Replace code with equivalent satisfiesLLVMModule() function call.
This is a general code cleanup and should be a NFC.

PiperOrigin-RevId: 285972718
2019-12-17 07:05:40 -08:00
Andy Davis 4e825c59be Update vector op unrolling transformation to generate ExtractSlicesOp and InsertSlicesOp (instead of less structured chain of StridedSliceOps and InsertStridedSliceOps).
PiperOrigin-RevId: 285968051
2019-12-17 06:27:01 -08:00
Mahesh Ravishankar 80ec474a65 Add atomic operations to SPIR-V dialect.
Some changes to the dialect generation script to allow specification
of different base class to derive from in ODS.

PiperOrigin-RevId: 285859230
2019-12-16 15:05:51 -08:00
Mahesh Ravishankar a0557ea9d6 Fix (de)serialization generation for SPV_ScopeAttr, SPV_MemorySemanticsAttr.
Scope and Memory Semantics attributes need to be serialized as a
constant integer value and the <id> needs to be used to specify the
value. Fix the auto-generated SPIR-V (de)serialization to handle this.

PiperOrigin-RevId: 285849431
2019-12-16 14:23:08 -08:00
Lei Zhang 659150b570 [spirv] Re-enable nested loop (de)serialization test
PiperOrigin-RevId: 285849308
2019-12-16 14:21:52 -08:00
Nicolas Vasilache 3c179b6575 Add edsc::ops for pointwise, conv and dilated_conv
This CL adds more Linalg EDSC ops and tests to support building pointwise operations along with conv and dilated_conv.
This also fixes a bug in the existing linalg_matmul EDSC and beefs up the test.

The current set of ops is already enough to build an interesting, albeit simple, model used internally.

PiperOrigin-RevId: 285838012
2019-12-16 13:42:38 -08:00
Andy Davis 11e92875f0 Add InsertSlicesOp to the VectorOps dialect.
PiperOrigin-RevId: 285830394
2019-12-16 12:56:38 -08:00
Alex Zinenko 6273fa0c6a Plug gpu.func into the GPU lowering pipelines
This updates the lowering pipelines from the GPU dialect to lower-level
dialects (NVVM, SPIRV) to use the recently introduced gpu.func operation
instead of a standard function annotated with an attribute. In particular, the
kernel outlining is updated to produce gpu.func instead of std.func and the
individual conversions are updated to consume gpu.funcs and disallow standard
funcs after legalization, if necessary. The attribute "gpu.kernel" is preserved
in the generic syntax, but can also be used with the custom syntax on
gpu.funcs. The special kind of function for GPU allows one to use additional
features such as memory attribution.

PiperOrigin-RevId: 285822272
2019-12-16 12:12:48 -08:00
River Riddle ab610e8a99 Insert signature-converted blocks into a region with a parent operation.
This keeps the IR valid and consistent as it is expected that each block should have a valid parent region/operation. Previously, converted blocks were kept floating without a valid parent region.

PiperOrigin-RevId: 285821687
2019-12-16 12:09:45 -08:00
Alex Zinenko ed749b7689 Make "LowerToCFG" an operation pass
The conversion from the Loops dialect to the Standard dialect, also known as
loop-to-cfg lowering, has been historically a function pass. It can be required
on non-Standard function Ops, in particular the recently introduced GPU
functions. Make the conversion an operation pass instead of a function pass.

PiperOrigin-RevId: 285814560
2019-12-16 11:36:02 -08:00
Jose Ignacio Gomez 3ae56c4135 [Linalg] Expose subview promotion as a declarative pattern
This PR targest issue tensorflow/mlir#295. It exposes the already existing
subiew promotion pass as a declarative pattern

Change-Id: If901ebef9fb53fcd0b12ecc536f6b174ce320b92

Closes tensorflow/mlir#315

COPYBARA_INTEGRATE_REVIEW=https://github.com/tensorflow/mlir/pull/315 from tetuante:issue295 8e5f268b6d85f31015c33505329dbd7a4db97ac5
PiperOrigin-RevId: 285801463
2019-12-16 10:50:45 -08:00
Mehdi Amini c290e993b2 Remove unused variable (fix warning) NFC
PiperOrigin-RevId: 285799680
2019-12-16 10:28:44 -08:00
Aart Bik cd5dab8ad7 [VectorOps] Add [insert/extract]element definition together with lowering to LLVM
Similar to insert/extract vector instructions but
(1) work on 1-D vectors only
(2) allow for a dynamic index

  %c3 = constant 3 : index
  %0 = vector.insertelement %arg0, %arg1[%c : index] : vector<4xf32>
  %1 = vector.extractelement %arg0[%c3 : index] : vector<4xf32>

PiperOrigin-RevId: 285792205
2019-12-16 09:52:46 -08:00
Andy Davis 73ec37c8bb Adds ExtractSlicesOp to the VectorOps dialect.
ExtractSlicesOp extracts slices of its vector operand and with a specified tiling scheme.
This operation centralizes the tiling scheme around a single op, which simplifies vector op unrolling and subsequent pattern rewrite transformations.

PiperOrigin-RevId: 285761129
2019-12-16 06:39:09 -08:00
Alex Zinenko 0684aa9a8b Make memref promotion during std->LLVM lowering the default calling convention
During the conversion from the standard dialect to the LLVM dialect,
memref-typed arguments are promoted from registers to memory and passed into
functions by pointer. This had been introduced into the lowering to work around
the abesnce of calling convention modeling in MLIR to enable better
interoperability with LLVM IR generated from C, and has been exerciced for
several months. Make this promotion the default calling covention when
converting to the LLVM dialect. This adds the documentation, simplifies the
code and makes the conversion consistent across function operations and
function types used in other places, e.g. in high-order functions or
attributes, which would not follow the same rule previously.

PiperOrigin-RevId: 285751280
2019-12-16 05:17:14 -08:00
Tres Popp 44fc7d72b3 Remove LLVM dependency on mlir::Module and instead check Traits.
PiperOrigin-RevId: 285724678
2019-12-16 01:45:44 -08:00
Uday Bondhugula 97af932272 Splat op doc - fix misformat / update tablegen op desc. comment
- bring op description comment in sync with the doc
- fix misformat in doc

Signed-off-by: Uday Bondhugula <uday@polymagelabs.com>

Closes tensorflow/mlir#317

COPYBARA_INTEGRATE_REVIEW=https://github.com/tensorflow/mlir/pull/317 from bondhugula:quickfix 7fcd945b318c973b2488b702874c87526855c8ef
PiperOrigin-RevId: 285574527
2019-12-14 11:22:24 -08:00
Smit Hinsu 2d22b1e04e Add verifyCompatibleShape function overload with shapes
PiperOrigin-RevId: 285574334
2019-12-14 11:18:38 -08:00
Nicolas Vasilache 3ef15a80d2 Reconcile struct and class for NestedPatternMatchers - NFC
This removes a warning and fixes a potential ABI issue on Windows.

PiperOrigin-RevId: 285502010
2019-12-13 17:51:15 -08:00
Nicolas Vasilache 200beb8446 Apply a level of sugaring to the linalg.generic EDSC - NFC
Make the declarative C++ builder API simpler to use so we can start chaining these ops together.

PiperOrigin-RevId: 285496266
2019-12-13 17:39:46 -08:00
River Riddle 7ac42fa26e Refactor various canonicalization patterns as in-place folds.
This is more efficient, and allows for these to fire in more situations: e.g. createOrFold, DialectConversion, etc.

PiperOrigin-RevId: 285476837
2019-12-13 17:19:02 -08:00
Jing Pu 27ae92516b Skip generating C++ for "DeclareOpInterfaceMethods" in op interface gen.
This is needed for calling the generator on a .td file that contains both OpInterface definitions and op definitions with DeclareOpInterfaceMethods<...> Traits.

PiperOrigin-RevId: 285465784
2019-12-13 17:08:33 -08:00
Nicolas Vasilache 7923abd357 Add a layer of EDSC for linalg.GenericOp
This will be evolved into a simple programming model for custom ops and custom layers in followup CLs.

This CL also deletes the obsolete tablegen's reference-impl.td that was using EDSCs.

PiperOrigin-RevId: 285459545
2019-12-13 16:57:57 -08:00
River Riddle b030e4a4ec Try to fold operations in DialectConversion when trying to legalize.
This change allows for DialectConversion to attempt folding as a mechanism to legalize illegal operations. This also expands folding support in OpBuilder::createOrFold to generate new constants when folding, and also enables it to work in the context of a PatternRewriter.

PiperOrigin-RevId: 285448440
2019-12-13 16:47:26 -08:00
Prakalp Srivastava 7b19d73617 Add a type range for the XLA HLO dialect.
PiperOrigin-RevId: 285437835
2019-12-13 16:36:21 -08:00
Christian Sigg 8846557672 Fix maskAndClamp in gpu.all_reduce.
The clamp value determines the returned predicate. Previously, the clamp value was fixed to 31 and the predicate was therefore always true. This is incorrect for partial warp reductions, but went unnoticed because the returned values happened to be zero (but it could be anything).

PiperOrigin-RevId: 285343160
2019-12-13 15:28:58 -08:00
River Riddle e7aa47ff11 NFC: Cleanup the various Op::print methods.
This cleans up the implementation of the various operation print methods. This is done via a combination of code cleanup, adding new streaming methods to the printer(e.g. operand ranges), etc.

PiperOrigin-RevId: 285285181
2019-12-12 15:32:21 -08:00
Jacques Pienaar a50cb184a0 Fix logic on when to emit collective type but separate arg builder
Got the comment right but the code wrong :/

PiperOrigin-RevId: 285270561
2019-12-12 14:23:14 -08:00
Aart Bik 1c81adf362 [VectorOps] Add lowering of vector.shuffle to LLVM IR
For example, a shuffle

%1 = vector.shuffle %arg0, %arg1 [0 : i32, 1 : i32] : vector<2xf32>, vector<2xf32>

becomes a direct LLVM shuffle

0 = llvm.shufflevector %arg0, %arg1 [0 : i32, 1 : i32] : !llvm<"<2 x float>">, !llvm<"<2 x float>">

but

%1 = vector.shuffle %a, %b[1 : i32, 0 : i32, 2: i32] : vector<1x4xf32>, vector<2x4xf32>

becomes the more elaborate (note the index permutation that drives
argument selection for the extract operations)

%0 = llvm.mlir.undef : !llvm<"[3 x <4 x float>]">
%1 = llvm.extractvalue %arg1[0] : !llvm<"[2 x <4 x float>]">
%2 = llvm.insertvalue %1, %0[0] : !llvm<"[3 x <4 x float>]">
%3 = llvm.extractvalue %arg0[0] : !llvm<"[1 x <4 x float>]">
%4 = llvm.insertvalue %3, %2[1] : !llvm<"[3 x <4 x float>]">
%5 = llvm.extractvalue %arg1[1] : !llvm<"[2 x <4 x float>]">
%6 = llvm.insertvalue %5, %4[2] : !llvm<"[3 x <4 x float>]">

PiperOrigin-RevId: 285268164
2019-12-12 14:11:56 -08:00
Jacques Pienaar 41a73ddce8 Add type inference variant for separate params builder generated
Add variant that does invoke infer type op interface where defined. Also add entry function that invokes that different separate argument builders for wrapped, unwrapped and inference variant.

PiperOrigin-RevId: 285220709
2019-12-12 10:36:14 -08:00
Nicolas Vasilache 782ae29678 Retire !linalg.buffer type - NFC
This type is not used anymore now that Linalg view and subview have graduated to std and that alignment is supported on alloc.

PiperOrigin-RevId: 285213424
2019-12-12 10:03:57 -08:00
Alexander Belyaev 1b579d998a [Linalg] Add test for fusion of GenericOp with IndexedGenericOp.
PiperOrigin-RevId: 285211797
2019-12-12 09:56:45 -08:00
Ehsan Toosi f7bffad5a7 Added lowering of `std.tanh` to llvm function call to `tanh` and `tanhf`.
Closes tensorflow/mlir#312

COPYBARA_INTEGRATE_REVIEW=https://github.com/tensorflow/mlir/pull/312 from dfki-ehna:tanh 9e89b072ff91ff390ad739501745114feb3ac856
PiperOrigin-RevId: 285205674
2019-12-12 09:25:15 -08:00
Nicolas Vasilache 95b5a4fd67 Move cpu runner utils templates to .h
This allows reusing the implementation in various places by just including and permits more easily writing test functions without explicit template instantiations.

This also modifies UnrankedMemRefType to take a template type parameter since it cannot be type agnostic atm.

PiperOrigin-RevId: 285187711
2019-12-12 07:33:09 -08:00
Christian Sigg 9b85582682 Automated rollback of commit f68ac464d8
PiperOrigin-RevId: 285162061
2019-12-12 03:48:38 -08:00
Christian Sigg f68ac464d8 Switch from shfl.bfly to shfl.down.
Both work for the current use case, but the latter allows implementing
prefix sums and is a little easier to understand for partial warps.

PiperOrigin-RevId: 285145287
2019-12-12 01:28:01 -08:00
River Riddle 851a8516d3 Make OpBuilder::insert virtual instead of OpBuilder::createOperation.
It is sometimes useful to create operations separately from the builder before insertion as it may be easier to erase them in isolation if necessary. One example use case for this is folding, as we will only want to insert newly generated constant operations on success. This has the added benefit of fixing some silent PatternRewriter failures related to cloning, as the OpBuilder 'clone' methods don't call createOperation.

PiperOrigin-RevId: 285086242
2019-12-11 16:26:45 -08:00
Nicolas Vasilache 9dfa84a269 Add std.log* and llvm.intr.log* that correspond to the LLVMIR intrinsics
PiperOrigin-RevId: 285073483
2019-12-11 15:25:34 -08:00
Mahesh Ravishankar b909299d20 Add missing CMake dependency for MLIRTestIR.
PiperOrigin-RevId: 285039153
2019-12-11 12:44:42 -08:00
Nicolas Vasilache beda0b2dc8 Fix OSS build
PiperOrigin-RevId: 285036782
2019-12-11 12:33:37 -08:00
Mahesh Ravishankar 652fc261d7 Expose a convenience function to add interface attributes to a function.
PiperOrigin-RevId: 285036647
2019-12-11 12:21:42 -08:00
Denis Khalikov d968f9696d [spirv] Add lowering for std.fdiv, std.frem, std.fsub
Closes tensorflow/mlir#313

COPYBARA_INTEGRATE_REVIEW=https://github.com/tensorflow/mlir/pull/313 from denis0x0D:sandbox/lowering_std_farith 41715070a74d13bfa9401957478978c1bb8006c0
PiperOrigin-RevId: 285023586
2019-12-11 11:17:35 -08:00
Nicolas Vasilache 508d4e672e Continue refactoring StructuredOps utilities
This CL adds more common information to StructuredOpsUtils.h
The n_view attribute is retired in favor of args_in + args_out but the CL is otherwise NFC.

PiperOrigin-RevId: 285000621
2019-12-11 09:27:34 -08:00
Christian Sigg c5fb4c1303 NFC: Fix naming inconsistency: FuncOpLowering -> GPUFuncOpLowering.
Remove nested anonymous namespace.

PiperOrigin-RevId: 284987357
2019-12-11 08:24:58 -08:00
Alexander Belyaev 4b0198acb5 Roll-forward initial liveness analysis including test cases.
Fix the usage of the map size when appending to the map with [].

PiperOrigin-RevId: 284985916
2019-12-11 08:13:43 -08:00
Alexander Belyaev 984fdde269 Automated rollback of commit 98fbf41044
PiperOrigin-RevId: 284979684
2019-12-11 07:17:21 -08:00
Stephan Herhut b96f86daaf Add a function to get lowering patterns from GPU to NVVM.
This enables combining the patterns with other patterns into larger lowerings.

PiperOrigin-RevId: 284979271
2019-12-11 07:14:33 -08:00
Alexander Belyaev bae8a7a724 [Linalg] Add tiling for IndexedGenericOp with a region.
PiperOrigin-RevId: 284949355
2019-12-11 02:56:40 -08:00
Marcel Koester 98fbf41044 Add initial liveness analysis including test cases.
Closes tensorflow/mlir#255

PiperOrigin-RevId: 284935454
2019-12-11 01:03:25 -08:00
Aart Bik 9826fe5c9f [VectorOps] Add lowering of vector.insert to LLVM IR
For example, an insert

  %0 = vector.insert %arg0, %arg1[3 : i32] : f32 into vector<4xf32>

becomes

  %0 = llvm.mlir.constant(3 : i32) : !llvm.i32
  %1 = llvm.insertelement %arg0, %arg1[%0 : !llvm.i32] : !llvm<"<4 x float>">

A more elaborate example, inserting an element in a higher dimension
vector

  %0 = vector.insert %arg0, %arg1[3 : i32, 7 : i32, 15 : i32] : f32 into vector<4x8x16xf32>

becomes

  %0 = llvm.extractvalue %arg1[3 : i32, 7 : i32] : !llvm<"[4 x [8 x <16 x float>]]">
  %1 = llvm.mlir.constant(15 : i32) : !llvm.i32
  %2 = llvm.insertelement %arg0, %0[%1 : !llvm.i32] : !llvm<"<16 x float>">
  %3 = llvm.insertvalue %2, %arg1[3 : i32, 7 : i32] : !llvm<"[4 x [8 x <16 x float>]]">

PiperOrigin-RevId: 284882443
2019-12-10 17:12:49 -08:00
Andy Davis 4d8ba88610 Add VectorOp transform pattern which splits vector TransferReadOps to target vector unroll size.
PiperOrigin-RevId: 284880592
2019-12-10 17:02:51 -08:00
Uday Bondhugula 36a415bcc5 More affine expr simplifications for floordiv and mod
Add one more simplification for floordiv and mod affine expressions.
Examples:
 (2*d0 + 1) floordiv 2 is simplified to d0
 (8*d0 + 4*d1 + d2) floordiv 4 simplified to 4*d0 + d1 + d2 floordiv 4.
 etc.

 Similarly, (4*d1 + 1) mod 2 is simplified to 1,
            (2*d0 + 8*d1) mod 8 simplified to 2*d0 mod 8.

Change getLargestKnownDivisor to return int64_t to be consistent and
to avoid casting at call sites (since the return value is used in expressions
of int64_t/index type).

Signed-off-by: Uday Bondhugula <uday@polymagelabs.com>

Closes tensorflow/mlir#202

COPYBARA_INTEGRATE_REVIEW=https://github.com/tensorflow/mlir/pull/202 from bondhugula:affine b13fcb2f1c00a39ca5434613a02408e085a80e77
PiperOrigin-RevId: 284866710
2019-12-10 16:00:53 -08:00
Alex Zinenko d1213ae51d Move gpu.launch_func to ODS. NFC
Move the definition of gpu.launch_func operation from hand-rolled C++
implementation to the ODS framework. Also move the documentation. This only
performs the move and remains a non-functional change, a follow-up will clean
up the custom functions that can be auto-generated using ODS.

PiperOrigin-RevId: 284842252
2019-12-10 13:55:21 -08:00
Nicolas Vasilache 995048d7b7 Fold TestLinalgTilePermutePatterns into TestLinalgTransformPatterns - NFC
Centralize all patterns that test Linalg transforms in a single pass.

PiperOrigin-RevId: 284835938
2019-12-10 13:26:15 -08:00
River Riddle 9ed22ae5b8 Refactor the various operand/result/type iterators to use indexed_accessor_range.
This has several benefits:
* The implementation is much cleaner and more efficient.
* The ranges now have support for many useful operations: operator[], slice, drop_front, size, etc.
* Value ranges can now directly query a range for their types via 'getTypes()': e.g:
   void foo(Operation::operand_range operands) {
     auto operandTypes = operands.getTypes();
   }

PiperOrigin-RevId: 284834912
2019-12-10 13:21:22 -08:00
Jose Ignacio Gomez b19fed5415 [Linalg] Add a Linalg iterator permutation transformation
This patch closes issue tensorflow/mlir#272
We add a standalone iterator permutation transformation to Linalg.
This transformation composes a permutation map with the maps in the
"indexing_maps" attribute. It also permutes "iterator_types"
accordingly.

Change-Id: I7c1e693b8203aeecc595a7c012e738ca1100c857

Closes tensorflow/mlir#307

COPYBARA_INTEGRATE_REVIEW=https://github.com/tensorflow/mlir/pull/307 from tetuante:issue272 f7908d58792f4111119721885e247045104f1131
PiperOrigin-RevId: 284824102
2019-12-10 12:25:43 -08:00
Nicolas Vasilache ad38e49806 Uniformize Vector transforms as patterns on the model of Linalg - NFC
This reorganizes the vector transformations to be more easily testable as patterns and more easily composable into fused passes in the future.

PiperOrigin-RevId: 284817474
2019-12-10 11:54:33 -08:00
MLIR Team 8ccb350979 Add Py API for composing an affine expression with a map. Also allows extracting constant values for const expressions.
PiperOrigin-RevId: 284809623
2019-12-10 11:30:35 -08:00
Mahesh Ravishankar 04fdd33daf More convenience build methods for SPIR-V ops.
Add some convenience build methods to SPIR-V ops and update the
lowering to use these methods where possible.

For SPIRV::CompositeExtractOp move the method to deduce type of
element based on base and indices into a convenience function. Some
additional functionality needed to handle differences between parsing
and verification methods.

PiperOrigin-RevId: 284794404
2019-12-10 10:11:50 -08:00
Mehdi Amini 90b72dd616 Add a doc on guidelines for contributing a new dialect to the MLIR core repo
Closes tensorflow/mlir#263

PiperOrigin-RevId: 284760931
2019-12-10 07:01:51 -08:00
Alex Zinenko ac4873322f Drop Markdown style annotations
These come from a non-standard extenion that is not available on Github, so it
only clutters the documentation source with {.mlir} or {.ebnf} tags.

PiperOrigin-RevId: 284733003
2019-12-10 03:00:57 -08:00
Jacques Pienaar acb23ff48d Fix build breakage on gcc-5
Avoid `error: could not convert ?(const char*)"reduction"? from ?const char*? to ?llvm::StringLiteral?`. Tested with gcc-5.5.

PiperOrigin-RevId: 284677810
2019-12-09 18:19:07 -08:00
Aart Bik 1fe65688d4 [VectorOps] Add a ShuffleOp to the VectorOps dialect
For example

 %0 = vector.shuffle %x, %y [3 : i32, 2 : i32, 1 : i32, 0 : i32] : vector<2xf32>, vector<2xf32>

yields a vector<4xf32> result with a permutation of the elements of %x and %y

PiperOrigin-RevId: 284657191
2019-12-09 16:15:41 -08:00
Aart Bik 0e963b9c42 [VectorOps] Fix off-by-one error in insert/extract validation
PiperOrigin-RevId: 284652653
2019-12-09 15:54:23 -08:00
River Riddle 3f9744a6b7 Refactor the Block support classes.
Each of the support classes for Block are now moved into a new header BlockSupport.h. The successor iterator class is also reimplemented as an indexed_accessor_range. This makes the class more efficient, and expands on its available functionality.

PiperOrigin-RevId: 284646792
2019-12-09 15:24:43 -08:00
River Riddle 7be6a40ab9 Add new indexed_accessor_range_base and indexed_accessor_range classes that simplify defining index-able ranges.
Many ranges want similar functionality from a range type(e.g. slice/drop_front/operator[]/etc.), so these classes provide a generic implementation that may be used by many different types of ranges. This removes some code duplication, and also empowers many of the existing range types in MLIR(e.g. result type ranges, operand ranges, ElementsAttr ranges, etc.). This change only updates RegionRange and ValueRange, more ranges will be updated in followup commits.

PiperOrigin-RevId: 284615679
2019-12-09 12:55:40 -08:00
shanshanpt 56da74476c Fix minor spelling tweaks.
Closes tensorflow/mlir#306

COPYBARA_INTEGRATE_REVIEW=https://github.com/tensorflow/mlir/pull/306 from shanshanpt:master 11430c2131281d84a432f45e854e29917b336e8d
PiperOrigin-RevId: 284613648
2019-12-09 12:45:20 -08:00
Denis Khalikov 34265dad65 [spirv] Add CompositeConstruct operation.
Closes tensorflow/mlir#308

COPYBARA_INTEGRATE_REVIEW=https://github.com/tensorflow/mlir/pull/308 from denis0x0D:sandbox/composite_construct 9ef7180f77f9374bcd05afc4f9e6c1d2d72d02b7
PiperOrigin-RevId: 284613617
2019-12-09 12:43:53 -08:00
Lei Zhang 2c7e8ed7c6 [spirv] Add spv.IAdd, spv.ISub, and spv.IMul folders
The patterns to be folded away can be commonly generated
during lowering to SPIR-V.

PiperOrigin-RevId: 284604855
2019-12-09 11:59:10 -08:00
Nicolas Vasilache 5a48e40a65 Factor out commonly reusable names across structured ops dialects
This CL starts extracting commonalities between dialects that use the structured ops abstractions. Also fixes an OSS build issue where StringRef were incorrectly used with constexpr.

PiperOrigin-RevId: 284591114
2019-12-09 11:01:40 -08:00
Jacques Pienaar 89cef725f4 ODS: Generate named accessors for raw attributes
Currently named accessors are generated for attributes returning a consumer
friendly type. But sometimes the attributes are used while transforming an
existing op and then the returned type has to be converted back into an
attribute or the raw `getAttr` needs to be used. Generate raw named accessor
for attributes to reference the raw attributes without having to use the string
interface for better compile time verification. This allows calling
`blahAttr()` instead of `getAttr("blah")`.

Raw here refers to returning the underlying storage attribute.

PiperOrigin-RevId: 284583426
2019-12-09 10:29:34 -08:00
Mahesh Ravishankar 4a62019eb8 Add lowering for module with gpu.kernel_module attribute.
The existing GPU to SPIR-V lowering created a spv.module for every
function with gpu.kernel attribute. A better approach is to lower the
module that the function lives in (which has the attribute
gpu.kernel_module) to a spv.module operation. This better captures the
host-device separation modeled by GPU dialect and simplifies the
lowering as well.

PiperOrigin-RevId: 284574688
2019-12-09 09:52:21 -08:00
Andy Davis 312ccb1c0f Unify vector op unrolling transformation.
Unifies vector op unrolling transformation, by using the same unrolling implementation for contraction and elementwise operations.
Removes fakefork/join operations which are non longer needed now that we have the InsertStridedSlice operation.

PiperOrigin-RevId: 284570784
2019-12-09 09:35:15 -08:00
Kazuaki Ishizaki ae05cf27c6 Minor spelling tweaks
Closes tensorflow/mlir#304

PiperOrigin-RevId: 284568358
2019-12-09 09:23:48 -08:00
Nicolas Vasilache 91c0074624 [StructuredOps][Linalg] Add a primitive pattern to rewrite the linalg.generic form of matmul to vector form.
This CL uses the newly expanded matcher support to easily detect when a linalg.generic has a multiply-accumulate body. A linalg.generic with such a body is rewritten as a vector contraction.
This CL additionally limits the rewrite to the case of matrix multiplication on contiguous and statically shaped memrefs for now.

Before expanding further, we should harden the infrastructure for expressing custom ops with the structured ops abstraction.

PiperOrigin-RevId: 284566659
2019-12-09 09:14:39 -08:00
Jacques Pienaar 70aeb4566e Add RegionRange for when need to abstract over different region iteration
Follows ValueRange in representing a generic abstraction over the different
ways to represent a range of Regions. This wrapper is not as ValueRange and only
considers the current cases of interest: MutableArrayRef<Region> and
ArrayRef<std::unique_ptr<Region>> as occurs during op construction vs op region
querying.

Note: ArrayRef<std::unique_ptr<Region>> allows for unset regions, so this range
returns a pointer to a Region instead of a Region.
PiperOrigin-RevId: 284563229
2019-12-09 08:57:56 -08:00
Nicolas Vasilache 7b19bd5411 Post-submit cleanups in RecursiveMatchers
This CL addresses leftover cleanups and adds a test mixing RecursiveMatchers and m_Constant
that captures properly.

PiperOrigin-RevId: 284551567
2019-12-09 07:47:35 -08:00
Uday Bondhugula a63f6e0bf9 Replace spurious SmallVector constructions with ValueRange
Signed-off-by: Uday Bondhugula <uday@polymagelabs.com>

Closes tensorflow/mlir#305

COPYBARA_INTEGRATE_REVIEW=https://github.com/tensorflow/mlir/pull/305 from bondhugula:value_range 21d1fae73f549e3c8e72b60876eff1b864cea39c
PiperOrigin-RevId: 284541027
2019-12-09 06:26:33 -08:00
Nicolas Vasilache ade58a268c Add a layer of recursive matchers that compose.
This CL adds support for building matchers recursively.
The following matchers are provided:

1. `m_any()` can match any value
2. `m_val(Value *)` binds to a value and must match it
3. `RecursivePatternMatcher<OpType, Matchers...>` n-arity pattern that matches `OpType` and whose operands must be matched exactly by `Matchers...`.

This allows building expression templates for patterns, declaratively, in a very natural fashion.
For example pattern `p9` defined as follows:
```
  auto mul_of_muladd = m_Op<MulFOp>(m_Op<MulFOp>(), m_Op<AddFOp>());
  auto mul_of_anyadd = m_Op<MulFOp>(m_any(), m_Op<AddFOp>());
  auto p9 = m_Op<MulFOp>(m_Op<MulFOp>(
                     mul_of_muladd, m_Op<MulFOp>()),
                   m_Op<MulFOp>(mul_of_anyadd, mul_of_anyadd));
```

Successfully matches `%6` in:
```
  %0 = addf %a, %b: f32
  %1 = addf %a, %c: f32 // matched
  %2 = addf %c, %b: f32
  %3 = mulf %a, %2: f32 // matched
  %4 = mulf %3, %1: f32 // matched
  %5 = mulf %4, %4: f32 // matched
  %6 = mulf %5, %5: f32 // matched
```

Note that 0-ary matchers can be used as leaves in place of n-ary matchers. This alleviates from passing explicit `m_any()` leaves.

In the future, we may add extra patterns to specify that operands may be matched in any order.

PiperOrigin-RevId: 284469446
2019-12-08 18:09:40 -08:00
Lei Zhang 9a4c2df480 NFC: Expose constFoldBinaryOp via a header
This allows other dialects to reuse the logic to support constant
folding binary operations and reduces code duplication.

PiperOrigin-RevId: 284428721
2019-12-08 06:25:54 -08:00
River Riddle d6ee6a0310 Update the builder API to take ValueRange instead of ArrayRef<Value *>
This allows for users to provide operand_range and result_range in builder.create<> calls, instead of requiring an explicit copy into a separate data structure like SmallVector/std::vector.

PiperOrigin-RevId: 284360710
2019-12-07 10:35:41 -08:00
River Riddle 9d1a0c72b4 Add a new ValueRange class.
This class represents a generic abstraction over the different ways to represent a range of Values: ArrayRef<Value *>, operand_range, result_range. This class will allow for removing the many instances of explicit SmallVector<Value *, N> construction. It has the same memory cost as ArrayRef, and only suffers cost from indexing(if+elsing the different underlying representations).

This change only updates a few of the existing usages, with more to be changed in followups; e.g. 'build' API.

PiperOrigin-RevId: 284307996
2019-12-06 20:07:23 -08:00
Nicolas Vasilache d27bc1db6a Improve Linalg documentation following the Structured Ops presentation.
PiperOrigin-RevId: 284291653
2019-12-06 17:09:16 -08:00
River Riddle 8904e91035 Add a flag to the IRPrinter instrumentation to only print after a pass if there is a change to the IR.
This adds an additional filtering mode for printing after a pass that checks to see if the pass actually changed the IR before printing it. This "change" detection is implemented using a SHA1 hash of the current operation and its children.

PiperOrigin-RevId: 284291089
2019-12-06 17:05:05 -08:00
Uday Bondhugula ca23bd78d4 NFC - update doc, comments, vim syntax file
- for the symbol rules, the code was updated but the doc wasn't.

Signed-off-by: Uday Bondhugula <uday@polymagelabs.com>

Closes tensorflow/mlir#284

COPYBARA_INTEGRATE_REVIEW=https://github.com/tensorflow/mlir/pull/284 from bondhugula:doc 9aad8b8a715559f7ce61265f3da3f8a3c11b45ea
PiperOrigin-RevId: 284283712
2019-12-06 16:17:06 -08:00
nmostafa fcc215e399 Fix langref code snippet - NFC
Closes tensorflow/mlir#294

PiperOrigin-RevId: 284281172
2019-12-06 16:03:51 -08:00
Mahesh Ravishankar 6500b7e0c0 NFC: Separate implementation and definition in ConvertStandardToSPIRV.cpp
PiperOrigin-RevId: 284274326
2019-12-06 15:26:17 -08:00
Jacques Pienaar 4add9edd72 Change inferReturnTypes to return LogicalResult and values
Previously the error case was using a sentinel in the error case which was bad. Also make the one `build` invoke the other `build` to reuse verification there.

And follow up on suggestion to use formatv which I missed during previous review.

PiperOrigin-RevId: 284265762
2019-12-06 14:42:45 -08:00
Alex Zinenko e96150eb46 Replace custom getBody method with an ODS-generated in gpu::LaunchOp
PiperOrigin-RevId: 284262981
2019-12-06 14:29:25 -08:00
Mahesh Ravishankar 883f555726 During serialization do a walk of ops in module to find spv.module.
During lowering, spv.module might be within other modules (for example
gpu kernel module). Walk the module op to find spirv module to
serialize.

PiperOrigin-RevId: 284262550
2019-12-06 14:27:03 -08:00
Alex Zinenko 3230267d0d Move GPU::LaunchOp to ODS. NFC.
Move the definition of the GPU launch opreation from hand-rolled C++ code to
ODS framework. This only does the moves, a follow-up is necessary to clean up
users of custom functions that could be auto-generated by ODS.

PiperOrigin-RevId: 284261856
2019-12-06 14:23:37 -08:00
Alex Zinenko 6e0a2e4e2f Use named traits in the ODS definition of LLVMFuncOp
The "FunctionLike" and "IsIsolatedFromAbove" op traits are now defined as named
records in base ODS file. Use those instead of NativeOpTrait referring to the
C++ class name in the ODS definition of LLVMFuncOp. NFC.

PiperOrigin-RevId: 284260891
2019-12-06 14:18:37 -08:00
Aart Bik d37f27251f [VecOps] Rename vector.[insert|extract]element to just vector.[insert|extract]
Since these operations lower to [insert|extract][element|value] at LLVM
dialect level, neither element nor value would correctly reflect the meaning.

PiperOrigin-RevId: 284240727
2019-12-06 12:39:25 -08:00
Alex Zinenko be3ed14658 LLVM::GlobalOp: take address space as builder argument
Accept the address space of the global as a builder argument when constructing
an LLVM::GlobalOp instance. This decreases the reliance of LLVM::GlobalOp users
on the internal name of the attribute used for this purpose. Update several
uses of the address space in GPU to NVVM conversion.

PiperOrigin-RevId: 284233254
2019-12-06 12:01:46 -08:00
Alex Zinenko ccc767d63b Move GPU::FuncOp definition to ODS - NFC
Move the definition of the GPU function opreation from hand-rolled C++ code to
ODS framework. This only does the moves, a follow-up is necessary to clean up
users of custom functions that could be auto-generated by ODS.

PiperOrigin-RevId: 284233245
2019-12-06 12:00:32 -08:00
MLIR Team 9ef9e23682 Provide a way to get the type of a ValueHandle.
PiperOrigin-RevId: 284221337
2019-12-06 11:07:10 -08:00
Aart Bik b36aaeafb1 [VectorOps] Add lowering of vector.broadcast to LLVM IR
For example, a scalar broadcast

    %0 = vector.broadcast %x : f32 to vector<2xf32>
    return %0 : vector<2xf32>

which expands scalar x into vector [x,x] by lowering
to the following LLVM IR dialect to implement the
duplication over the leading dimension.

    %0 = llvm.mlir.undef : !llvm<"<2 x float>">
    %1 = llvm.mlir.constant(0 : index) : !llvm.i64
    %2 = llvm.insertelement %x, %0[%1 : !llvm.i64] : !llvm<"<2 x float>">
    %3 = llvm.shufflevector %2, %0 [0 : i32, 0 : i32] : !llvm<"<2 x float>">, !llvm<"<2 x float>">
    return %3 : vector<2xf32>

In the trailing dimensions, the operand is simply
"passed through", unless a more elaborate "stretch"
is required.

For example

    %0 = vector.broadcast %arg0 : vector<1xf32> to vector<4xf32>
    return %0 : vector<4xf32>

becomes

    %0 = llvm.mlir.undef : !llvm<"<4 x float>">
    %1 = llvm.mlir.constant(0 : index) : !llvm.i64
    %2 = llvm.extractelement %arg0[%1 : !llvm.i64] : !llvm<"<1 x float>">
    %3 = llvm.mlir.constant(0 : index) : !llvm.i64
    %4 = llvm.insertelement %2, %0[%3 : !llvm.i64] : !llvm<"<4 x float>">
    %5 = llvm.shufflevector %4, %0 [0 : i32, 0 : i32, 0 : i32, 0 : i32] : !llvm<"<4 x float>">, !llvm<"<4 x float>">
    llvm.return %5 : !llvm<"<4 x float>">

PiperOrigin-RevId: 284219926
2019-12-06 11:02:29 -08:00
Jacques Pienaar 398f04aa49 Generate builder for ops that use InferTypeOpInterface trait in ODS
For ops with infer type op interface defined, generate version that calls the inferal method on build. This is intermediate step to removing special casing of SameOperandsAndResultType & FirstAttrDereivedResultType. After that would be generating the inference code, with the initial focus on shaped container types. In between I plan to refactor these a bit to reuse generated paths. The intention would not be to add the type inference trait in multiple places, but rather to take advantage of the current modelling in ODS where possible to emit it instead.

Switch the `inferReturnTypes` method to be static.

Skipping ops with regions here as I don't like the Region vs unique_ptr<Region> difference at the moment, and I want the infer return type trait to be useful for verification too. So instead, just skip it for now to avoid churn.

PiperOrigin-RevId: 284217913
2019-12-06 10:53:06 -08:00
Alex Zinenko e216a72ab8 Add conversions of GPU func with memory attributions to LLVM/NVVM
GPU functions use memory attributions, a combination of Op attributes and
region arguments, to specify function-wide buffers placed in workgroup or
private memory spaces. Introduce a lowering pattern for GPU functions to be
converted to LLVM functions taking into account memory attributions. Workgroup
attributions get transformed into module-level globals with unique names
derived from function names. Private attributions get converted into
llvm.allocas inside the function body. In both cases, we inject at the
beginning of the function the IR that obtains the raw pointer to the data and
populates a MemRef descriptor based on the MemRef type of buffer, making
attributions compose with the rest of the MemRef lowering and transparent for
use with std.load and std.store. While using raw pointers instead of
descriptors might have been more efficient, it is better implemented as a
canonicalization or a separate transformation so that non-attribution memrefs
could also benefit from it.

PiperOrigin-RevId: 284208396
2019-12-06 10:08:43 -08:00
Alexandre E. Eichenberger 3c69ca1e69 fix examples in comments
Closes tensorflow/mlir#301

COPYBARA_INTEGRATE_REVIEW=https://github.com/tensorflow/mlir/pull/301 from AlexandreEichenberger:vect-doc-update 7e5418a9101a4bdad2357882fe660b02bba8bd01
PiperOrigin-RevId: 284202462
2019-12-06 09:40:50 -08:00
River Riddle 79047e1ab5 Use regex to fix failure when stats are disabled.
It would be nice if we could detect if stats were enabled or not and use 'Requires', but this isn't possible to do at configure time.

Fixes tensorflow/mlir#296

PiperOrigin-RevId: 284200271
2019-12-06 09:29:14 -08:00
Andy Davis 41f8e105fa Unroll vector masks along with their associated vector arguments.
Updates vector ContractionOp to use proper vector masks (produced by CreateMaskOp/ConstantMaskOp).
Leverages the following canonicalizations in unrolling unit test: CreateMaskOp -> ConstantMaskOp, StridedSliceOp(ConstantMaskOp) -> ConstantMaskOp
Removes IndexTupleOp (no longer needed now that we have vector mask ops).
Updates all unit tests.

PiperOrigin-RevId: 284182168
2019-12-06 07:37:28 -08:00
Denis Khalikov 9ca53130f3 [spirv] Reorder `erase` and `emplace` to avoid "invalid iterator access".
The iterator should be erased before adding a new entry
into blockMergeInfo to avoid iterator invalidation.

Closes tensorflow/mlir#299

COPYBARA_INTEGRATE_REVIEW=https://github.com/tensorflow/mlir/pull/299 from denis0x0D:sandbox/reoder_erase 983be565809aa0aadfc7e92962e4d4b282f63c66
PiperOrigin-RevId: 284173235
2019-12-06 06:26:56 -08:00
Uday Bondhugula 3ade6a7d15 DimOp folding for alloc/view dynamic dimensions
Signed-off-by: Uday Bondhugula <uday@polymagelabs.com>

Closes tensorflow/mlir#253

COPYBARA_INTEGRATE_REVIEW=https://github.com/tensorflow/mlir/pull/253 from bondhugula:dimop a4b464f24ae63fd259114558d87e11b8ee4dae86
PiperOrigin-RevId: 284169689
2019-12-06 06:00:54 -08:00
Kazuaki Ishizaki 84a6182ddd minor spelling tweaks
Closes tensorflow/mlir#290

COPYBARA_INTEGRATE_REVIEW=https://github.com/tensorflow/mlir/pull/290 from kiszk:spelling_tweaks_201912 9d9afd16a723dd65754a04698b3976f150a6054a
PiperOrigin-RevId: 284169681
2019-12-06 05:59:30 -08:00
Alex Zinenko 58adf99ed1 LLVM::AddressOfOp: properly take into account the address space
The AddressOf operation in the LLVM dialect return a pointer to a global
variable. The latter may be in a non-default address space as indicated by the
"addr_space" attribute. Check that the address space of the pointer returned by
AddressOfOp matches that of the referenced GlobalOp. Update the AddressOfOp
builder to respect this constraint.

PiperOrigin-RevId: 284138860
2019-12-06 01:09:13 -08:00
River Riddle 12e57cf6c0 NFC: Add documentation for `-mlir-print-op-on-diagnostic` and `-mlir-print-stacktrace-on-diagnostic`.
This change adds proper documentation in Diagnostics.md, allowing for users to more easily find them.

PiperOrigin-RevId: 284092336
2019-12-05 17:47:03 -08:00