River Riddle [Thu, 19 Sep 2019 02:20:36 +0000 (19:20 -0700)]
NFC: Remove stray logging from ~Block().
PiperOrigin-RevId:
269941815
River Riddle [Thu, 19 Sep 2019 01:23:12 +0000 (18:23 -0700)]
Fix nested dominance relationship between parent results and child operations.
This modifies DominanceInfo::properlyDominates(Value *value, Operation *op) to return false if the value is defined by a parent operation of 'op'. This prevents using values defined by the parent operation from within any child regions.
PiperOrigin-RevId:
269934920
Uday Bondhugula [Wed, 18 Sep 2019 18:25:33 +0000 (11:25 -0700)]
Support symbolic operands for memref replacement; fix memrefNormalize
- allow symbols in index remapping provided for memref replacement
- fix memref normalize crash on cases with layout maps with symbols
Signed-off-by: Uday Bondhugula <uday@polymagelabs.com>
Reported by: Alex Zinenko
Closes tensorflow/mlir#139
COPYBARA_INTEGRATE_REVIEW=https://github.com/tensorflow/mlir/pull/139 from bondhugula:memref-rep-symbols
2f48c1fdb5d4c58915bbddbd9f07b18541819233
PiperOrigin-RevId:
269851182
MLIR Team [Wed, 18 Sep 2019 14:44:39 +0000 (07:44 -0700)]
Unify error messages to start with lower-case.
PiperOrigin-RevId:
269803466
Alex Zinenko [Wed, 18 Sep 2019 09:16:59 +0000 (02:16 -0700)]
SDBM: support sum expressions on the LHS of stripe expressions
Introduce support for applying the stripe operator to sum expressions, as in
(x + A) # B = x + A - (x + A) mod B.
This is required to represent a combination of tiling and padding in the SDBM
framework, and is a valid SDBM construct that was not originally supported.
PiperOrigin-RevId:
269758807
Alex Zinenko [Wed, 18 Sep 2019 09:08:19 +0000 (02:08 -0700)]
Simplify SDBM expressions more aggressively in operators and conversions
Extend SDBM simplification patterns to support more cases where the addition of
two expressions each involving one or two variables would result in a sum
expression that only contains one variable and thus remains in the SDBM domain.
This is made possible by the new canonical structure of SDBM where the constant
term appears once. This simplification will be necessary to support
round-tripping of stripe expressions containing constant terms on the LHS
through affine expressions.
PiperOrigin-RevId:
269757732
River Riddle [Wed, 18 Sep 2019 00:54:54 +0000 (17:54 -0700)]
Add support to OpAsmParser for parsing unknown keywords.
This is useful in several cases, for example a user may want to sugar the syntax of a string(as we do with custom operation syntax), or avoid many nested ifs for parsing a set of known keywords.
PiperOrigin-RevId:
269695451
Mahesh Ravishankar [Tue, 17 Sep 2019 22:21:20 +0000 (15:21 -0700)]
Add (de)serialization support for OpRuntimeArray.
Update the SPIR-V (de)serialization to handle RuntimeArrayType.
PiperOrigin-RevId:
269667196
Lei Zhang [Tue, 17 Sep 2019 21:47:55 +0000 (14:47 -0700)]
Register a -test-spirv-roundtrip hook to mlir-translate
This CL registers a new mlir-translate hook, -test-spirv-roundtrip,
for testing SPIR-V serialization and deserialization round-trip.
This CL also moves the existing -serialize-spirv and
-deserialize-spirv hooks to one source file.
PiperOrigin-RevId:
269659528
River Riddle [Tue, 17 Sep 2019 20:59:12 +0000 (13:59 -0700)]
Add a preprocess pass to remove sequences that are problematic with FileCheck
Add a preprocess phase to rewrite parts of the input line that may be problematic with filecheck. This change adds preprocessing to escape '[[' bracket sequences, as these are used by FileCheck for variables.
PiperOrigin-RevId:
269648490
Lei Zhang [Tue, 17 Sep 2019 20:03:48 +0000 (13:03 -0700)]
Support file-to-file translation in mlir-translate
Existing translations are either from MLIR or to MLIR. To support
cases like round-tripping some external format via MLIR, one must
chain two mlir-translate invocations together using pipes. This
can be problematic to support -split-input-file in mlir-translate
given that it won't work across pipes.
Motivated by the above, this CL adds another translation category
that allows file to file. This gives users more freedom.
PiperOrigin-RevId:
269636438
Lei Zhang [Tue, 17 Sep 2019 19:16:05 +0000 (12:16 -0700)]
Change MLIR translation functions signature
This CL changes translation functions to take MemoryBuffer
as input and raw_ostream as output. It is generally better to
avoid handling files directly in a library (unless the library
is specifically for file manipulation) and we can unify all
file handling to the mlir-translate binary itself.
PiperOrigin-RevId:
269625911
Uday Bondhugula [Tue, 17 Sep 2019 18:49:14 +0000 (11:49 -0700)]
Add rewrite pattern to compose maps into affine load/stores
- add canonicalization pattern to compose maps into affine loads/stores;
templatize the pattern and reuse it for affine.apply as well
- rename getIndices -> getMapOperands() (getIndices is confusing since
these are no longer the indices themselves but operands to the map
whose results are the indices). This also makes the accessor uniform
across affine.apply/load/store. Change arg names on the affine
load/store builder to avoid confusion. Drop an unused confusing build
method on AffineStoreOp.
- update incomplete doc comment for canonicalizeMapAndOperands (this was
missed from a previous update).
Addresses issue tensorflow/mlir#121
Signed-off-by: Uday Bondhugula <uday@polymagelabs.com>
Closes tensorflow/mlir#122
COPYBARA_INTEGRATE_REVIEW=https://github.com/tensorflow/mlir/pull/122 from bondhugula:compose-load-store
e71de1771e56a85c4282c10cb43f30cef0701c4f
PiperOrigin-RevId:
269619540
Mehdi Amini [Tue, 17 Sep 2019 07:38:28 +0000 (00:38 -0700)]
Add missing CMake dependency from libAnalysis to the Vector dialect
Fixes tensorflow/mlir#138
PiperOrigin-RevId:
269509668
Mahesh Ravishankar [Tue, 17 Sep 2019 00:11:50 +0000 (17:11 -0700)]
Autogenerate (de)serialization for Extended Instruction Sets
A generic mechanism for (de)serialization of extended instruction sets
is added with this CL. To facilitate this, a new class
"SPV_ExtendedInstSetOp" is added which is a base class for all
operations corresponding to extended instruction sets. The methods to
(de)serialization such ops as well as its dispatch is generated
automatically.
The behavior controlled by autogenSerialization and hasOpcode is also
slightly modified to enable this. They are now decoupled.
1) Setting hasOpcode=1 means the operation has a corresponding
opcode in SPIR-V binary format, and its dispatch for
(de)serialization is automatically generated.
2) Setting autogenSerialization=1 generates the function for
(de)serialization automatically.
So now it is possible to have hasOpcode=0 and autogenSerialization=1
(for example SPV_ExtendedInstSetOp).
Since the dispatch functions is also auto-generated, the input file
needs to contain all operations. To this effect, SPIRVGLSLOps.td is
included into SPIRVOps.td. This makes the previously added
SPIRVGLSLOps.h and SPIRVGLSLOps.cpp unnecessary, and are deleted.
The SPIRVUtilsGen.cpp is also changed to make better use of
formatv,making the code more readable.
PiperOrigin-RevId:
269456263
Denis Khalikov [Mon, 16 Sep 2019 22:39:16 +0000 (15:39 -0700)]
[spirv] Add support for function calls.
Add spv.FunctionCall operation and (de)serialization.
Closes tensorflow/mlir#137
COPYBARA_INTEGRATE_REVIEW=https://github.com/tensorflow/mlir/pull/137 from denis0x0D:sandbox/function_call_op
e2e6f07d21e7f23e8b44c7df8a8ab784f3356ce4
PiperOrigin-RevId:
269437167
River Riddle [Mon, 16 Sep 2019 17:37:48 +0000 (10:37 -0700)]
Add support for multi-level value mapping to DialectConversion.
When performing A->B->C conversion, an operation may still refer to an operand of A. This makes it necessary to unmap through multiple levels of replacement for a specific value.
PiperOrigin-RevId:
269367859
Lei Zhang [Mon, 16 Sep 2019 16:22:43 +0000 (09:22 -0700)]
[spirv] Add support for BitEnumAttr
Certain enum classes in SPIR-V, like function/loop control and memory
access, are bitmasks. This CL introduces a BitEnumAttr to properly
model this and drive auto-generation of verification code and utility
functions. We still store the attribute using an 32-bit IntegerAttr
for minimal memory footprint and easy (de)serialization. But utility
conversion functions are adjusted to inspect each bit and generate
"|"-concatenated strings for the bits; vice versa.
Each such enum class has a "None" case that means no bit is set. We
need special handling for "None". Because of this, the logic is not
general anymore. So right now the definition is placed in the SPIR-V
dialect. If later this turns out to be useful for other dialects,
then we can see how to properly adjust it and move to OpBase.td.
Added tests for SPV_MemoryAccess to check and demonstrate.
PiperOrigin-RevId:
269350620
Alex Zinenko [Mon, 16 Sep 2019 15:15:25 +0000 (08:15 -0700)]
Overhaul the SDBM expression kind hierarchy
Swap the allowed nesting of sum and diff expressions: now a diff expression can
contain a sum expression, but only on the left hand side. A difference of two
expressions sum must be canonicalized by grouping their constant terms in a
single expression. This change of sturcture became possible thanks to the
introduction of the "direct" super-kind. It is necessary to enable support of
sum expressions on the left hand side of the stripe expression.
SDBM expressions are now grouped into the following structure
- expression
- varying
- direct
- sum <- (term, constant)
- term
- symbol
- dimension
- stripe <- (term, constant)
- negation <- (direct)
- difference <- (direct, term)
- constant
The notation <- (...) denotes the types of subexpressions a compound
expression can combine.
PiperOrigin-RevId:
269337222
Alex Zinenko [Mon, 16 Sep 2019 15:08:22 +0000 (08:08 -0700)]
Introduce SDBMDirect expression into the SDBM expression hierarchy
Direct expressions are those that do not negate any of the variables they
involve. They include input expressions (dimensions and symbols), stripe and
sum expressions, and combinations of those. Reifying direct expressions as a
class is a precondition for enabling additions on the LHS of a stripe
expression.
PiperOrigin-RevId:
269336031
MLIR Team [Mon, 16 Sep 2019 14:45:13 +0000 (07:45 -0700)]
Unify how errors are emitted in LaunchFuncOp verification.
PiperOrigin-RevId:
269331869
MLIR Team [Mon, 16 Sep 2019 14:18:40 +0000 (07:18 -0700)]
Error out when kernel function is not found while translating GPU calls.
PiperOrigin-RevId:
269327909
Alex Zinenko [Mon, 16 Sep 2019 10:30:33 +0000 (03:30 -0700)]
Drop makePositionAttr and the like in favor of Builder::getI64ArrayAttr
The helper functions makePositionAttr() and positionAttr() were originally
introduced in the lowering-to-LLVM-dialect pass to construct integer array
attributes that are used for static positions in extract/insertelement.
Constructing an integer array attribute being fairly common, a utility function
Builder::getI64ArrayAttr was later introduced into the Builder API. Drop
makePositionAttr and similar homegrown functions and use that API instead.
PiperOrigin-RevId:
269295836
Mahesh Ravishankar [Mon, 16 Sep 2019 02:39:28 +0000 (19:39 -0700)]
Add mechanism to specify extended instruction sets in SPIR-V.
Add support for specifying extended instructions sets. The operations
in SPIR-V dialect are named as 'spv.<extension-name>.<op-name>'. Use
this mechanism to define a 'Exp' operation from GLSL(450)
instructions.
Later CLs will add support for (de)serialization of these operations,
and update the dialect generation scripts to auto-generate the
specification using the spec directly.
Additional changes:
Add a Type Constraint to OpBase.td to check for vector of specified
lengths. This is used to check that the vector type used in SPIR-V
dialect are of lengths 2, 3 or 4.
Update SPIRVBase.td to use this Type constraints for vectors.
PiperOrigin-RevId:
269234377
River Riddle [Sun, 15 Sep 2019 21:00:31 +0000 (14:00 -0700)]
Update the pass registration section and add a sub-section on the textual pipeline specification.
Now that the pass manager is generalized, and nested/arbritrary pipelines are possible, it is important to document how to specify these types of pipelines from the command line.
PiperOrigin-RevId:
269207681
Uday Bondhugula [Sun, 15 Sep 2019 16:05:54 +0000 (09:05 -0700)]
Fix typo in test/AffineOps/ops.mlir
Closes tensorflow/mlir#135
COPYBARA_INTEGRATE_REVIEW=https://github.com/tensorflow/mlir/pull/135 from bondhugula:patch-1
539a7f1b43d09ef539b2fd15875f8ac765600263
PiperOrigin-RevId:
269187507
River Riddle [Sun, 15 Sep 2019 05:10:00 +0000 (22:10 -0700)]
NFC: Update the PassInstrumentation section.
This section has grown stale as the pass infrastructure has been generalized.
PiperOrigin-RevId:
269140863
River Riddle [Sun, 15 Sep 2019 05:02:41 +0000 (22:02 -0700)]
NFC: Update the expected outputs of pass-timing.
The output of the pass timing instrumentation has been changed now that the pass hierarchy has been generalized.
PiperOrigin-RevId:
269140277
River Riddle [Sun, 15 Sep 2019 04:56:09 +0000 (21:56 -0700)]
Update the IRPrinter instrumentation to work on non function/module operations.
This is necessary now that the pass manager may work on different types of operations.
PiperOrigin-RevId:
269139669
River Riddle [Sun, 15 Sep 2019 00:44:10 +0000 (17:44 -0700)]
NFC: Pass PassInstrumentations by unique_ptr instead of raw pointer.
This makes the ownership model explicit, and removes potential user errors.
PiperOrigin-RevId:
269122834
River Riddle [Sun, 15 Sep 2019 00:37:03 +0000 (17:37 -0700)]
NFC: Merge OpPass with OperationPass into just OperationPass.
OperationPass' are defined exactly the same way as they are now:
class DerivedPass : public OperationPass<DerivedPass>;
OpPass' are now defined as OperationPass, but with an additional template parameter for the operation type:
class DerivedPass : public OperationPass<DerivedPass, FuncOp>;
PiperOrigin-RevId:
269122410
Jing Pu [Sun, 15 Sep 2019 00:02:06 +0000 (17:02 -0700)]
Add convenience methods to create i8 and i16 attributes in Builder.
PiperOrigin-RevId:
269120226
Uday Bondhugula [Sat, 14 Sep 2019 20:23:18 +0000 (13:23 -0700)]
NFC - Move explicit copy/dma generation utility out of pass and into LoopUtils
- turn copy/dma generation method into a utility in LoopUtils, allowing
it to be reused elsewhere.
- no functional/logic change to the pass/utility
- trim down header includes in files affected
Signed-off-by: Uday Bondhugula <uday@polymagelabs.com>
Closes tensorflow/mlir#124
COPYBARA_INTEGRATE_REVIEW=https://github.com/tensorflow/mlir/pull/124 from bondhugula:datacopy
9f346e62e5bd9dd1986720a30a35f302eb4d3252
PiperOrigin-RevId:
269106088
Uday Bondhugula [Sat, 14 Sep 2019 20:21:00 +0000 (13:21 -0700)]
update normalizeMemRef utility; handle missing failure check + add more tests
- take care of symbolic operands with alloc
- add missing check for compose map failure and a test case
- add test cases on strides
- drop incorrect check for one-to-one'ness
Signed-off-by: Uday Bondhugula <uday@polymagelabs.com>
Closes tensorflow/mlir#132
COPYBARA_INTEGRATE_REVIEW=https://github.com/tensorflow/mlir/pull/132 from bondhugula:normalize-memrefs
8aebf285fb0d7c19269d85255aed644657e327b7
PiperOrigin-RevId:
269105947
Uday Bondhugula [Sat, 14 Sep 2019 19:10:18 +0000 (12:10 -0700)]
Clean up build trip count analysis method - avoid mutating IR
- NFC - on any pass/utility logic/output.
- Resolve TODO; the method building loop trip count maps was
creating and deleting affine.apply ops (transforming IR from under
analysis!, strictly speaking). Introduce AffineValueMap::difference to
do this correctly (without the need to create any IR).
- Move AffineApplyNormalizer out so that its methods are reusable from
AffineStructures.cpp; add a helper method 'normalize' to it. Fix
AffineApplyNormalize::renumberOneDim (Issue tensorflow/mlir#89).
- Trim includes on files touched.
- add test case on a scenario previously not covered
Signed-off-by: Uday Bondhugula <uday@polymagelabs.com>
Closes tensorflow/mlir#133
COPYBARA_INTEGRATE_REVIEW=https://github.com/tensorflow/mlir/pull/133 from bondhugula:trip-count-build
7fc34d857f7788f98b641792cafad6f5bd50e47b
PiperOrigin-RevId:
269101118
River Riddle [Sat, 14 Sep 2019 16:43:55 +0000 (09:43 -0700)]
NFC: Fix stray character in error message: 1 -> '
PiperOrigin-RevId:
269091468
Lei Zhang [Sat, 14 Sep 2019 15:36:53 +0000 (08:36 -0700)]
Update QuickstartRewrites.md regarding op definition and rewrites
This CL updates the doc with recent changes. It also adds a section
on registering and using the auto-generated patterns.
PiperOrigin-RevId:
269086830
Uday Bondhugula [Sat, 14 Sep 2019 05:11:23 +0000 (22:11 -0700)]
Add pattern to canonicalize for loop bounds
- add pattern to canonicalize affine.for loop bounds (using
canonicalizeMapAndOperands)
- rename AffineForLoopBoundFolder -> AffineForLoopBoundFolder for
consistency
Signed-off-by: Uday Bondhugula <uday@polymagelabs.com>
Closes tensorflow/mlir#111
COPYBARA_INTEGRATE_REVIEW=https://github.com/tensorflow/mlir/pull/111 from bondhugula:bound-canonicalize
ee8fb7f43a7ffd45f6df3f53c95098d8b7e494c7
PiperOrigin-RevId:
269041220
River Riddle [Sat, 14 Sep 2019 01:18:22 +0000 (18:18 -0700)]
Verify that ModuleOps only contain dialect specific attributes.
ModuleOp has no expected operations, so only dialect-specific attributes are valid.
PiperOrigin-RevId:
269020062
Uday Bondhugula [Sat, 14 Sep 2019 01:18:21 +0000 (18:18 -0700)]
add missing memref cast fold pattern for dim op
- add missing canonicalization pattern to fold memref_cast + dim to
dim (needed to propagate constant when folding a dynamic shape to
a static one)
- also fix an outdated/inconsistent comment in StandardOps/Ops.td
Signed-off-by: Uday Bondhugula <uday@polymagelabs.com>
Closes tensorflow/mlir#126
COPYBARA_INTEGRATE_REVIEW=https://github.com/tensorflow/mlir/pull/126 from bondhugula:quickfix
4566e75e49685c532faffff91d64c5d83d4da524
PiperOrigin-RevId:
269020058
River Riddle [Sat, 14 Sep 2019 00:53:28 +0000 (17:53 -0700)]
Publicly expose the functionality to parse a textual pass pipeline.
This allows for users other than those on the command line to apply a textual description of a pipeline to a given pass manager.
PiperOrigin-RevId:
269017028
Geoffrey Martin-Noble [Fri, 13 Sep 2019 23:05:06 +0000 (16:05 -0700)]
Add type constraints for shaped types with same rank and element count
PiperOrigin-RevId:
269000237
Lei Zhang [Fri, 13 Sep 2019 22:25:56 +0000 (15:25 -0700)]
Update SPIR-V symbols and use GLSL450 instead of VulkanKHR
SPIR-V recently publishes v1.5, which brings a bunch of symbols
into core. So the suffix "KHR"/"EXT"/etc. is removed from the
symbols. We use a script to pull information from the spec
directly.
Also changed conversion and tests to use GLSL450 instead of
VulkanKHR memory model. GLSL450 is still the main memory model
supported by Vulkan shaders and it does not require extra
capability to enable.
PiperOrigin-RevId:
268992661
River Riddle [Fri, 13 Sep 2019 20:33:46 +0000 (13:33 -0700)]
NFC: Finish replacing FunctionPassBase/ModulePassBase with OpPassBase.
These directives were temporary during the generalization of FunctionPass/ModulePass to OpPass.
PiperOrigin-RevId:
268970259
Geoffrey Martin-Noble [Fri, 13 Sep 2019 20:21:57 +0000 (13:21 -0700)]
Add tablegen class for memrefs with rank constraints
PiperOrigin-RevId:
268968004
River Riddle [Fri, 13 Sep 2019 20:18:44 +0000 (13:18 -0700)]
Forward diagnostics from untracked threads in ParallelDiagnosticHandler.
This allows for the use of multiple ParallelDiagnosticHandlers without having them conflict with each other.
PiperOrigin-RevId:
268967407
MLIR Team [Fri, 13 Sep 2019 19:46:07 +0000 (12:46 -0700)]
Improve verifier error reporting on type mismatch (NFC)
Before this change, it only reports expected type but not exact type, so
it's hard to troubleshoot.
PiperOrigin-RevId:
268961078
River Riddle [Fri, 13 Sep 2019 19:09:50 +0000 (12:09 -0700)]
Refactor pass pipeline command line parsing to support explicit pipeline strings.
This allows for explicitly specifying the pipeline to add to the pass manager. This includes the nesting structure, as well as the passes/pipelines to run. A textual pipeline string is defined as a series of names, each of which may in itself recursively contain a nested pipeline description. A name is either the name of a registered pass, or pass pipeline, (e.g. "cse") or the name of an operation type (e.g. "func").
For example, the following pipeline:
$ mlir-opt foo.mlir -cse -canonicalize -lower-to-llvm
Could now be specified as:
$ mlir-opt foo.mlir -pass-pipeline='func(cse, canonicalize), lower-to-llvm'
This will allow for running pipelines on nested operations, like say spirv modules. This does not remove any of the current functionality, and in fact can be used in unison. The new option is available via 'pass-pipeline'.
PiperOrigin-RevId:
268954279
Geoffrey Martin-Noble [Fri, 13 Sep 2019 17:28:53 +0000 (10:28 -0700)]
NFC: Update comments about rank constraints
These refer to ranked tensors, but are actually applicable to any shaped type
PiperOrigin-RevId:
268931789
MLIR Team [Fri, 13 Sep 2019 11:07:33 +0000 (04:07 -0700)]
Fixing typo in documentation.
PiperOrigin-RevId:
268877189
Smit Hinsu [Fri, 13 Sep 2019 08:37:07 +0000 (01:37 -0700)]
Log name of the generated illegal operation name in DialectConversion debug mode
PiperOrigin-RevId:
268859399
Geoffrey Martin-Noble [Thu, 12 Sep 2019 22:43:26 +0000 (15:43 -0700)]
Cmpf constant folding for nan and inf
PiperOrigin-RevId:
268783645
Geoffrey Martin-Noble [Thu, 12 Sep 2019 22:29:59 +0000 (15:29 -0700)]
NFC: Clean up constant fold tests
Use variable captures to make constant folding tests less sensitive to printer/parser implementation details.
See guidelines at https://github.com/tensorflow/mlir/blob/master/g3doc/TestingGuide.md
PiperOrigin-RevId:
268780812
Lei Zhang [Wed, 11 Sep 2019 21:02:23 +0000 (14:02 -0700)]
[spirv] Add support for spv.loop (de)serialization
This CL adds support for serializing and deserializing spv.loop ops.
This adds support for spv.Branch and spv.BranchConditional op
(de)serialization, too, because they are needed for spv.loop.
PiperOrigin-RevId:
268536962
Alex Zinenko [Wed, 11 Sep 2019 17:18:01 +0000 (10:18 -0700)]
Rename SDBMPositiveExpr to SDBMTermExpr
This better reflects how this kind of expressions is used and avoids the
potential confusion since the expression can take negative values. Term
expressions comprise dimensions, symbols and stripe expressions. In an SDBM
domain, a stripe expression always corresponds to a variable, input or
temporary. This expression can appear anywhere an input variable can,
including on the LHS of other stripe expressions.
PiperOrigin-RevId:
268486066
Alex Zinenko [Wed, 11 Sep 2019 13:11:03 +0000 (06:11 -0700)]
Fix typos in SDBMTest.cpp
PiperOrigin-RevId:
268443146
MLIR Team [Wed, 11 Sep 2019 12:09:23 +0000 (05:09 -0700)]
Add logical groups to NVVM op definitions.
PiperOrigin-RevId:
268436116
MLIR Team [Wed, 11 Sep 2019 06:53:58 +0000 (23:53 -0700)]
Fix a typo in comments. The Inequality and Equality explanations were apparently reversed.
PiperOrigin-RevId:
268395163
MLIR Team [Wed, 11 Sep 2019 02:02:54 +0000 (19:02 -0700)]
Don't leak TargetMachine in ExecutionEngine::setupTargetTriple
PiperOrigin-RevId:
268361054
Lei Zhang [Wed, 11 Sep 2019 00:47:37 +0000 (17:47 -0700)]
Add folding rule for spv.CompositeExtract
If the composite is a constant, we can fold it away. This only
supports vector and array constants for now, given that struct
constant is not supported in spv.constant yet.
PiperOrigin-RevId:
268350340
Feng Liu [Tue, 10 Sep 2019 20:26:14 +0000 (13:26 -0700)]
Remove the constraint that min / max should stride zero
Since we apply nudging for the zero point to make sure the nudged zerop points
can be in the range of [qmin, qmax], the constraint that rmin / rmax should
stride zero isn't necessary.
This also matches the documentation of tensorflow's FakeQuantWithMinMaxArgs op,
where min and max don't need to stride zero:
https://www.tensorflow.org/api_docs/python/tf/quantization/fake_quant_with_min_max_args
PiperOrigin-RevId:
268296285
Feng Liu [Tue, 10 Sep 2019 17:50:16 +0000 (10:50 -0700)]
Convert ConstFakeQuantPerAxis to qcast and dcast pair
This is also to add the test to the fakeQuantAttrsToType for per-channel fake quant.
PiperOrigin-RevId:
268260032
Jacques Pienaar [Tue, 10 Sep 2019 08:30:34 +0000 (01:30 -0700)]
Remove unused variable
PiperOrigin-RevId:
268173638
Jacques Pienaar [Tue, 10 Sep 2019 02:50:19 +0000 (19:50 -0700)]
Remove redundant qualification
Address GCC error: extra qualification not allowed [-fpermissive]
PiperOrigin-RevId:
268133737
Jacques Pienaar [Tue, 10 Sep 2019 02:36:02 +0000 (19:36 -0700)]
Avoid sign-compare warning
PiperOrigin-RevId:
268132321
Jacques Pienaar [Tue, 10 Sep 2019 01:12:12 +0000 (18:12 -0700)]
Add pass generate per block in a function a GraphViz Dot graph with ops as nodes
* Add GraphTraits that treat a block as a graph, Operation* as node and use-relationship for edges;
- Just basic graph output;
* Add use iterator to iterate over all uses of an Operation;
* Add testing pass to generate op graph;
This does not support arbitrary operations other than function nor nested regions yet.
PiperOrigin-RevId:
268121782
Feng Liu [Mon, 9 Sep 2019 22:42:07 +0000 (15:42 -0700)]
Add quant.const_fake_quant_per_axis op
Comparing to the existing quant.const_fake_quant op, the min and max attributes
of this new op is for each channel of last dimension of the input.
PiperOrigin-RevId:
268093722
Feng Liu [Mon, 9 Sep 2019 22:29:30 +0000 (15:29 -0700)]
[NFC] Rename ExpressedToUniformQuantizedType to ExpressedToQuantizedType
PiperOrigin-RevId:
268090906
Feng Liu [Mon, 9 Sep 2019 21:57:29 +0000 (14:57 -0700)]
Convert per channel fake quant attributes to type
For per channel fake quant attributes, the returned type should be
UniformQuantizedPerAxisType. Currently, this method isn't under test because we
haven't added the quant_ConstFakeQuantPerAxis op and the convert method.
PiperOrigin-RevId:
268084017
River Riddle [Mon, 9 Sep 2019 20:43:51 +0000 (13:43 -0700)]
Explicitly declare the OpPassManager move constructor to avoid undefined errors.
Some compilers will try to auto-generate the destructor, instead of using the user provided destructor, when creating a default move constructor.
PiperOrigin-RevId:
268067367
MLIR Team [Mon, 9 Sep 2019 18:38:34 +0000 (11:38 -0700)]
Overload LLVM::TerminatorOp::build() for empty operands list.
PiperOrigin-RevId:
268041584
MLIR Team [Mon, 9 Sep 2019 18:37:05 +0000 (11:37 -0700)]
Add warpsize and laneid intrinsics to NVVM dialect.
PiperOrigin-RevId:
268041263
River Riddle [Mon, 9 Sep 2019 16:51:59 +0000 (09:51 -0700)]
Add support for coalescing adjacent nested pass pipelines.
This allows for parallelizing across pipelines of multiple operation types. AdaptorPasses can now hold pass managers for multiple operation types and will dispatch based upon the operation being operated on.
PiperOrigin-RevId:
268017344
Stephan Herhut [Mon, 9 Sep 2019 08:15:10 +0000 (01:15 -0700)]
Addressing some late review comments on kernel inlining.
Just formatting and better lit tests, no functional change.
PiperOrigin-RevId:
267942907
Mehdi Amini [Mon, 9 Sep 2019 06:39:34 +0000 (23:39 -0700)]
Add `parseGenericOperation()` to the OpAsmParser
This method parses an operation in its generic form, from the current parser
state. This is the symmetric of OpAsmPrinter::printGenericOp(). An immediate
use case is illustrated in the test dialect, where an operation wraps another
one in its region and makes use of a single-line pretty-print form.
PiperOrigin-RevId:
267930869
River Riddle [Mon, 9 Sep 2019 02:57:25 +0000 (19:57 -0700)]
Refactor PassTiming to support nested pipelines.
This is done via a new set of instrumentation hooks runBeforePipeline/runAfterPipeline, that signal the lifetime of a pass pipeline on a specific operation type. These hooks also provide the parent thread of the pipeline, allowing for accurate merging of timers running on different threads.
PiperOrigin-RevId:
267909193
Mehdi Amini [Sun, 8 Sep 2019 01:56:39 +0000 (18:56 -0700)]
Use "final" instead of marking method virtual in override (NFC)
This is the only example for overriding this interface in the repo, let's
try to make it right as it may be taken as a reference when implemented in
other dialects
PiperOrigin-RevId:
267811123
Mehdi Amini [Sun, 8 Sep 2019 00:02:07 +0000 (17:02 -0700)]
Refactor getUsedValuesDefinedAbove to expose a variant taking a callback (NFC)
This will allow clients to implement a different collection strategy on these
values, including collecting each uses within the region for example.
PiperOrigin-RevId:
267803978
Uday Bondhugula [Sat, 7 Sep 2019 16:59:47 +0000 (09:59 -0700)]
Set mlir-cpu-runner JIT codegen opt level correctly
- the JIT codegen was being run at the default -O0 level; instead,
propagate the opt level from the cmd line.
Signed-off-by: Uday Bondhugula <uday@polymagelabs.com>
Closes tensorflow/mlir#123
COPYBARA_INTEGRATE_REVIEW=https://github.com/tensorflow/mlir/pull/123 from bondhugula:jit-runner
3b055e47f94c9a48bf487f6400787478738cda02
PiperOrigin-RevId:
267778586
Mehdi Amini [Sat, 7 Sep 2019 15:53:24 +0000 (08:53 -0700)]
Wrap debug dump in LLVM_DEBUG
PiperOrigin-RevId:
267774506
Lei Zhang [Sat, 7 Sep 2019 12:25:39 +0000 (05:25 -0700)]
Add doc for declarative rewrite rules
This doc serves as a manual for table-driven declarative rewrite rules.
It lists all the details regarding supported mechanisms.
PiperOrigin-RevId:
267761702
Mehdi Amini [Fri, 6 Sep 2019 19:30:06 +0000 (12:30 -0700)]
Fix typo in the documentation for tensor_cast (NFC)
PiperOrigin-RevId:
267650411
River Riddle [Fri, 6 Sep 2019 18:43:35 +0000 (11:43 -0700)]
Restrict affine inlining to just Function operations.
The current restrictions on dim/symbols require a top-level symbol for the conservative case of a non-affine region. This should be relaxed in the future.
PiperOrigin-RevId:
267641838
Nagy Mostafa [Fri, 6 Sep 2019 18:02:31 +0000 (11:02 -0700)]
Add custom builder for AffineIfOp
Closes tensorflow/mlir#109
COPYBARA_INTEGRATE_REVIEW=https://github.com/tensorflow/mlir/pull/109 from nmostafa:nmostafa/AffineIfOp
7dbf2115f0092ffab26381ea8704aa05a0253971
PiperOrigin-RevId:
267633077
Nicolas Vasilache [Fri, 6 Sep 2019 15:30:54 +0000 (08:30 -0700)]
Simplify Linalg ABI integration with external function calls.
View descriptors are converted to *pointer to* LLVM struct to avoid ABI issues related to C struct packing. This creates unnecessary complexity and hampers unification with memrefs.
Instead, this CL makes view descriptors convert to LLVM struct (as it was originally) and promotes all structs to pointers right before calling an external function.
PiperOrigin-RevId:
267602693
Alex Zinenko [Fri, 6 Sep 2019 08:22:24 +0000 (01:22 -0700)]
Fix typos in Interfaces.md
PiperOrigin-RevId:
267548530
Uday Bondhugula [Fri, 6 Sep 2019 06:12:01 +0000 (23:12 -0700)]
Integer set + operands / affine if op canonicalization
- turn canonicalizeMapAndOperands into a template that works on both
sets and maps, and use it to introduce a utility to canonicalize an
affine integer set and its operands
- add pattern to canonicalize affine if op's.
- rename IntegerSet::getNumOperands -> IntegerSet::getNumInputs to be
consistent with AffineMap
- add missing accessors for IntegerSet
Doesn't need extensive testing since canonicalizeSetAndOperands just
reuses canonicalizeMapAndOperands' logic, and the latter is tested on
affine.apply map + operands; the new method works the same way on an
integer set + operands of an affine if op for example.
Signed-off-by: Uday Bondhugula <uday@polymagelabs.com>
Closes tensorflow/mlir#112
COPYBARA_INTEGRATE_REVIEW=https://github.com/tensorflow/mlir/pull/112 from bondhugula:set-canonicalize
eff72f23250b96fa7d9f5caff3877440f5de2cec
PiperOrigin-RevId:
267532876
River Riddle [Thu, 5 Sep 2019 22:19:55 +0000 (15:19 -0700)]
Add support for conservatively inlining Affine operations.
This commit defines an initial implementation of the DialectInlinerInterface for the AffineOps dialect. This change allows for affine operations to be inlined into any region that is not an affine region. Inlining into affine regions requires special handling for dimension/symbol identifiers that will be added in followups.
PiperOrigin-RevId:
267467078
Lei Zhang [Thu, 5 Sep 2019 19:45:08 +0000 (12:45 -0700)]
[spirv] Add spv.loop
SPIR-V can explicitly declare structured control-flow constructs using merge
instructions. These explicitly declare a header block before the control
flow diverges and a merge block where control flow subsequently converges.
These blocks delimit constructs that must nest, and can only be entered
and exited in structured ways.
Instead of having a `spv.LoopMerge` op to directly model loop merge
instruction for indicating the merge and continue target, we use regions
to delimit the boundary of the loop: the merge target is the next op
following the `spv.loop` op and the continue target is the block that
has a back-edge pointing to the entry block inside the `spv.loop`'s region.
This way it's easier to discover all blocks belonging to a construct and
it plays nicer with the MLIR system.
Updated the SPIR-V.md doc.
PiperOrigin-RevId:
267431010
River Riddle [Thu, 5 Sep 2019 19:23:45 +0000 (12:23 -0700)]
Add the initial inlining infrastructure.
This defines a set of initial utilities for inlining a region(or a FuncOp), and defines a simple inliner pass for testing purposes.
A new dialect interface is defined, DialectInlinerInterface, that allows for dialects to override hooks controlling inlining legality. The interface currently provides the following hooks, but these are just premilinary and should be changed/added to/modified as necessary:
* isLegalToInline
- Determine if a region can be inlined into one of this dialect, *or* if an operation of this dialect can be inlined into a given region.
* shouldAnalyzeRecursively
- Determine if an operation with regions should be analyzed recursively for legality. This allows for child operations to be closed off from the legality checks for operations like lambdas.
* handleTerminator
- Process a terminator that has been inlined.
This cl adds support for inlining StandardOps, but other dialects will be added in followups as necessary.
PiperOrigin-RevId:
267426759
Stephan Herhut [Thu, 5 Sep 2019 08:45:40 +0000 (01:45 -0700)]
Make GPU kernel outlining test independent of value names.
PiperOrigin-RevId:
267323604
Smit Hinsu [Thu, 5 Sep 2019 06:15:33 +0000 (23:15 -0700)]
Generalize I32ElementsAttr definition and introduce I64ElementsAttr
Also, fix constBuilderCall to return attribute of the storage class DenseIntElementsAttr
PiperOrigin-RevId:
267305813
Nicolas Vasilache [Thu, 5 Sep 2019 02:16:32 +0000 (19:16 -0700)]
Use transform function on llvm::Module in the ExecutionEngine
The refactoring of ExecutionEngine dropped the usage of the irTransform function used to pass -O3 and other options to LLVM. As a consequence, the proper optimizations do not kick in in LLMV-land.
This CL makes use of the transform function and allows producing avx512 instructions, on an internal example, when using:
`mlir-cpu-runner -dump-object-file=1 -object-filename=foo.o` combined with `objdump -D foo.o`.
Assembly produced resembles:
```
2b2e: 62 72 7d 48 18 04 0e vbroadcastss (%rsi,%rcx,1),%zmm8
2b35: 62 71 7c 48 28 ce vmovaps %zmm6,%zmm9
2b3b: 62 72 3d 48 a8 c9 vfmadd213ps %zmm1,%zmm8,%zmm9
2b41: 62 f1 7c 48 28 cf vmovaps %zmm7,%zmm1
2b47: 62 f2 3d 48 a8 c8 vfmadd213ps %zmm0,%zmm8,%zmm1
2b4d: 62 f2 7d 48 18 44 0e vbroadcastss 0x4(%rsi,%rcx,1),%zmm0
2b54: 01
2b55: 62 71 7c 48 28 c6 vmovaps %zmm6,%zmm8
2b5b: 62 72 7d 48 a8 c3 vfmadd213ps %zmm3,%zmm0,%zmm8
2b61: 62 f1 7c 48 28 df vmovaps %zmm7,%zmm3
2b67: 62 f2 7d 48 a8 da vfmadd213ps %zmm2,%zmm0,%zmm3
2b6d: 62 f2 7d 48 18 44 0e vbroadcastss 0x8(%rsi,%rcx,1),%zmm0
2b74: 02
2b75: 62 f2 7d 48 a8 f5 vfmadd213ps %zmm5,%zmm0,%zmm6
2b7b: 62 f2 7d 48 a8 fc vfmadd213ps %zmm4,%zmm0,%zmm7
```
etc.
Fixes tensorflow/mlir#120
PiperOrigin-RevId:
267281097
Rob Suderman [Thu, 5 Sep 2019 00:24:04 +0000 (17:24 -0700)]
Updated StructAttr to use the struct name for StorageType and ReturnType.
PiperOrigin-RevId:
267266687
MLIR Team [Wed, 4 Sep 2019 19:26:11 +0000 (12:26 -0700)]
Retain address space during MLIR > LLVM conversion.
PiperOrigin-RevId:
267206460
Alex Zinenko [Wed, 4 Sep 2019 15:37:39 +0000 (08:37 -0700)]
Move LLVMIR dialect tests from test/LLVMIR to test/Dialect and test/Conversion
This follows up on the recent restructuring that moved the dialects under
lib/Dialect and inter-dialect conversions to lib/Conversion. Originally, the
tests for both the LLVMIR dialect itself and the conversion from Standard to
LLVMIR dialect lived under test/LLVMIR. This no longer reflects the code
structure. Move the tests to either test/Dialect/LLVMIR or
test/Conversion/StandardToLLVM depending on the features they exercise.
PiperOrigin-RevId:
267159219
Jacques Pienaar [Wed, 4 Sep 2019 14:02:37 +0000 (07:02 -0700)]
Make isIsolatedAbove robuster to invalid IR
This function is only called from the verifier.
PiperOrigin-RevId:
267145495
Uday Bondhugula [Wed, 4 Sep 2019 13:58:39 +0000 (06:58 -0700)]
pipeline-data-transfer: remove dead tag alloc's and improve test coverage for replaceMemRefUsesWith / pipeline-data-transfer
- address remaining comments from PR tensorflow/mlir#87 for better test coverage for
pipeline-data-transfer/replaceAllMemRefUsesWith
- remove dead tag allocs the same way they are removed for the replaced buffers
Signed-off-by: Uday Bondhugula <uday@polymagelabs.com>
Closes tensorflow/mlir#106
COPYBARA_INTEGRATE_REVIEW=https://github.com/tensorflow/mlir/pull/106 from bondhugula:followup
9e868666d047e8d43e5f82f43e4093b838c710fa
PiperOrigin-RevId:
267144774
Alex Zinenko [Wed, 4 Sep 2019 13:32:54 +0000 (06:32 -0700)]
Move Linalg dialect tests to test/Dialect/Linalg
This was missing from the commit that moved the Linalg dialect to lib/Dialect.
PiperOrigin-RevId:
267141176
Stephan Herhut [Wed, 4 Sep 2019 13:15:40 +0000 (06:15 -0700)]
Make GPU kernel outlining inline constants.
It is generally beneficial to pass less arguments to a kernel, so cloning constants
into the kernel is beneficial.
PiperOrigin-RevId:
267139084