platform/upstream/llvm.git
4 years agoMake OpBuilder::insert virtual instead of OpBuilder::createOperation.
River Riddle [Thu, 12 Dec 2019 00:26:08 +0000 (16:26 -0800)]
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

4 years agoAdd std.log* and llvm.intr.log* that correspond to the LLVMIR intrinsics
Nicolas Vasilache [Wed, 11 Dec 2019 23:25:00 +0000 (15:25 -0800)]
Add std.log* and llvm.intr.log* that correspond to the LLVMIR intrinsics

PiperOrigin-RevId: 285073483

4 years agoAdd missing CMake dependency for MLIRTestIR.
Mahesh Ravishankar [Wed, 11 Dec 2019 20:35:43 +0000 (12:35 -0800)]
Add missing CMake dependency for MLIRTestIR.

PiperOrigin-RevId: 285039153

4 years agoFix OSS build
Nicolas Vasilache [Wed, 11 Dec 2019 20:22:04 +0000 (12:22 -0800)]
Fix OSS build

PiperOrigin-RevId: 285036782

4 years agoExpose a convenience function to add interface attributes to a function.
Mahesh Ravishankar [Wed, 11 Dec 2019 20:21:13 +0000 (12:21 -0800)]
Expose a convenience function to add interface attributes to a function.

PiperOrigin-RevId: 285036647

