Alex Zinenko [Tue, 8 Oct 2019 12:11:00 +0000 (05:11 -0700)]
GPUToCUDA: attach CUBIN to the nested module rather than to the function
Originally, we were attaching attributes containing CUBIN blobs to the kernel
function called by `gpu.launch_func`. This kernel is now contained in a nested
module that is used as a compilation unit. Attach compiled CUBIN blobs to the
module rather than to the function since we were compiling the module. This
also avoids duplication of the attribute on multiple kernels within the same
module.
PiperOrigin-RevId:
273497303
Alex Zinenko [Tue, 8 Oct 2019 12:03:09 +0000 (05:03 -0700)]
GPUToCUDA: emit addressof directly instead of wrapping it into a getter function
Originally, the CUBIN getter function was introduced as a mechanism to
circumvent the absence of globals in the LLVM dialect. It would allocate memory
and populate it with the CUBIN data. LLVM dialect now supports globals and they
are already used to store CUBIN data, making the getter function a trivial
address computation of a global. Emit the address computation directly at the
place of `gpu.launch_func` instead of putting it in a function and calling it.
This simplifies the conversion flow and prepares it for using the
DialectConversion infrastructure.
PiperOrigin-RevId:
273496221
Alex Zinenko [Tue, 8 Oct 2019 11:35:04 +0000 (04:35 -0700)]
Fuse GenerateCubinAccessors pass into LaunchFunctToCuda
Now that the accessor function is a trivial getter of the global variable, it
makes less sense to have the getter generation as a separate pass. Move the
getter generation into the lowering of `gpu.launch_func` to CUDA calls. This
change is mostly code motion, but the process can be simplified further by
generating the addressof inplace instead of using a call. This is will be done
in a follow-up.
PiperOrigin-RevId:
273492517
Alex Zinenko [Tue, 8 Oct 2019 11:29:58 +0000 (04:29 -0700)]
Use named modules for gpu.launch_func
The kernel function called by gpu.launch_func is now placed into an isolated
nested module during the outlining stage to simplify separate compilation.
Until recently, modules did not have names and could not be referenced. This
limitation was circumvented by introducing a stub kernel at the same name at
the same nesting level as the module containing the actual kernel. This
relation is only effective in one direction: from actual kernel function to its
launch_func "caller".
Leverage the recently introduced symbol name attributes on modules to refer to
a specific nested module from `gpu.launch_func`. This removes the implicit
connection between the identically named stub and kernel functions. It also
enables support for `gpu.launch_func`s to call different kernels located in the
same module.
PiperOrigin-RevId:
273491891
Jing Pu [Tue, 8 Oct 2019 04:52:36 +0000 (21:52 -0700)]
Update upgrade some uses of mlir::interleave API to take container argument directly.
PiperOrigin-RevId:
273446814
River Riddle [Tue, 8 Oct 2019 00:18:54 +0000 (17:18 -0700)]
Add a flag to the AsmPrinter for eliding large ElementsAttrs.
Some modules may have extremely large ElementsAttrs, which makes debugging involving IR dumping extremely slow and painful. This change adds a flag that will elide ElementsAttrs with a "large"(as defined by the user) number of elements by printing "..." instead of the element data.
PiperOrigin-RevId:
273413100
Jing Pu [Mon, 7 Oct 2019 23:45:26 +0000 (16:45 -0700)]
Print result types when dumping graphviz.
PiperOrigin-RevId:
273406833
MLIR Team [Mon, 7 Oct 2019 22:00:35 +0000 (15:00 -0700)]
Expose `fuseProducerOf` in Linalg/Utils/Utils.h.
PiperOrigin-RevId:
273384063
Mahesh Ravishankar [Mon, 7 Oct 2019 21:51:31 +0000 (14:51 -0700)]
Do not add spirv::BitcastOp for cast from signed to unsigned type.
Since MLIR integer types don't make a distinction between signed vs
unsigned integers, during deserialization of SPIR-V binaries, the
OpBitcast might result in a cast from/to the same type. Do not add a
spv.Bitcast operation to the spv.module in these cases.
PiperOrigin-RevId:
273381887
Lei Zhang [Mon, 7 Oct 2019 21:40:18 +0000 (14:40 -0700)]
[spirv] Disable a crashing spv.loop test
PiperOrigin-RevId:
273379318
River Riddle [Mon, 7 Oct 2019 20:54:16 +0000 (13:54 -0700)]
Add a new class, OpPrintingFlags, to enable programmatic control of Operation::print behavior.
This allows for controlling the behavior of the AsmPrinter programmatically, instead of relying exclusively on cl::opt flags. This will also allow for more fine-tuned control of printing behavior per callsite, instead of being applied globally.
PiperOrigin-RevId:
273368361
Mahesh Ravishankar [Mon, 7 Oct 2019 19:56:08 +0000 (12:56 -0700)]
Update UndefOp (de)serialization to generate OpUndef at module level.
The SPIR-V spec recommends all OpUndef instructions be generated at
module level. For the SPIR-V dialect its better for UndefOp to produce
an SSA value for use with other instructions. If UndefOp is to be used
at module level, it cannot produce an SSA value (use of this SSA value
within FuncOp would need implicit capture). To satisfy needs of the
SPIR-V spec while making it simpler to represent UndefOp in the SPIR-V
dialect, the serialization is updated to create OpUndef instruction
at module scope.
PiperOrigin-RevId:
273355526
Lei Zhang [Mon, 7 Oct 2019 19:36:39 +0000 (12:36 -0700)]
[spirv] Fix function entry block erase after moving to spv.selection
The structured selection/loop's entry block does not have arguments.
If the function's header block is also part of the structured control
flow, we cannot just simply erase it because it may contain arguments
matching the function signature and used by the cloned blocks. Instead,
turn it into a block only containing a spv.Branch op.
Also, we can directly emit instructions for the spv.selection header
block to the block containing the spv.selection op. This eliminates
unnecessary branches in the SPIR-V blob.
Added a test for nested spv.loop.
PiperOrigin-RevId:
273351424
Uday Bondhugula [Mon, 7 Oct 2019 17:03:38 +0000 (10:03 -0700)]
fix simplify-affine-structures bug
Signed-off-by: Uday Bondhugula <uday@polymagelabs.com>
Closes tensorflow/mlir#157
COPYBARA_INTEGRATE_REVIEW=https://github.com/tensorflow/mlir/pull/157 from bondhugula:quickfix
bd1fcd79825fc0bd5b4a3e688153fa0993ab703d
PiperOrigin-RevId:
273316498
Christian Sigg [Mon, 7 Oct 2019 17:02:44 +0000 (10:02 -0700)]
Change Block::getParent() to be a const function. This is only necessary because ilist_node_with_parent specifically requires a 'getParent() const' method. If/When ilist_node removes this constraint we should drop the const to fit the rest of the MLIR const model.
PiperOrigin-RevId:
273316153
Stephan Herhut [Mon, 7 Oct 2019 16:26:58 +0000 (09:26 -0700)]
Fix a comment in the OperationInterface example.
PiperOrigin-RevId:
273308494
Nicolas Vasilache [Mon, 7 Oct 2019 16:06:08 +0000 (09:06 -0700)]
Start a minimal mlir_utils runtime library for testing debugging purposes
Now that MLIR has a standardized StridedMemRef descriptor, it becomes very easy to interact with external library functions and build utilities directly in C++.
This CL introduces basic printing support in a libmlir_utils.so.
Unit tests are rewritten using this feature and also to improve coverage.
For now, C mandates that we have a unique function for each MemRef element type and rank.
In a future a simple unranked descriptor can be introduced to only require uniqu'ing by element type.
PiperOrigin-RevId:
273304741
Nicolas Vasilache [Mon, 7 Oct 2019 16:00:39 +0000 (09:00 -0700)]
Support AllocOp terminal in Linalg::AliasAnalysis.
Now that linalg.view and strided memrefs are unified, there is no reason to
disallow AllocOp in alias analysis. This CLs adds support for AllocOp which allows writing shorter tests that do not require explicitly creating a view for
each operation.
PiperOrigin-RevId:
273303060
Jacques Pienaar [Mon, 7 Oct 2019 15:40:29 +0000 (08:40 -0700)]
Add DialectType and generate docs for dialect types
Add new `typeDescription` (description was already used by base constraint class) field to type to allow writing longer descriptions about a type being defined. This allows for providing additional information/rationale for a defined type. This currently uses `description` as the heading/name for the type in the generated documentation.
PiperOrigin-RevId:
273299332
Nicolas Vasilache [Mon, 7 Oct 2019 15:25:24 +0000 (08:25 -0700)]
Fix CMake build after adding TestOpaqueLoc.cpp
PiperOrigin-RevId:
273296399
MLIR Team [Mon, 7 Oct 2019 12:05:07 +0000 (05:05 -0700)]
Add OpaqueLoc to MLIR locations.
See RFC: https://groups.google.com/a/tensorflow.org/forum/#!topic/mlir/xE2IzfhE3Wg.
Opaque location stores two pointers, one of them points to some data structure that is external to MLIR, and the other one is unique for each type and represents type id of that data structure. OpaqueLoc also stores an optional location that can be used if the first one is not suitable.
OpaqueLoc is managed similar to FileLineColLoc. It is passed around by MLIR transformations and can be used in compound locations like CallSiteLoc.
PiperOrigin-RevId:
273266510
Christian Sigg [Mon, 7 Oct 2019 10:30:34 +0000 (03:30 -0700)]
Support reduction of partial warps.
gpu.all_reduce now supports block sizes that are not multiple of 32.
PiperOrigin-RevId:
273255204
Jacques Pienaar [Sat, 5 Oct 2019 19:21:07 +0000 (12:21 -0700)]
Enable emitting dialect summary & description during op generation
Sort ops per dialect and emit summary & description (if provided) of each dialect before emitting the ops of the dialect.
PiperOrigin-RevId:
273077138
Geoffrey Martin-Noble [Sat, 5 Oct 2019 17:05:40 +0000 (10:05 -0700)]
Allow element type traits to operate on scalars
This allows confirming that a scalar argument has the same element type as a shaped one. It's easy to validate a type is shaped on its own if that's desirable, so this shouldn't make that use case harder. This matches the behavior of other traits that operate on element type (e.g. AllElementTypesMatch). Also this makes the code simpler because now we just use getElementTypeOrSelf.
Verified that all uses in core already check the type is shaped in another way.
PiperOrigin-RevId:
273068507
Geoffrey Martin-Noble [Sat, 5 Oct 2019 17:00:11 +0000 (10:00 -0700)]
NFC: Cleanup test ops and traits tests
1. Rename a few ops to make it clear they operate on *element* types.
2. Remove unused and generic operand and result ODS names (e.g. $res, $arg, $input). These are just clutter and don't make the op definitions any clearer.
3. Give test cases with duplicate names clearer names.
4. Add missing test case for no operands in SameOperandAndResultElementType.
PiperOrigin-RevId:
273067933
Lei Zhang [Sat, 5 Oct 2019 03:08:05 +0000 (20:08 -0700)]
[spirv] Allow return ops to be in control flow ops
Use `getParentOfType<FunctionOp>()` instead of `cast<FuncOp>(getParentOp())`
to avoid crash when return ops are used inside spv.selection/spv.loop.
PiperOrigin-RevId:
273006041
Mehdi Amini [Sat, 5 Oct 2019 01:40:09 +0000 (18:40 -0700)]
Add missing dependency on the TypeInferOpInterface from the Test dialect
This is fixing a build failure, usually non-deterministic because of
parallelism in the build, but could be reliably reproduced:
ninja projects/mlir/test/lib/TestDialect/CMakeFiles/MLIRTestDialect.dir/TestPatterns.cpp.o
PiperOrigin-RevId:
272998436
Mahesh Ravishankar [Fri, 4 Oct 2019 22:59:54 +0000 (15:59 -0700)]
Add spv.Undef op to support OpUndef instruction in SPIR-V.
Adding support for OpUndef instruction. Updating the dialect
generation script to fix a few bugs in the instruction spec
generation.
PiperOrigin-RevId:
272975685
Mahesh Ravishankar [Fri, 4 Oct 2019 21:02:14 +0000 (14:02 -0700)]
Add some utility builder functions for SPIR-V operations.
Add builder functions for spv._address_of, spv.EntryPoint,
spv.ExecutionMode and spv.Load to make it easier to create these
operations.
Fix a minor bug in printing of spv.EntryPoint
Add a utility function to get the attribute name associated with a
decoration.
PiperOrigin-RevId:
272952846
Nicolas Vasilache [Fri, 4 Oct 2019 15:57:28 +0000 (08:57 -0700)]
Replace constexpr MemRefType::kDynamicStrideOrOffset by a MemRefType:;getDynamicStrideOrOffset() method - NFC
This fixes global ODR-use issues, some of which manifest in Parser.cpp.
Fixes tensorflow/mlir#167.
PiperOrigin-RevId:
272886347
Nicolas Vasilache [Fri, 4 Oct 2019 15:07:12 +0000 (08:07 -0700)]
Add missing Linalg lowerings to allow roundtrip.mlir to lower to LLVM
Certain lowering patterns were reported as [missing](https://groups.google.com/a/tensorflow.org/forum/#!topic/mlir/dkdmHa77sSQ).
This CL adds them and allows Linalg/roundtrip.mlir and Linalg/loops.mlir to lower to LLVM directly. Those 2 tests are updated to additionally check that the direct lowering to LLVM does not crash.
The following points, left as TODOs still need to be addressed for correct end-to-end execution:
1. the lowering for ConvOp needs to pass attributes such as strides and dilations; the external library call needs to support it.
2. the lowering for GenericOp needs to support lowering to loops as a DialectConversion pattern. This is blocked on the DialectConversion infrastructure accepting an OperationFolder.
PiperOrigin-RevId:
272878131
Deven Desai [Fri, 4 Oct 2019 13:19:25 +0000 (06:19 -0700)]
Moving the GPUIndexIntrinsicOpLowering template to a common location
The GPUIndexIntrinsicOpLowering template is currently used by the code in both the GPUToNVVM and GPUToROCDL dirs.
Moving it to a common location to remove code duplication.
Closes tensorflow/mlir#163
COPYBARA_INTEGRATE_REVIEW=https://github.com/tensorflow/mlir/pull/163 from deven-amd:deven-refactor-gpu-index-ops-lowering
b8dc2a5f5353df196039b6ff2ad42106028693ed
PiperOrigin-RevId:
272863297
Christian Sigg [Fri, 4 Oct 2019 11:37:14 +0000 (04:37 -0700)]
Fix typos, NFC.
PiperOrigin-RevId:
272851237
River Riddle [Fri, 4 Oct 2019 06:10:25 +0000 (23:10 -0700)]
Add support for inlining calls with different arg/result types from the callable.
Some dialects have implicit conversions inherent in their modeling, meaning that a call may have a different type that the type that the callable expects. To support this, a hook is added to the dialect interface that allows for materializing conversion operations during inlining when there is a mismatch. A hook is also added to the callable interface to allow for introspecting the expected result types.
PiperOrigin-RevId:
272814379
River Riddle [Fri, 4 Oct 2019 06:04:56 +0000 (23:04 -0700)]
Update the Inliner pass to work on SCCs of the CallGraph.
This allows for the inliner to work on arbitrary call operations. The updated inliner will also work bottom-up through the callgraph enabling support for multiple levels of inlining.
PiperOrigin-RevId:
272813876
Feng Liu [Fri, 4 Oct 2019 03:28:40 +0000 (20:28 -0700)]
Add `axis` attribute to the quant.stats op
The first dim length of the axisStats attribute should equals to the slice size
of the input argument when splitted by the axis dimension.
PiperOrigin-RevId:
272798042
MLIR Team [Thu, 3 Oct 2019 23:36:43 +0000 (16:36 -0700)]
Add fpext and fptrunc to the Standard dialect and includes conversion to LLVM
PiperOrigin-RevId:
272768027
Christian Sigg [Thu, 3 Oct 2019 19:59:42 +0000 (12:59 -0700)]
Generalize parse/printBinaryOp to parse/printOneResultOp.
PiperOrigin-RevId:
272722539
Nicolas Vasilache [Thu, 3 Oct 2019 19:33:47 +0000 (12:33 -0700)]
Add syntactic sugar for strided memref parsing.
This CL implements the last remaining bit of the [strided memref proposal](https://groups.google.com/a/tensorflow.org/forum/#!topic/mlir/MaL8m2nXuio).
The syntax is a bit more explicit than what was originally proposed and resembles:
`memref<?x?xf32, offset: 0 strides: [?, 1]>`
Nonnegative strides and offsets are currently supported. Future extensions will include negative strides.
This also gives a concrete example of syntactic sugar for the ([RFC] Proposed Changes to MemRef and Tensor MLIR Types)[https://groups.google.com/a/tensorflow.org/forum/#!topic/mlir/-wKHANzDNTg].
The underlying implementation still uses AffineMap layout.
PiperOrigin-RevId:
272717437
Alex Zinenko [Thu, 3 Oct 2019 17:04:05 +0000 (10:04 -0700)]
Make Module::getName return Optional<StringRef>
Module names are optional so it makes more sense to take and return an optional
any time the name is involved. Also update the language reference to reflect
the module names.
PiperOrigin-RevId:
272684698
Alex Zinenko [Thu, 3 Oct 2019 15:56:12 +0000 (08:56 -0700)]
Give modules a name
Modules are now Ops and, as such, can be nested. They do not produce an SSA
value so there is no possibility to refer to them in the IR. Introduce support
for symbol names attached to the module Op so that it can be referred to using
SymbolRefAttrs. The name is optional, for example the implicit top-level module
does not have a name.
PiperOrigin-RevId:
272671600
Alex Zinenko [Thu, 3 Oct 2019 08:46:39 +0000 (01:46 -0700)]
Add parentheses around boolean operators in assert
This removes a warning and is generally a good practice.
PiperOrigin-RevId:
272613597
Alex Zinenko [Thu, 3 Oct 2019 08:34:16 +0000 (01:34 -0700)]
NFC: rename Conversion/ControlFlowToCFG to Conversion/LoopToStandard
This makes the name of the conversion pass more consistent with the naming
scheme, since it actually converts from the Loop dialect to the Standard
dialect rather than working with arbitrary control flow operations.
PiperOrigin-RevId:
272612112
Alex Zinenko [Thu, 3 Oct 2019 07:57:55 +0000 (00:57 -0700)]
Disallow index types in memrefs.
As specified in the MLIR language reference and rationale documents, `memref`
types should not be allowed to have `index` as element types. As observed in
https://groups.google.com/a/tensorflow.org/forum/#!msg/mlir/P49hVWqTMNc/nW89a4i_AgAJ
this restriction was lifted when canonicalization unit tests for affine
operations were introduced, without sufficient motivation to lift the
restriction itself. The test in question can be trivially rewritten (return
the value from a function instead of storing it to prevent DCE from removing
the producer operation) and the restriction put back in place.
If `memref<...x index>` is relevant for some use cases, the relaxation of the
type system can be implemented separately with appropriate modifications to the
documentation.
PiperOrigin-RevId:
272607043
Nicolas Vasilache [Wed, 2 Oct 2019 20:24:27 +0000 (13:24 -0700)]
Extract MemRefType::getStridesAndOffset as a free function and fix dynamic offset determination.
This also adds coverage with a missing test, which uncovered a bug in the conditional for testing whether an offset is dynamic or not.
PiperOrigin-RevId:
272505798
Lei Zhang [Wed, 2 Oct 2019 18:00:50 +0000 (11:00 -0700)]
[spirv] Add support for spv.selection
Similar to spv.loop, spv.selection is another op for modelling
SPIR-V structured control flow. It covers both OpBranchConditional
and OpSwitch with OpSelectionMerge.
Instead of having a `spv.SelectionMerge` op to directly model
selection merge instruction for indicating the merge target,
we use regions to delimit the boundary of the selection: the
merge target is the next op following the `spv.selection` op.
This way it's easier to discover all blocks belonging to
the selection and it plays nicer with the MLIR system.
PiperOrigin-RevId:
272475006
Alex Zinenko [Wed, 2 Oct 2019 16:15:53 +0000 (09:15 -0700)]
Fix example in OpInterfaces documentation
The concept-based polymorphism structure was missing an inheritance link
between the concept and the model. The interface class did not re-export the
base class constructor, which made it unusable with llvm::isa calls. Fix these
and reformat the code around.
PiperOrigin-RevId:
272452062
Nicolas Vasilache [Wed, 2 Oct 2019 13:36:52 +0000 (06:36 -0700)]
Replace spurious `long` stride type by int64_t - NFC
PiperOrigin-RevId:
272425434
Deven Desai [Wed, 2 Oct 2019 08:50:03 +0000 (01:50 -0700)]
[ROCm] Adding pass to lower GPU Dialect to ROCDL Dialect.
This is a follow-up to the PRtensorflow/mlir#146 which introduced the ROCDL Dialect. This PR introduces a pass to lower GPU Dialect to the ROCDL Dialect. As with the previous PR, this one builds on the work done by @whchung, and addresses most of the review comments in the original PR.
Closes tensorflow/mlir#154
COPYBARA_INTEGRATE_REVIEW=https://github.com/tensorflow/mlir/pull/154 from deven-amd:deven-lower-gpu-to-rocdl
809893e08236da5ab6a38e3459692fa04247773d
PiperOrigin-RevId:
272390729
Jacques Pienaar [Wed, 2 Oct 2019 08:45:35 +0000 (01:45 -0700)]
Show type even if elementsattr is elided in graph
The type is quite useful for debugging and shouldn't be too large.
PiperOrigin-RevId:
272390311
Lei Zhang [Tue, 1 Oct 2019 21:07:42 +0000 (14:07 -0700)]
[spirv] Change enum case uniquing in gen_spirv_dialect.py
In SPIR-V we can have multiple symbols corresponding to the same
enum value. This is because when an extension is introduced into
the core spec, its suffix is typically removed, e.g., 'VulkanKHR'
memory model becomes 'Vulkan' memory model in SPIR-V 1.5.
Previously we just keep the first symbol for an enum value. That
symbol is not necessarily a better one. This CL changes to sort
symbols, grouped by enum values, alphabetically and then keep
the first one, which is typically shorter and without the extension
suffix. We also fix up certain ones like HlslSemanticGOOGLE.
PiperOrigin-RevId:
272290363
Eric Schweitz [Tue, 1 Oct 2019 20:55:10 +0000 (13:55 -0700)]
Add a pair of hooks to DominanceInfo.
This exposes hooks for accessing internal dominance nodes, and updating the internal DFS numbers.
Closes tensorflow/mlir#151
COPYBARA_INTEGRATE_REVIEW=https://github.com/tensorflow/mlir/pull/151 from schweitzpgi:dominance_hooks
69d14214a423b816cbd59feffcacdd02f3b5f921
PiperOrigin-RevId:
272287352
Alex Zinenko [Tue, 1 Oct 2019 15:41:16 +0000 (08:41 -0700)]
Fix and simplify CallOp/CallIndirectOp to LLVM::CallOp conversion
A recent ABI compatibility change affected the conversion from standard
CallOp/CallIndirectOp to LLVM::CallOp by changing its signature. In order to
analyze the signature, the code was looking up the callee symbol in the module.
This is incorrect since, during the conversion, the module may contain both the
original and the converted function op that have the same symbol name. There is
no strict guarantee on which of the two symbols will be found by the lookup.
The conversion was not failing because the type legalizer converts the LLVM
types to themselves making the original and the converted function signatures
ultimately produce the same type.
Instead of looking up the function signature to get the list of result types,
use the types of the CallOp/CallIndirectOp results which must match those of
the function in valid IR. These types are guaranteed to be the original,
unconverted types when converting the operation. Furthermore, this avoids the
need to perform a lookup of a symbol name in the module which may be expensive.
Finally, propagate attributes as-is from the original op to the converted op
since they share the attribute name for the callee of direct calls and the rest
of attributes are not affected by the conversion. This removes the need for
additional contorsions between direct and indirect calls to extract the name of
the optional callee attribute only to insert it back. This also prevents the
conversion from unintentionally dropping the other attributes of the op.
PiperOrigin-RevId:
272218871
Nicolas Vasilache [Tue, 1 Oct 2019 12:22:54 +0000 (05:22 -0700)]
Unify Linalg types by using strided memrefs
This CL finishes the implementation of the Linalg + Affine type unification of the [strided memref RFC](https://groups.google.com/a/tensorflow.org/forum/#!topic/mlir/MaL8m2nXuio).
As a consequence, the !linalg.view type, linalg::DimOp, linalg::LoadOp and linalg::StoreOp can now disappear and Linalg can use standard types everywhere.
PiperOrigin-RevId:
272187165
Lei Zhang [Tue, 1 Oct 2019 10:27:44 +0000 (03:27 -0700)]
[spirv] NFC: rename SPV_ArithmeticOp to SPV_ArithmeticBinaryOp
Also rename SPV_UnaryArithmeticOp to SPV_ArithmeticUnaryOp to be
consistent.
PiperOrigin-RevId:
272173974
Christian Sigg [Tue, 1 Oct 2019 09:50:47 +0000 (02:50 -0700)]
Change all_reduce lowering to support 2D and 3D blocks.
Perform second reduce only with first warp. This requires an additional __sync_threads(), but doesn't need special handling when the last warp is small. This simplifies support for block sizes that are not multiple of 32.
Supporting partial warp reduce will be done in a separate CL.
PiperOrigin-RevId:
272168917
Christian Sigg [Tue, 1 Oct 2019 07:56:38 +0000 (00:56 -0700)]
Add verification error message for ops that require at least one operand or result.
PiperOrigin-RevId:
272153634
Christian Sigg [Tue, 1 Oct 2019 05:55:53 +0000 (22:55 -0700)]
Add integer shift ops to LLVM dialect.
PiperOrigin-RevId:
272140049
MLIR Team [Tue, 1 Oct 2019 01:43:58 +0000 (18:43 -0700)]
Fold away reduction over 0 dimensions.
PiperOrigin-RevId:
272113564
River Riddle [Tue, 1 Oct 2019 00:44:31 +0000 (17:44 -0700)]
Pass the pointer of the parent pipeline collection pass to PassInstrumentation::run*Pipeline.
For the cases where there are multiple levels of nested pass managers, the parent thread ID is not enough to distinguish the parent of a given pass pipeline. Passing in the parent pass gives an exact anchor point.
PiperOrigin-RevId:
272105461
MLIR Team [Mon, 30 Sep 2019 23:48:08 +0000 (16:48 -0700)]
Format markdown list.
PiperOrigin-RevId:
272095611
Denis Khalikov [Mon, 30 Sep 2019 23:42:46 +0000 (16:42 -0700)]
[spirv] Add array length check.
According to the SPIR-V spec:
"Length is the number of elements in the array. It must be at least 1."
Closes tensorflow/mlir#160
COPYBARA_INTEGRATE_REVIEW=https://github.com/tensorflow/mlir/pull/160 from denis0x0D:sandbox/array_len
0840dc0986ad0088a3aa7d5d8d3e97d489377ed9
PiperOrigin-RevId:
272094669
Ben Vanik [Mon, 30 Sep 2019 21:36:50 +0000 (14:36 -0700)]
Adding signed integer ops for abs, sign, min, and max in the GLSL extension.
PiperOrigin-RevId:
272067942
Jacques Pienaar [Mon, 30 Sep 2019 20:37:16 +0000 (13:37 -0700)]
Add missing file from cmakelist
PiperOrigin-RevId:
272054623
Jacques Pienaar [Mon, 30 Sep 2019 19:42:31 +0000 (12:42 -0700)]
Enable autogenerating OpInterface method declarations
Add DeclareOpInterfaceFunctions to enable specifying whether OpInterfaceMethods
for an OpInterface should be generated automatically. This avoids needing to
declare the extra methods, while also allowing adding function declaration by way of trait/inheritance.
Most of this change is mechanical/extracting classes to be reusable.
PiperOrigin-RevId:
272042739
River Riddle [Mon, 30 Sep 2019 19:35:21 +0000 (12:35 -0700)]
NFC: Change `classof` on registered operations to use pointer comparison.
The current implementation always uses string comparison, but if the operation is registered the AbstractOperation instance can be used to provide faster pointer comparison.
PiperOrigin-RevId:
272041333
Ben Vanik [Mon, 30 Sep 2019 19:28:21 +0000 (12:28 -0700)]
Adding some missing SPIR-V core and GLSL extended ops.
PiperOrigin-RevId:
272039887
Nicolas Vasilache [Mon, 30 Sep 2019 18:58:14 +0000 (11:58 -0700)]
Normalize MemRefType lowering to LLVM as strided MemRef descriptor
This CL finishes the implementation of the lowering part of the [strided memref RFC](https://groups.google.com/a/tensorflow.org/forum/#!topic/mlir/MaL8m2nXuio).
Strided memrefs correspond conceptually to the following templated C++ struct:
```
template <typename Elem, size_t Rank>
struct {
Elem *ptr;
int64_t offset;
int64_t sizes[Rank];
int64_t strides[Rank];
};
```
The linearization procedure for address calculation for strided memrefs is the same as for linalg views:
`base_offset + SUM_i index_i * stride_i`.
The following CL will unify Linalg and Standard by removing !linalg.view in favor of strided memrefs.
PiperOrigin-RevId:
272033399
Lei Zhang [Mon, 30 Sep 2019 18:48:30 +0000 (11:48 -0700)]
[DRR] Explain result type deduction in doc
PiperOrigin-RevId:
272031467
Mahesh Ravishankar [Mon, 30 Sep 2019 17:40:07 +0000 (10:40 -0700)]
Add support for Logical Ops in SPIR-V dialect
Add operations corresponding to OpLogicalAnd, OpLogicalNot,
OpLogicalEqual, OpLogicalNotEqual and OpLogicalOr instructions in
SPIR-V dialect. This needs changes to class hierarchy in SPIR-V
TableGen files to split SPIRVLogicalOp into SPIRVLogicalUnaryOp and
SPIRVLogicalBinaryOp. All derived classes of SPIRVLogicalOp are
updated accordingly.
Update the spirv dialect generation script to
1) Allow specifying base class to use for instruction spec generation
and file name to generate the specification in separately.
2) Use the existing descriptions for operations.
3) Update define_inst.sh to also invoke define_opcode.sh to also
define the corresponding SPIR-V instruction opcode enum.
PiperOrigin-RevId:
272014876
Jacques Pienaar [Mon, 30 Sep 2019 16:36:26 +0000 (09:36 -0700)]
Use MaybeAlign when setting alignment
PiperOrigin-RevId:
272000548
Nicolas Vasilache [Mon, 30 Sep 2019 14:15:54 +0000 (07:15 -0700)]
Fix MemRefType::getStrides corner case
MemRefType::getStrides uses AffineExpr::walk which operates in post-order from the leaves. In order to compute strides properly, it needs to escape on terminal nodes and analyze binary ops only. This did not work for AffineExpr that consist of a single term (i.e. without a binary op).
This CL fixes the corner case and adds relevant tests.
PiperOrigin-RevId:
271975746
Christian Sigg [Mon, 30 Sep 2019 10:19:09 +0000 (03:19 -0700)]
Switch comments from GPU dialect terms to CUDA terms (NFC).
local workgroup -> block, subgroup -> warp, invocation -> thread.
PiperOrigin-RevId:
271946342
Jacques Pienaar [Mon, 30 Sep 2019 00:28:29 +0000 (17:28 -0700)]
Add InferTypeOpTrait & enable generating its member function definition
Use OpInterfaces to add an interface for ops defining a return type function.
This change does not use this trait in any meaningful way, I'll use it in a
follow up to generalize and unify some of the op type traits/constraints. Also,
currently the infer type function can only be manually specified in C++, that should rather be the fallback in future.
PiperOrigin-RevId:
271883746
Uday Bondhugula [Sun, 29 Sep 2019 22:53:24 +0000 (15:53 -0700)]
update Rationale.md - remove outdated info
- removing outdated/confusing info
- the affine dialect is missing documentation on
affine.load/affine.store; the references herein have to be updated
once that's updated.
Signed-off-by: Uday Bondhugula <uday@polymagelabs.com>
Closes tensorflow/mlir#159
COPYBARA_INTEGRATE_REVIEW=https://github.com/tensorflow/mlir/pull/159 from bondhugula:doc
86dd794f2d0d7fd097dde5764c62eb406ed4f910
PiperOrigin-RevId:
271876525
Roberto Rosmaninho [Sun, 29 Sep 2019 22:53:21 +0000 (15:53 -0700)]
Fix a typo in Toy Chapter 2 tutorial documentation
Closes tensorflow/mlir#155
COPYBARA_INTEGRATE_REVIEW=https://github.com/tensorflow/mlir/pull/155 from Robertorosmaninho:patch-1
232ac4e1253948c7f3150515e93abe50fcec2f96
PiperOrigin-RevId:
271876515
Uday Bondhugula [Sun, 29 Sep 2019 22:52:52 +0000 (15:52 -0700)]
Fix syntax of 'call' and 'splat' ops
- fix missing return value syntax on call / splat ops
- reflow cond_br / store op syntax
Closes tensorflow/mlir#161
COPYBARA_INTEGRATE_REVIEW=https://github.com/tensorflow/mlir/pull/161 from bondhugula:patch-1
2beb5bdcb387a5e7c52438985f79e2987d3b3ebe
PiperOrigin-RevId:
271876453
Jacques Pienaar [Sat, 28 Sep 2019 16:35:23 +0000 (09:35 -0700)]
Switch explicit create methods to match generated build's order
The generated build methods have result type before the arguments (operands and attributes, which are also now adjacent in the explicit create method). This also results in changing the create method's ordering to match most build method's ordering.
PiperOrigin-RevId:
271755054
Geoffrey Martin-Noble [Sat, 28 Sep 2019 00:34:56 +0000 (17:34 -0700)]
Tablegen helpers for accessing properties of shaped types
Tablegen's lack of functions continues to be annoying
PiperOrigin-RevId:
271680947
Yanan Cao [Fri, 27 Sep 2019 23:20:04 +0000 (16:20 -0700)]
Append a newline when dumping a Value.
This is more consistent with other dump methods. Otherwise successive Value dumps are concatenated in same line, hurting readability.
PiperOrigin-RevId:
271669846
Nicolas Vasilache [Fri, 27 Sep 2019 19:31:12 +0000 (12:31 -0700)]
Remove spurious debug spew in tests
PiperOrigin-RevId:
271624731
Nicolas Vasilache [Fri, 27 Sep 2019 19:02:09 +0000 (12:02 -0700)]
Add TODO to revisit coupling of CallOp to MemRefType lowering
PiperOrigin-RevId:
271619132
Uday Bondhugula [Fri, 27 Sep 2019 18:57:52 +0000 (11:57 -0700)]
NFC - clean up op accessor usage, std.load/store op verify, other stale info
- also remove stale terminology/references in docs
Signed-off-by: Uday Bondhugula <uday@polymagelabs.com>
Closes tensorflow/mlir#148
COPYBARA_INTEGRATE_REVIEW=https://github.com/tensorflow/mlir/pull/148 from bondhugula:cleanup
e846b641a3c2936e874138aff480a23cdbf66591
PiperOrigin-RevId:
271618279
Nicolas Vasilache [Fri, 27 Sep 2019 16:55:38 +0000 (09:55 -0700)]
Promote MemRefDescriptor to a pointer to struct when passing function boundaries in LLVMLowering.
The strided MemRef RFC discusses a normalized descriptor and interaction with library calls (https://groups.google.com/a/tensorflow.org/forum/#!topic/mlir/MaL8m2nXuio).
Lowering of nested LLVM structs as value types does not play nicely with externally compiled C/C++ functions due to ABI issues.
Solving the ABI problem generally is a very complex problem and most likely involves taking
a dependence on clang that we do not want atm.
A simple workaround is to pass pointers to memref descriptors at function boundaries, which this CL implement.
PiperOrigin-RevId:
271591708
Nicolas Vasilache [Fri, 27 Sep 2019 16:44:54 +0000 (09:44 -0700)]
Fix JitRunner.cpp Error creation pattern and reactivate tests.
linalg_integration_test.mlir and simple.mlir were temporarily disabled due to an OSS-only failure.
The issue is that, once created, an llvm::Error must be explicitly checked before it can be discarded or overwritten.
This CL fixes the issue and reenable the test.
PiperOrigin-RevId:
271589651
Denis Khalikov [Fri, 27 Sep 2019 14:46:40 +0000 (07:46 -0700)]
Fix Documentation OpDefinitions.md
Add missing semicolon for the builders example.
Closes tensorflow/mlir#150
COPYBARA_INTEGRATE_REVIEW=https://github.com/tensorflow/mlir/pull/150 from denis0x0D:sandbox/doc_fix
07e3680e678bf141a70af7747136e9fde7b4cc0a
PiperOrigin-RevId:
271568527
Kazuaki Ishizaki [Fri, 27 Sep 2019 14:44:52 +0000 (07:44 -0700)]
Fix missing links in the documentation
Closes tensorflow/mlir#149
COPYBARA_INTEGRATE_REVIEW=https://github.com/tensorflow/mlir/pull/149 from kiszk:missing_links_g3doc
5f98bc279649d54ea3dcf9fe0e17be6ad6d6cb8f
PiperOrigin-RevId:
271568274
Deven Desai [Fri, 27 Sep 2019 06:49:51 +0000 (23:49 -0700)]
[ROCm] Adding ROCDL Dialect.
This commit introduces the ROCDL Dialect (i.e. the ROCDL ops + the code to lower those ROCDL ops to LLWM intrinsics/functions). Think of ROCDL Dialect as analogous to the NVVM Dialect, but for AMD GPUs. This patch contains just the essentials needed to get a simple example up and running. We expect to make further additions to the ROCDL Dialect.
This is the first of 3 commits, the follow-up will be:
* add a pass that lowers GPU Dialect to ROCDL Dialect
* add a "mlir-rocm-runner" utility
Closes tensorflow/mlir#146
COPYBARA_INTEGRATE_REVIEW=https://github.com/tensorflow/mlir/pull/146 from deven-amd:deven-rocdl-dialect
e78e8005c75a78912631116c78dc844fcc4b0de9
PiperOrigin-RevId:
271511259
Jacques Pienaar [Thu, 26 Sep 2019 23:41:57 +0000 (16:41 -0700)]
Disable failing tests
PiperOrigin-RevId:
271460509
Jacques Pienaar [Thu, 26 Sep 2019 21:00:22 +0000 (14:00 -0700)]
Make result ops generated output deterministic
Sort the result ops reported in lexographical order.
PiperOrigin-RevId:
271426258
Nicolas Vasilache [Thu, 26 Sep 2019 15:43:58 +0000 (08:43 -0700)]
Decouple tiling from fusion in Linalg.
This CL modifies the linalg-fusion pass such that it does not tile anymore as part of the pass. Tiling is a separate concern that enables linalg fusion but should happen before.
This makes fusion more composable with other decisions.
In particular the fusion pass now becomes greedy and only applies the transformation on a best-effort basis.
This should also let fusion work in a multi-hop fashion with chains of producer/consumers.
Since the fusion pass does not perform tiling anymore, tests are rewritten to be in pretiled form and make the intent of the test clearer (albeit more verbose).
PiperOrigin-RevId:
271357741
Alex Zinenko [Thu, 26 Sep 2019 12:41:26 +0000 (05:41 -0700)]
Drop support for memrefs from JitRunner
The support for functions taking and returning memrefs of floats was introduced
in the first version of the runner, created before MLIR had reliable lowering
of allocation/deallocation to library calls. It forcibly runs MLIR
transformation convering affine, loop and standard dialects into the LLVM
dialect, unlike the other runner flows that accept the LLVM dialect directly.
Memref support leads to more complex layering and is generally fragile. Drop
it in favor of functions returning a scalar, or library-based function calls to
print memrefs and other data structures.
PiperOrigin-RevId:
271330839
Christian Sigg [Thu, 26 Sep 2019 07:17:13 +0000 (00:17 -0700)]
Add AllReduceOp to GPU dialect with lowering to NVVM.
The reduction operation is currently fixed to "add", and the scope is fixed to "workgroup".
The implementation is currently limited to sizes that are multiple 32 (warp size) and no larger than 1024.
PiperOrigin-RevId:
271290265
Lei Zhang [Thu, 26 Sep 2019 02:04:59 +0000 (19:04 -0700)]
Remove unused variables and methods to address compiler warnings
PiperOrigin-RevId:
271256784
Mahesh Ravishankar [Thu, 26 Sep 2019 02:01:18 +0000 (19:01 -0700)]
Add spv.Bitcast operation to SPIR-V dialect
Support the OpBitcast instruction of SPIR-V using the spv.Bitcast
operation. The semantics implemented in the dialect differ from the
SPIR-V spec in that the dialect does not allow conversion to/from
pointer types from/to non-pointer types.
PiperOrigin-RevId:
271255957
Jing Pu [Thu, 26 Sep 2019 01:33:09 +0000 (18:33 -0700)]
Change the return type of createPrintCFGGraphPass to match other passes.
PiperOrigin-RevId:
271252404
Lei Zhang [Wed, 25 Sep 2019 23:34:37 +0000 (16:34 -0700)]
[spirv] Add SPV_UnaryOp and spv.FNegate
This CL also moves common parsers and printers to the
same section in SPIRVOps.cpp.
PiperOrigin-RevId:
271233546
Kazuaki Ishizaki [Wed, 25 Sep 2019 18:57:13 +0000 (11:57 -0700)]
Minor spelling tweaks
Closes tensorflow/mlir#145
COPYBARA_INTEGRATE_REVIEW=https://github.com/tensorflow/mlir/pull/145 from kiszk:spelling_tweaks_g3doc
ae9140aab5b797441e880d43e557903585815e40
PiperOrigin-RevId:
271173907
Jacques Pienaar [Wed, 25 Sep 2019 18:23:15 +0000 (11:23 -0700)]
Emit function name being tested in TestMemRefStrideCalculation
Bring back CHECK-LABEL post
PiperOrigin-RevId:
271166428
Geoffrey Martin-Noble [Wed, 25 Sep 2019 17:16:39 +0000 (10:16 -0700)]
Add tablegen verification traits for comparing different properties
This allows things like comparing the rank of one operand to the size of another that specifies indices into it.
PiperOrigin-RevId:
271150439