Commit Graph

2624 Commits

Author SHA1 Message Date
Uday Bondhugula 1366467a3b 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
2019-09-14 13:21:35 -07:00
Uday Bondhugula 018cfa94d9 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
2019-09-14 12:10:55 -07:00
River Riddle 2de18fb84d NFC: Fix stray character in error message: 1 -> '
PiperOrigin-RevId: 269091468
2019-09-14 09:44:23 -07:00
Lei Zhang aac8fa8c47 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
2019-09-14 08:37:38 -07:00
Uday Bondhugula f2eb0f02fa 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
2019-09-13 22:11:56 -07:00
River Riddle 4e48beadbb Verify that ModuleOps only contain dialect specific attributes.
ModuleOp has no expected operations, so only dialect-specific attributes are valid.

PiperOrigin-RevId: 269020062
2019-09-13 18:19:33 -07:00
Uday Bondhugula 1e6a93b7ca 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
2019-09-13 18:18:48 -07:00
River Riddle d780bdef20 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
2019-09-13 17:54:00 -07:00
Geoffrey Martin-Noble efbd3e4610 Add type constraints for shaped types with same rank and element count
PiperOrigin-RevId: 269000237
2019-09-13 16:05:38 -07:00
Lei Zhang 113aadddf9 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
2019-09-13 15:26:32 -07:00
River Riddle f1b100c77b NFC: Finish replacing FunctionPassBase/ModulePassBase with OpPassBase.
These directives were temporary during the generalization of FunctionPass/ModulePass to OpPass.

PiperOrigin-RevId: 268970259
2019-09-13 13:34:27 -07:00
Geoffrey Martin-Noble a260436714 Add tablegen class for memrefs with rank constraints
PiperOrigin-RevId: 268968004
2019-09-13 13:22:21 -07:00
River Riddle 8a1cdeb31b 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
2019-09-13 13:19:19 -07:00
MLIR Team d3787e5865 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
2019-09-13 12:46:34 -07:00
River Riddle 9274ed66ef 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
2019-09-13 12:10:31 -07:00
Geoffrey Martin-Noble 70653ed600 NFC: Update comments about rank constraints
These refer to ranked tensors, but are actually applicable to any shaped type

PiperOrigin-RevId: 268931789
2019-09-13 10:29:18 -07:00
MLIR Team 6cce275301 Fixing typo in documentation.
PiperOrigin-RevId: 268877189
2019-09-13 04:08:12 -07:00
Smit Hinsu 1854c64c7c Log name of the generated illegal operation name in DialectConversion debug mode
PiperOrigin-RevId: 268859399
2019-09-13 01:37:38 -07:00
Geoffrey Martin-Noble 2ccbb3f1ce Cmpf constant folding for nan and inf
PiperOrigin-RevId: 268783645
2019-09-12 15:43:59 -07:00
Geoffrey Martin-Noble f39a599e46 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
2019-09-12 15:30:58 -07:00
Lei Zhang a84bc68acc [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
2019-09-11 14:02:59 -07:00
Alex Zinenko e15356f8ed 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
2019-09-11 10:18:29 -07:00
Alex Zinenko 9037f28cb4 Fix typos in SDBMTest.cpp
PiperOrigin-RevId: 268443146
2019-09-11 06:11:36 -07:00
MLIR Team bc9b52f2ed Add logical groups to NVVM op definitions.
PiperOrigin-RevId: 268436116
2019-09-11 05:10:29 -07:00
MLIR Team 6f8321f06f Fix a typo in comments. The Inequality and Equality explanations were apparently reversed.
PiperOrigin-RevId: 268395163
2019-09-10 23:54:36 -07:00
MLIR Team d732aaf2cb Don't leak TargetMachine in ExecutionEngine::setupTargetTriple
PiperOrigin-RevId: 268361054
2019-09-10 19:03:21 -07:00
Lei Zhang ee8cbccacf 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
2019-09-10 17:48:24 -07:00
Feng Liu cf0a782339 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
2019-09-10 13:26:46 -07:00
Feng Liu c68d5467d6 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
2019-09-10 10:50:57 -07:00
Jacques Pienaar 277b6136ee Remove unused variable
PiperOrigin-RevId: 268173638
2019-09-10 01:31:17 -07:00
Jacques Pienaar a23f69a37b Remove redundant qualification
Address GCC error: extra qualification not allowed [-fpermissive]

PiperOrigin-RevId: 268133737
2019-09-09 19:50:53 -07:00
Jacques Pienaar af27f4c746 Avoid sign-compare warning
PiperOrigin-RevId: 268132321
2019-09-09 19:36:31 -07:00
Jacques Pienaar 2660623a88 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
2019-09-09 18:12:41 -07:00
Feng Liu f4ae4762bf 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
2019-09-09 15:42:37 -07:00
Feng Liu d3a6dbc0b8 [NFC] Rename ExpressedToUniformQuantizedType to ExpressedToQuantizedType
PiperOrigin-RevId: 268090906
2019-09-09 15:29:59 -07:00
Feng Liu 27d776fa6d 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
2019-09-09 14:57:59 -07:00
River Riddle 893c86fff7 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
2019-09-09 13:44:24 -07:00
MLIR Team 36508528c7 Overload LLVM::TerminatorOp::build() for empty operands list.
PiperOrigin-RevId: 268041584
2019-09-09 11:39:03 -07:00
MLIR Team 5e65dafbfa Add warpsize and laneid intrinsics to NVVM dialect.
PiperOrigin-RevId: 268041263
2019-09-09 11:38:03 -07:00
River Riddle e702875d16 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
2019-09-09 09:52:25 -07:00
Stephan Herhut 318ff019cf Addressing some late review comments on kernel inlining.
Just formatting and better lit tests, no functional change.

PiperOrigin-RevId: 267942907
2019-09-09 01:15:47 -07:00
Mehdi Amini 42b60d34fc 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
2019-09-08 23:40:12 -07:00
River Riddle 120509a6b2 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
2019-09-08 19:58:13 -07:00
Mehdi Amini cbb6f09ce8 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
2019-09-07 18:57:19 -07:00
Mehdi Amini 6443583bfd 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
2019-09-07 17:03:01 -07:00
Uday Bondhugula 713ab0dde7 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
2019-09-07 10:00:25 -07:00
Mehdi Amini 53bb528b19 Wrap debug dump in LLVM_DEBUG
PiperOrigin-RevId: 267774506
2019-09-07 08:53:52 -07:00
Lei Zhang 6e5d1b9d62 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
2019-09-07 05:26:07 -07:00
Mehdi Amini 06398f32f6 Fix typo in the documentation for tensor_cast (NFC)
PiperOrigin-RevId: 267650411
2019-09-06 12:30:47 -07:00
River Riddle b78410fd81 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
2019-09-06 11:44:19 -07:00