4 years ago[spirv] Add lowering for std.fdiv, std.frem, std.fsub
Denis Khalikov [Wed, 11 Dec 2019 19:17:03 +0000 (11:17 -0800)]
[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

4 years agoContinue refactoring StructuredOps utilities
Nicolas Vasilache [Wed, 11 Dec 2019 17:26:51 +0000 (09:26 -0800)]
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

4 years agoNFC: Fix naming inconsistency: FuncOpLowering -> GPUFuncOpLowering.
Christian Sigg [Wed, 11 Dec 2019 16:08:22 +0000 (08:08 -0800)]
NFC: Fix naming inconsistency: FuncOpLowering -> GPUFuncOpLowering.

Remove nested anonymous namespace.

PiperOrigin-RevId: 284987357

4 years agoRoll-forward initial liveness analysis including test cases.
Alexander Belyaev [Wed, 11 Dec 2019 16:01:56 +0000 (08:01 -0800)]
Roll-forward initial liveness analysis including test cases.

Fix the usage of the map size when appending to the map with [].

PiperOrigin-RevId: 284985916

4 years agoAutomated rollback of commit 98fbf41044d3364dbaf18db81b9e8d9520d14761
Alexander Belyaev [Wed, 11 Dec 2019 15:16:47 +0000 (07:16 -0800)]
Automated rollback of commit 98fbf41044d3364dbaf18db81b9e8d9520d14761

PiperOrigin-RevId: 284979684

4 years agoAdd a function to get lowering patterns from GPU to NVVM.
Stephan Herhut [Wed, 11 Dec 2019 15:13:54 +0000 (07:13 -0800)]
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

4 years ago[Linalg] Add tiling for IndexedGenericOp with a region.
Alexander Belyaev [Wed, 11 Dec 2019 10:56:06 +0000 (02:56 -0800)]
[Linalg] Add tiling for IndexedGenericOp with a region.

PiperOrigin-RevId: 284949355

4 years agoAdd initial liveness analysis including test cases.
Marcel Koester [Wed, 11 Dec 2019 09:02:39 +0000 (01:02 -0800)]
Add initial liveness analysis including test cases.

Closes tensorflow/mlir#255

PiperOrigin-RevId: 284935454

4 years ago[VectorOps] Add lowering of vector.insert to LLVM IR
Aart Bik [Wed, 11 Dec 2019 01:12:11 +0000 (17:12 -0800)]
[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

4 years agoAdd VectorOp transform pattern which splits vector TransferReadOps to target vector...
Andy Davis [Wed, 11 Dec 2019 01:02:17 +0000 (17:02 -0800)]
Add VectorOp transform pattern which splits vector TransferReadOps to target vector unroll size.

PiperOrigin-RevId: 284880592

4 years agoMore affine expr simplifications for floordiv and mod
Uday Bondhugula [Tue, 10 Dec 2019 23:49:07 +0000 (15:49 -0800)]
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

4 years agoMove gpu.launch_func to ODS. NFC
Alex Zinenko [Tue, 10 Dec 2019 21:54:50 +0000 (13:54 -0800)]
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

4 years agoFold TestLinalgTilePermutePatterns into TestLinalgTransformPatterns - NFC
Nicolas Vasilache [Tue, 10 Dec 2019 21:25:41 +0000 (13:25 -0800)]
Fold TestLinalgTilePermutePatterns into TestLinalgTransformPatterns - NFC

Centralize all patterns that test Linalg transforms in a single pass.

PiperOrigin-RevId: 284835938

4 years agoRefactor the various operand/result/type iterators to use indexed_accessor_range.
River Riddle [Tue, 10 Dec 2019 21:20:50 +0000 (13:20 -0800)]
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

4 years ago[Linalg] Add a Linalg iterator permutation transformation
Jose Ignacio Gomez [Tue, 10 Dec 2019 20:25:10 +0000 (12:25 -0800)]
[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

4 years agoUniformize Vector transforms as patterns on the model of Linalg - NFC
Nicolas Vasilache [Tue, 10 Dec 2019 19:54:00 +0000 (11:54 -0800)]
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

4 years agoAdd Py API for composing an affine expression with a map. Also allows extracting...
MLIR Team [Tue, 10 Dec 2019 19:18:57 +0000 (11:18 -0800)]
Add Py API for composing an affine expression with a map. Also allows extracting constant values for const expressions.

PiperOrigin-RevId: 284809623

4 years agoMore convenience build methods for SPIR-V ops.
Mahesh Ravishankar [Tue, 10 Dec 2019 18:11:19 +0000 (10:11 -0800)]
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

4 years agoAdd a doc on guidelines for contributing a new dialect to the MLIR core repo
Mehdi Amini [Tue, 10 Dec 2019 15:01:17 +0000 (07:01 -0800)]
Add a doc on guidelines for contributing a new dialect to the MLIR core repo

Closes tensorflow/mlir#263

PiperOrigin-RevId: 284760931

4 years agoDrop Markdown style annotations
Alex Zinenko [Tue, 10 Dec 2019 11:00:29 +0000 (03:00 -0800)]
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

4 years agoFix build breakage on gcc-5
Jacques Pienaar [Tue, 10 Dec 2019 02:18:38 +0000 (18:18 -0800)]
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

4 years ago[VectorOps] Add a ShuffleOp to the VectorOps dialect
Aart Bik [Tue, 10 Dec 2019 00:15:02 +0000 (16:15 -0800)]
[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

4 years ago[VectorOps] Fix off-by-one error in insert/extract validation
Aart Bik [Mon, 9 Dec 2019 23:53:50 +0000 (15:53 -0800)]
[VectorOps] Fix off-by-one error in insert/extract validation

PiperOrigin-RevId: 284652653

4 years agoRefactor the Block support classes.
River Riddle [Mon, 9 Dec 2019 23:24:10 +0000 (15:24 -0800)]
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

4 years agoAdd new indexed_accessor_range_base and indexed_accessor_range classes that simplify...
River Riddle [Mon, 9 Dec 2019 20:55:05 +0000 (12:55 -0800)]
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

4 years agoFix minor spelling tweaks.
shanshanpt [Mon, 9 Dec 2019 20:43:39 +0000 (12:43 -0800)]
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

4 years ago[spirv] Add CompositeConstruct operation.
Denis Khalikov [Mon, 9 Dec 2019 20:43:23 +0000 (12:43 -0800)]
[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

4 years ago[spirv] Add spv.IAdd, spv.ISub, and spv.IMul folders
Lei Zhang [Mon, 9 Dec 2019 19:58:39 +0000 (11:58 -0800)]
[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

4 years agoFactor out commonly reusable names across structured ops dialects
Nicolas Vasilache [Mon, 9 Dec 2019 19:00:53 +0000 (11:00 -0800)]
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

4 years agoODS: Generate named accessors for raw attributes
Jacques Pienaar [Mon, 9 Dec 2019 18:28:58 +0000 (10:28 -0800)]
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

4 years agoAdd lowering for module with gpu.kernel_module attribute.
Mahesh Ravishankar [Mon, 9 Dec 2019 17:51:25 +0000 (09:51 -0800)]
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

4 years agoUnify vector op unrolling transformation.
Andy Davis [Mon, 9 Dec 2019 17:34:40 +0000 (09:34 -0800)]
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

4 years agoMinor spelling tweaks
Kazuaki Ishizaki [Mon, 9 Dec 2019 17:23:15 +0000 (09:23 -0800)]
Minor spelling tweaks

Closes tensorflow/mlir#304

PiperOrigin-RevId: 284568358

4 years ago[StructuredOps][Linalg] Add a primitive pattern to rewrite the linalg.generic form...
Nicolas Vasilache [Mon, 9 Dec 2019 17:14:05 +0000 (09:14 -0800)]
[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

4 years agoAdd RegionRange for when need to abstract over different region iteration
Jacques Pienaar [Mon, 9 Dec 2019 16:57:27 +0000 (08:57 -0800)]
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

4 years agoPost-submit cleanups in RecursiveMatchers
Nicolas Vasilache [Mon, 9 Dec 2019 15:47:01 +0000 (07:47 -0800)]
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

4 years agoReplace spurious SmallVector constructions with ValueRange
Uday Bondhugula [Mon, 9 Dec 2019 14:26:05 +0000 (06:26 -0800)]
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

4 years agoAdd a layer of recursive matchers that compose.
Nicolas Vasilache [Mon, 9 Dec 2019 02:09:07 +0000 (18:09 -0800)]
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

4 years agoNFC: Expose constFoldBinaryOp via a header
Lei Zhang [Sun, 8 Dec 2019 14:25:17 +0000 (06:25 -0800)]
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

4 years agoUpdate the builder API to take ValueRange instead of ArrayRef<Value *>
River Riddle [Sat, 7 Dec 2019 18:35:01 +0000 (10:35 -0800)]
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

4 years agoAdd a new ValueRange class.
River Riddle [Sat, 7 Dec 2019 04:06:48 +0000 (20:06 -0800)]
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

4 years agoImprove Linalg documentation following the Structured Ops presentation.
Nicolas Vasilache [Sat, 7 Dec 2019 01:08:26 +0000 (17:08 -0800)]
Improve Linalg documentation following the Structured Ops presentation.

PiperOrigin-RevId: 284291653

4 years agoAdd a flag to the IRPrinter instrumentation to only print after a pass if there is...
River Riddle [Sat, 7 Dec 2019 01:04:24 +0000 (17:04 -0800)]
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

4 years agoNFC - update doc, comments, vim syntax file
Uday Bondhugula [Sat, 7 Dec 2019 00:16:32 +0000 (16:16 -0800)]
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

4 years agoFix langref code snippet - NFC
nmostafa [Sat, 7 Dec 2019 00:03:16 +0000 (16:03 -0800)]
Fix langref code snippet - NFC

Closes tensorflow/mlir#294

PiperOrigin-RevId: 284281172

4 years agoNFC: Separate implementation and definition in ConvertStandardToSPIRV.cpp
Mahesh Ravishankar [Fri, 6 Dec 2019 23:25:46 +0000 (15:25 -0800)]
NFC: Separate implementation and definition in ConvertStandardToSPIRV.cpp
PiperOrigin-RevId: 284274326

4 years agoChange inferReturnTypes to return LogicalResult and values
Jacques Pienaar [Fri, 6 Dec 2019 22:42:16 +0000 (14:42 -0800)]
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

4 years agoReplace custom getBody method with an ODS-generated in gpu::LaunchOp
Alex Zinenko [Fri, 6 Dec 2019 22:28:54 +0000 (14:28 -0800)]
Replace custom getBody method with an ODS-generated in gpu::LaunchOp

PiperOrigin-RevId: 284262981

4 years agoDuring serialization do a walk of ops in module to find spv.module.
Mahesh Ravishankar [Fri, 6 Dec 2019 22:26:34 +0000 (14:26 -0800)]
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

4 years agoMove GPU::LaunchOp to ODS. NFC.
Alex Zinenko [Fri, 6 Dec 2019 22:23:06 +0000 (14:23 -0800)]
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

4 years agoUse named traits in the ODS definition of LLVMFuncOp
Alex Zinenko [Fri, 6 Dec 2019 22:18:05 +0000 (14:18 -0800)]
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

4 years ago[VecOps] Rename vector.[insert|extract]element to just vector.[insert|extract]
Aart Bik [Fri, 6 Dec 2019 20:38:52 +0000 (12:38 -0800)]
[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

4 years agoLLVM::GlobalOp: take address space as builder argument
Alex Zinenko [Fri, 6 Dec 2019 20:00:01 +0000 (12:00 -0800)]
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

4 years agoMove GPU::FuncOp definition to ODS - NFC
Alex Zinenko [Fri, 6 Dec 2019 19:59:59 +0000 (11:59 -0800)]
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

4 years agoProvide a way to get the type of a ValueHandle.
MLIR Team [Fri, 6 Dec 2019 19:06:38 +0000 (11:06 -0800)]
Provide a way to get the type of a ValueHandle.

PiperOrigin-RevId: 284221337

4 years ago[VectorOps] Add lowering of vector.broadcast to LLVM IR
Aart Bik [Fri, 6 Dec 2019 19:01:54 +0000 (11:01 -0800)]
[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

4 years agoGenerate builder for ops that use InferTypeOpInterface trait in ODS
Jacques Pienaar [Fri, 6 Dec 2019 18:52:38 +0000 (10:52 -0800)]
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

4 years agoAdd conversions of GPU func with memory attributions to LLVM/NVVM
Alex Zinenko [Fri, 6 Dec 2019 18:08:15 +0000 (10:08 -0800)]
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

4 years agofix examples in comments
Alexandre E. Eichenberger [Fri, 6 Dec 2019 17:40:12 +0000 (09:40 -0800)]
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

4 years agoUse regex to fix failure when stats are disabled.
River Riddle [Fri, 6 Dec 2019 17:28:48 +0000 (09:28 -0800)]
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

4 years agoUnroll vector masks along with their associated vector arguments.
Andy Davis [Fri, 6 Dec 2019 15:36:55 +0000 (07:36 -0800)]
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

4 years ago[spirv] Reorder `erase` and `emplace` to avoid "invalid iterator access".
Denis Khalikov [Fri, 6 Dec 2019 14:26:24 +0000 (06:26 -0800)]
[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

4 years agoDimOp folding for alloc/view dynamic dimensions
Uday Bondhugula [Fri, 6 Dec 2019 13:59:06 +0000 (05:59 -0800)]
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

4 years agominor spelling tweaks
Kazuaki Ishizaki [Fri, 6 Dec 2019 13:58:59 +0000 (05:58 -0800)]
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

4 years agoLLVM::AddressOfOp: properly take into account the address space
Alex Zinenko [Fri, 6 Dec 2019 09:08:40 +0000 (01:08 -0800)]
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

4 years agoNFC: Add documentation for `-mlir-print-op-on-diagnostic` and `-mlir-print-stacktrace...
River Riddle [Fri, 6 Dec 2019 01:46:37 +0000 (17:46 -0800)]
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

4 years agoAdd include path to the TestDialect to fix broken build.
River Riddle [Thu, 5 Dec 2019 23:32:59 +0000 (15:32 -0800)]
Add include path to the TestDialect to fix broken build.

PiperOrigin-RevId: 284067891

4 years ago[Linalg] Add permutation information to tiling
Jose Ignacio Gomez [Thu, 5 Dec 2019 23:14:22 +0000 (15:14 -0800)]
[Linalg] Add permutation information to tiling

This patch closes issue tensorflow/mlir#271.
It adds an optional permutation map to declarative tiling transformations.
The map is expressed as a list of integers.

Closes tensorflow/mlir#288

COPYBARA_INTEGRATE_REVIEW=https://github.com/tensorflow/mlir/pull/288 from tetuante:issue271 2df2938d6a1f01b3bc404ded08dea2dd1e10b588
PiperOrigin-RevId: 284064151

4 years agoRefactor the IRPrinting instrumentation to take a derivable config.
River Riddle [Thu, 5 Dec 2019 22:52:28 +0000 (14:52 -0800)]
Refactor the IRPrinting instrumentation to take a derivable config.

This allows for more interesting behavior from users, e.g. enabling the ability to dump the IR to a separate file for each pass invocation.

PiperOrigin-RevId: 284059447

4 years agoAdd UnrankedMemRef Type
nmostafa [Thu, 5 Dec 2019 21:12:50 +0000 (13:12 -0800)]
Add UnrankedMemRef Type

Closes tensorflow/mlir#261

COPYBARA_INTEGRATE_REVIEW=https://github.com/tensorflow/mlir/pull/261 from nmostafa:nmostafa/unranked 96b6e918f6ed64496f7573b2db33c0b02658ca45
PiperOrigin-RevId: 284037040

4 years ago[spirv] Add CompositeInsertOp operation
Denis Khalikov [Thu, 5 Dec 2019 21:10:10 +0000 (13:10 -0800)]
[spirv] Add CompositeInsertOp operation

A CompositeInsertOp operation make a copy of a composite object,
while modifying one part of it.

Closes tensorflow/mlir#292

COPYBARA_INTEGRATE_REVIEW=https://github.com/tensorflow/mlir/pull/292 from denis0x0D:sandbox/composite_insert 2200962b9057bda53cd2f2866b461e2797196380
PiperOrigin-RevId: 284036551

4 years agoAdd support for instance specific pass statistics.
River Riddle [Thu, 5 Dec 2019 19:52:58 +0000 (11:52 -0800)]
Add support for instance specific pass statistics.

Statistics are a way to keep track of what the compiler is doing and how effective various optimizations are. It is useful to see what optimizations are contributing to making a particular program run faster. Pass-instance specific statistics take this even further as you can see the effect of placing a particular pass at specific places within the pass pipeline, e.g. they could help answer questions like "what happens if I run CSE again here".

Statistics can be added to a pass by simply adding members of type 'Pass::Statistics'. This class takes as a constructor arguments: the parent pass pointer, a name, and a description. Statistics can be dumped by the pass manager in a similar manner to how pass timing information is dumped, i.e. via PassManager::enableStatistics programmatically; or -pass-statistics and -pass-statistics-display via the command line pass manager options.

Below is an example:

struct MyPass : public OperationPass<MyPass> {
  Statistic testStat{this, "testStat", "A test statistic"};

  void runOnOperation() {
    ...
    ++testStat;
    ...
  }
};

$ mlir-opt -pass-pipeline='func(my-pass,my-pass)' foo.mlir -pass-statistics

Pipeline Display:
===-------------------------------------------------------------------------===
                         ... Pass statistics report ...
===-------------------------------------------------------------------------===
'func' Pipeline
  MyPass
    (S) 15 testStat - A test statistic
  MyPass
    (S)  6 testStat - A test statistic

List Display:
===-------------------------------------------------------------------------===
                         ... Pass statistics report ...
===-------------------------------------------------------------------------===
MyPass
  (S) 21 testStat - A test statistic

PiperOrigin-RevId: 284022014

4 years agoAllow specification of the workgroup size for GPUToSPIRV lowering.
Mahesh Ravishankar [Thu, 5 Dec 2019 19:31:28 +0000 (11:31 -0800)]
Allow specification of the workgroup size for GPUToSPIRV lowering.

SPIR-V/Vulkan spec requires the workgroups size to be specified with
the spv.ExecutionMode operation. This was hard-wired to be set to a
particular value. It is now changed to be configurable by clients of
the pass or of the patterns that implement the lowering from GPU to
SPIRV.

PiperOrigin-RevId: 284017482

4 years agoAdd spv.AtomicCompareExchangeWeak
Lei Zhang [Thu, 5 Dec 2019 18:05:54 +0000 (10:05 -0800)]
Add spv.AtomicCompareExchangeWeak

PiperOrigin-RevId: 283997917

4 years agoAdd a flag to dump the current stack trace when emitting a diagnostic.
River Riddle [Thu, 5 Dec 2019 17:59:52 +0000 (09:59 -0800)]
Add a flag to dump the current stack trace when emitting a diagnostic.

It is often desirable to know where within the program that a diagnostic was emitted, without reverting to assert/unreachable which crash the program. This change adds a flag `mlir-print-stacktrace-on-diagnostic` that attaches the current stack trace as a note to every diagnostic that gets emitted.

PiperOrigin-RevId: 283996373

4 years ago[spirv] Fix nested loop (de)serialization
Lei Zhang [Thu, 5 Dec 2019 12:39:06 +0000 (04:39 -0800)]
[spirv] Fix nested loop (de)serialization

For serialization, when we have nested ops, the inner loop will create multiple
SPIR-V blocks. If the outer loop has block arguments (which corresponds to
OpPhi instructions), we defer the handling of OpPhi's parent block handling
until we serialized all blocks and then fix it up with the result <id>. These two
cases happening together was generating invalid SPIR-V blob because we
previously assume the parent block to be the block containing the terminator.
That is not true anymore when the block contains structured control flow ops.
If that happens, it should be fixed to use the structured control flow op's
merge block.

For deserialization, we record a map from header blocks to their corresponding
merge and continue blocks during the initial deserialization and then use the
info to construct spv.selection/spv.loop. The existing implementation will also
fall apart when we have nested loops. If so, we clone all blocks for the outer
loop, including the ones for the inner loop, to the spv.loop's region. So the map
for header blocks' merge info need to be updated; otherwise we are operating
on already deleted blocks.

PiperOrigin-RevId: 283949230

4 years agoFix MLIR Build after LLVM upstream JIT changes (getMainJITDylib removed)
Mehdi Amini [Thu, 5 Dec 2019 12:32:13 +0000 (04:32 -0800)]
Fix MLIR Build after LLVM upstream JIT changes (getMainJITDylib removed)

The getMainJITDylib() method was removed in 4fc68b9b7f, replace it by creating a JITDylib on the fly.

PiperOrigin-RevId: 283948595

4 years agoMove ModuleManager functionality into mlir::SymbolTable.
Tres Popp [Thu, 5 Dec 2019 11:56:18 +0000 (03:56 -0800)]
Move ModuleManager functionality into mlir::SymbolTable.

Note for broken code, the following transformations occurred:
ModuleManager::insert(Block::iterator, Operation*) - > SymbolTable::insert(Operation*, Block::iterator)
ModuleManager::lookupSymbol -> SymbolTable::lookup
ModuleManager::getModule() -> SymbolTable::getOp()
ModuleManager::getContext() -> SymbolTable::getOp()->getContext()
ModuleManager::* -> SymbolTable::*
PiperOrigin-RevId: 283944635

4 years agoAdd MLIRIR as a dependency to LLVM and related dialects
Lei Zhang [Thu, 5 Dec 2019 07:45:01 +0000 (23:45 -0800)]
Add MLIRIR as a dependency to LLVM and related dialects

Fixes tensorflow/mlir#289

PiperOrigin-RevId: 283914472

4 years agoOptimize operation ordering to support non-congruent indices.
River Riddle [Thu, 5 Dec 2019 00:09:41 +0000 (16:09 -0800)]
Optimize operation ordering to support non-congruent indices.

This change adds support for non-congruent indices in the operation ordering within a basic block. This effect of this is that insertions are less likely to cause an invalidation of the ordering within a block. This has a big effect on modules that have very large basic blocks.

PiperOrigin-RevId: 283858136

4 years agoAdd emitOptional(Error|Warning|Remark) functions to simplify emission with an optiona...
River Riddle [Wed, 4 Dec 2019 23:49:09 +0000 (15:49 -0800)]
Add emitOptional(Error|Warning|Remark) functions to simplify emission with an optional location.

In some situations a diagnostic may optionally be emitted by the presence of a location, e.g. attribute and type verification. These situations currently require extra 'if(loc) emitError(...); return failure()' wrappers that make verification clunky. These new overloads take an optional location and a list of arguments to the diagnostic, and return a LogicalResult. We take the arguments directly and return LogicalResult instead of returning InFlightDiagnostic because we cannot create a valid diagnostic with a null location. This creates an awkward situation where a user may try to treat the, potentially null, diagnostic as a valid one and encounter crashes when attaching notes/etc. Below is an example of how these methods simplify some existing usages:

Before:

  if (loc)
    emitError(*loc, "this is my diagnostic with argument: ") << 5;
  return failure();

After:

  return emitOptionalError(loc, "this is my diagnostic with argument: ", 5);

PiperOrigin-RevId: 283853599

4 years agoAdd a CL option to Standard to LLVM lowering to use alloca instead of malloc/free.
Nicolas Vasilache [Wed, 4 Dec 2019 22:15:24 +0000 (14:15 -0800)]
Add a CL option to Standard to LLVM lowering to use alloca instead of malloc/free.

In the future, a more configurable malloc and free interface should be used and exposed via
extra parameters to the `createLowerToLLVMPass`. Until requirements are gathered, a simple CL flag allows generating code that runs successfully on hardware that cannot use the stdlib.

PiperOrigin-RevId: 283833424

4 years agoAdd canonicalization patterns for vector CreateMaskOp and StridedSliceOp to be used...
Andy Davis [Wed, 4 Dec 2019 21:00:14 +0000 (13:00 -0800)]
Add canonicalization patterns for vector CreateMaskOp and StridedSliceOp to be used in the unroll vector op transformation.
Adds a ConstantMaskOp to the vector ops dialect.
Adds the following canonicalization patterns:
CreateMaskOp -> ConstantMaskOp
StridedSliceOp(ConstantMaskOp) -> ConstantMaskOp

PiperOrigin-RevId: 283816752

4 years ago[CSE] NFC: Hash the attribute dictionary pointer instead of the list of attributes.
River Riddle [Wed, 4 Dec 2019 20:31:36 +0000 (12:31 -0800)]
[CSE] NFC: Hash the attribute dictionary pointer instead of the list of attributes.

PiperOrigin-RevId: 283810829

4 years agoDrop MaterializeVectorTransfers in favor of simpler declarative unrolling
Nicolas Vasilache [Wed, 4 Dec 2019 20:11:08 +0000 (12:11 -0800)]
Drop MaterializeVectorTransfers in favor of simpler declarative unrolling

Now that we have unrolling as a declarative pattern, we can drop a full pass that has gone stale. In the future we may want to add specific unrolling patterns for VectorTransferReadOp.

PiperOrigin-RevId: 283806880

4 years agoNFC: Fix mismatches between LangRef.md and actual parser implementation.
River Riddle [Wed, 4 Dec 2019 20:05:52 +0000 (12:05 -0800)]
NFC: Fix mismatches between LangRef.md and actual parser implementation.
PiperOrigin-RevId: 283805832

4 years ago[spirv] Define a few more extensions in SPIRVBase.td
Lei Zhang [Wed, 4 Dec 2019 19:34:01 +0000 (11:34 -0800)]
[spirv] Define a few more extensions in SPIRVBase.td

PiperOrigin-RevId: 283798496

4 years agoPrint out large elementsattr's such that they are parseable.
Sean Silva [Wed, 4 Dec 2019 18:19:20 +0000 (10:19 -0800)]
Print out large elementsattr's such that they are parseable.

I found that when running crash reproducers, the elided elementsattr's
would prevent parsing the IR repro. I found myself manually going and
replacing the "..." with some valid IR.

With this change, we now print elided attrs as `opaque<"", "0xDEADBEEF">`
to clearly delineate them as being elided while still being parseable.

PiperOrigin-RevId: 283781806

4 years agoNFC - fix name / comments - isAccessInvariant
Uday Bondhugula [Wed, 4 Dec 2019 17:29:51 +0000 (09:29 -0800)]
NFC - fix name / comments - isAccessInvariant

- the name was misleading; this is really checking if a Value being used
  to index was loop IV invariant. Update comment.

- the method is only used locally; what can be exposed in the future is
  isAccessInvariant(LoadOrStoreOp op, Value *iv)

Signed-off-by: Uday Bondhugula <uday@polymagelabs.com>
Closes tensorflow/mlir#285

COPYBARA_INTEGRATE_REVIEW=https://github.com/tensorflow/mlir/pull/285 from bondhugula:quickfix fe5837abe987980c4ab469a9aa7de8e4f0007d9f
PiperOrigin-RevId: 283771923

4 years ago[spirv] Adding sqrt op in the GLSL extension.
Scott Todd [Wed, 4 Dec 2019 17:15:49 +0000 (09:15 -0800)]
[spirv] Adding sqrt op in the GLSL extension.

PiperOrigin-RevId: 283769736

4 years agoLoop coalescing: fix pointer chainsing in use-chain traversal
Alex Zinenko [Wed, 4 Dec 2019 15:41:55 +0000 (07:41 -0800)]
Loop coalescing: fix pointer chainsing in use-chain traversal

In the replaceAllUsesExcept utility function called from loop coalescing the
iteration over the use-chain is incorrect. The use list nodes (IROperands) have
next/prev links, and bluntly resetting the use would make the loop to continue
on uses of the value that was replaced instead of the original one. As a
result, it could miss the existing uses and update the wrong ones. Make sure we
increment the iterator before updating the use in the loop body.

Reported-by: Uday Bondhugula <uday@polymagelabs.com>
Closes tensorflow/mlir#291.

PiperOrigin-RevId: 283754195

4 years agoAdded new FAbs, FCeil, Cos, Neg, Sign, Tanh operations.
Julian Gross [Wed, 4 Dec 2019 15:17:01 +0000 (07:17 -0800)]
Added new FAbs, FCeil, Cos, Neg, Sign, Tanh operations.

Closes tensorflow/mlir#251

COPYBARA_INTEGRATE_REVIEW=https://github.com/tensorflow/mlir/pull/251 from dfki-jugr:new_ops 0398997bf9953016898f873068e22916a062eb2b
PiperOrigin-RevId: 283750699

4 years agoAdds support for unrolling single-result vector operations with iterator type lists...
Andy Davis [Wed, 4 Dec 2019 14:53:07 +0000 (06:53 -0800)]
Adds support for unrolling single-result vector operations with iterator type lists and indexing maps to a target vector size.
Adds unit tests for unrolling the vector ContractionOp with different iteration orders.

PiperOrigin-RevId: 283747503

4 years agominor spelling tweaks
Kazuaki Ishizaki [Wed, 4 Dec 2019 12:58:12 +0000 (04:58 -0800)]
minor spelling tweaks

Closes tensorflow/mlir#250

COPYBARA_INTEGRATE_REVIEW=https://github.com/tensorflow/mlir/pull/250 from kiszk:spelling_tweaks_201911 50fc04443723190b764e824b6fcd2469fecb56e6
PiperOrigin-RevId: 283733032

4 years agoAvoid variable name conflict in MLIR tutorial code snippet
Smit Hinsu [Wed, 4 Dec 2019 05:25:02 +0000 (21:25 -0800)]
Avoid variable name conflict in MLIR tutorial code snippet

PiperOrigin-RevId: 283682865