summaryrefslogtreecommitdiffstats
path: root/mlir
Commit message (Collapse)AuthorAgeFilesLines
...
* [spirv] Add binary arithmetic operations.Denis Khalikov2019-07-304-16/+445
| | | | | | | | | Add binary operations such as: OpIAdd, OpFAdd, OpISub, OpFSub, OpIMul, OpFDiv, OpFRem, OpFMod. Closes tensorflow/mlir#54 PiperOrigin-RevId: 260734166
* Remove dead code.Jacques Pienaar2019-07-306-95/+0
| | | | PiperOrigin-RevId: 260585594
* RewriterGen: properly handle zero-result opsAlex Zinenko2019-07-303-3/+27
| | | | | | | | | RewriterGen was emitting invalid C++ code if the pattern required to create a zero-result operation due to the absence of a special case that would avoid generating a spurious comma. Handle this case. Also add rewriter tests for zero-argument operations. PiperOrigin-RevId: 260576998
* Fix SingleBlockImplicitTerminator traits to catch empty blocksMehdi Amini2019-07-303-4/+41
| | | | | | | | | | The code was written with the assumption that on failure an error would be issued by another verifier. However verification is stopping on the first failure which lead to an empty output. Instead we make sure an error is displayed. Also add tests in the test dialect for this trait. PiperOrigin-RevId: 260541290
* Simplify ODS for loop.if and loop.for traits (NFC)Mehdi Amini2019-07-301-2/+2
| | | | | | | There is a wrapper for SingleBlockImplicitTerminator in ODS, this is nicer to read than using `NativeOpTrait`. PiperOrigin-RevId: 260539473
* Enable (de)serialization support for spirv::AccessChainOpMahesh Ravishankar2019-07-303-13/+45
| | | | | | | | | | Automatic generation of spirv::AccessChainOp (de)serialization needs the (de)serialization emitters to handle argument specified as Variadic<...>. To handle this correctly, this argument can only be the last entry in the arguments list. Add a test to (de)serialize spirv::AccessChainOp PiperOrigin-RevId: 260532598
* Add a `HasParent` operation trait to enforce a specific parent on an ↵Mehdi Amini2019-07-307-5/+35
| | | | | | operation (NFC) PiperOrigin-RevId: 260532592
* [mlir-tblgen] Emit forward declarations for all the classes before the ↵Mehdi Amini2019-07-302-1/+11
| | | | | | | | definitions This allows classes to refer to each other in the ODS file, for instance for traits. PiperOrigin-RevId: 260532419
* Initialize union to avoid -Wmissing-field-initializers warning.Jacques Pienaar2019-07-271-2/+2
| | | | | | Reported by clang-6. PiperOrigin-RevId: 260311814
* Verify that affine.load/store/dma_start/dma_wait operands are valid ↵Andy Davis2019-07-272-7/+133
| | | | | | dimension or symbol identifiers. PiperOrigin-RevId: 260197567
* Automated rollback of commit 3708f53219aa2b201e82e7172c5064c1eb9d483bNicolas Vasilache2019-07-262-73/+9
| | | | PiperOrigin-RevId: 260136255
* Add sgemm specializations - NFCNicolas Vasilache2019-07-262-9/+73
| | | | | | | | | This CL adds a few specializations for sgemm. A minor change to alpha is made in cblas_interface.cpp to be compatible with actual BLAS calls. For now this is for internal testing purposes only. PiperOrigin-RevId: 260129027
* Support referencing a single value generated by a matched multi-result opLei Zhang2019-07-266-26/+57
| | | | | | | | It's quite common that we want to put further constraints on the matched multi-result op's specific results. This CL enables referencing symbols bound to source op with the `__N` syntax. PiperOrigin-RevId: 260122401
* Fix backward slice corner caseNicolas Vasilache2019-07-262-4/+22
| | | | | | | In the backward slice computation, BlockArgument coming from function arguments represent a natural boundary for the traversal and should not trigger llvm_unreachable. This CL also improves the error message and adds a relevant test. PiperOrigin-RevId: 260118630
* Fix linalg_matmul_impl interfacing with sgemmNicolas Vasilache2019-07-262-2/+2
| | | | | | This CL provides a fix that makes linal_matmul_impl compliant with the BLAS interface. Before this CL it would compute either C += A * B when called with cblas.cpp:cblas_sgemm implementation and C = A * B with other implementations. PiperOrigin-RevId: 260117367
* Use "standard" load and stores in LowerVectorTransfersNicolas Vasilache2019-07-263-6/+12
| | | | | | | Clipping creates non-affine memory accesses, use std_load and std_store instead of affine_load and affine_store. In the future we may also want a fill with the neutral element rather than clip, this would make the accesses affine if we wanted more analyses and transformations to happen post lowering to pointwise copies. PiperOrigin-RevId: 260110503
* Add API for bulk-setting attributes in an OperationStateKrzysztof Drewniak2019-07-251-0/+5
| | | | | | | | This API is needed for the TFLite flatbuffer importer as the importer constructs arrays of NamedAttributes based on the flatbuffer that need to be added to an operation. PiperOrigin-RevId: 260041403
* Automated rollback of commit fc194a4f22fe53f46729821d9c4a993fe200facfMehdi Amini2019-07-255-169/+13
| | | | PiperOrigin-RevId: 260037115
* [spirv] Add AccessChainOp operation.Denis Khalikov2019-07-254-1/+318
| | | | | | | | | AccessChainOp creates a pointer into a composite object that can be used with OpLoad and OpStore. Closes tensorflow/mlir#52 PiperOrigin-RevId: 260035676
* Use perfect forwarding for OpBuilder::create args (NFC)Mehdi Amini2019-07-251-2/+2
| | | | | | | This looks like an oversight, and it can be useful for building using non-copyable types. PiperOrigin-RevId: 260032944
* Genericize function-like printer and parser. NFCAlex Zinenko2019-07-253-177/+262
| | | | | | | | | | | | | Function-like operations are likely to have similar custom syntax, in particular they all need to print function signature with argument attributes. Transform function printer and parser so that they can be applied to any operation with the FunctionLike trait. Move them to the trait itself. To avoid large member functions in the class template, define a concrete base class for the trait and implement common functionality in it. This allows printer and parser to be implemented in a source file without templating. PiperOrigin-RevId: 260020893
* Add support for hexadecimal float literalsAlex Zinenko2019-07-255-13/+169
| | | | | | | | | | | | | MLIR does not have support for parsing special floating point values such as infinities and NaNs. If programmatically constructed, these values are printed as NaN and (+-)Inf and cannot be parsed back. Add parser support for hexadecimal literals in float attributes, following LLVM IR. The literal corresponds to the in-memory representation of the floating point value. IEEE 754 defines a range of possible values for NaNs, storing the bitwise representation allows MLIR to properly roundtrip NaNs with different bit values of significands. PiperOrigin-RevId: 260018802
* Add support for an analysis mode to DialectConversion.River Riddle2019-07-254-9/+124
| | | | | | | | This mode analyzes which operations are legalizable to the given target if a conversion were to be applied, i.e. no rewrites are ever performed even on success. This mode is useful for device partitioning or other utilities that may want to analyze the effect of conversion to different targets before performing it. The analysis method currently just fills a provided set with the operations that were found to be legalizable. This can be extended in the future to capture more information as necessary. PiperOrigin-RevId: 259987105
* Fix backward slice computation to iterate through known control flowNicolas Vasilache2019-07-253-4/+70
| | | | | | | | | This CL fixes an oversight with dealing with loops in slicing analysis. The forward slice computation properly propagates through loops but not the backward slice. Add relevant unit tests. PiperOrigin-RevId: 259903396
* Move GPU dialect to {lib,include/mlir}/DialectAlex Zinenko2019-07-2523-24/+24
| | | | | | | Per tacit agreement, individual dialects should now live in lib/Dialect/Name with headers in include/mlir/Dialect/Name and tests in test/Dialect/Name. PiperOrigin-RevId: 259896851
* NFC: Use ValueOfRange instead of T in Diagnostic::appendRange.River Riddle2019-07-241-1/+2
| | | | | | For iterator_range, T is often the name of another iterator type and not the the value of the range. PiperOrigin-RevId: 259843446
* Move SPIRV dialect tests under test/DialectAlex Zinenko2019-07-2411-0/+0
| | | | | | | This was overlooked when the dialect code was moved under {lib,include/mlir}/Dialect. NFC. PiperOrigin-RevId: 259801927
* Disable auto-generated builders for spv.moduleLei Zhang2019-07-241-0/+4
| | | | | | | We need to ensure the block inside the region is properly terminated; the auto-generated builders do not guarantee that. PiperOrigin-RevId: 259793777
* Cleanup slicing test.Nicolas Vasilache2019-07-242-194/+207
| | | | | | Remove hardcoded SSA names and make use of CHECK-LABEL directives. PiperOrigin-RevId: 259767803
* Enable multi-level Linalg fusionNicolas Vasilache2019-07-243-29/+79
| | | | | | | | This CL adds support for SubViewOp in the alias analysis to permit multiple Linalg fusion passes to compose. The debugging messages are also improved for better readability. The readability benefits came in handy when tracking this issue. A 2-level fusion test is added to capture the new behavior. PiperOrigin-RevId: 259720246
* Add a utility function to populate StdOp to SPIRV Conversion PatternsMahesh Ravishankar2019-07-232-2/+44
| | | | | | | | The function populateStdOpsToSPIRVPatterns appends the conversion patterns automatically generated from StdOpsToSPIRVConversion.td to a list of patterns PiperOrigin-RevId: 259677890
* Update cmake files.Jacques Pienaar2019-07-232-2/+2
| | | | | | | Use MLIR_MAIN_SRC_DIR that also works if MLIR is not checked out in projects directory & simplify dir for EDSC test. PiperOrigin-RevId: 259664306
* Add sitofp to the standard dialectMLIR Team2019-07-237-5/+81
| | | | | | Conversion from integers (window or input size, padding etc) to floating point is required to express many ML kernels, for example average pooling. PiperOrigin-RevId: 259575284
* Affine loop parallelism detection: conservatively handle unknown opsAlex Zinenko2019-07-234-5/+37
| | | | | | | | | | | | | | | | | The loop parallelism detection utility only collects the affine.load and affine.store operations appearing inside the loop to analyze the access patterns for the absence of dependences. However, any operation, including unregistered operations, can appear in a body of an affine loop. If such operation has side effects, the result of parallelism analysis is incorrect. Conservatively assume affine loops are not parallel in presence of operations other than affine.load, affine.store, affine.for, affine.terminator that may have side effects. This required to update the loop-fusion unit test that relies on parallelism analysis and was exercising loop fusion in presence of an unregistered operation. PiperOrigin-RevId: 259560935
* ODS: support UnitAttr in Operation definitionsAlex Zinenko2019-07-234-4/+45
| | | | | | | | | | | | | | | A recent commit introduced UnitAttr into the ODS but did not include the support for using UnitAttrs in operation definitions (only patterns were supported). Extend the ODS definition of UnitAttr to be usable in operation definition by providing a trivial builder and an accessor that returns "true" if the unit attribute is present since the attribute presence itself has meaning. Additionally, test that unit attributes are effectively rewritten in patterns in addition to the already available FileCheck tests of the generated rewriter code. PiperOrigin-RevId: 259560653
* Introduce LLVMFuncOpAlex Zinenko2019-07-236-231/+569
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Originally, MLIR only supported functions of the built-in FunctionType. On the conversion path to LLVM IR, we were creating MLIR functions that contained LLVM dialect operations and used LLVM IR types for everything expect top-level functions (e.g., a second-order function would have a FunctionType that consume or produces a wrapped LLVM function pointer type). With MLIR functions becoming operations, it is now possible to introduce non-built-in function operations. This will let us use conversion patterns for function conversion, simplify the MLIR-to-LLVM translation by removing the knowledge of the MLIR built-in function types, and provide stronger correctness verifications (e.g. LLVM functions only accept LLVM types). Furthermore, we can currently construct a situation where the same function is used with two different types: () -> () when its specified and called directly, and !llvm<"void ()"> when it's passed somewhere on called indirectly. Having a special function-op that is always of !llvm<"void ()"> type makes the function model and the llvm dialect type system more consistent. Introduce LLVMFuncOp to represent a function in the LLVM dialect. Unlike standard FuncOp, this function has an LLVMType wrapping an LLVM IR function type. Generalize the common behavior of function-defining operations (functions live in a symbol table of a module, contain a single region, are iterable as a list of blocks, and support argument attributes). This only defines the operation. Custom syntax, conversion and translation rules will be added in follow-ups. The operation name mentions LLVM explicitly to avoid confusion with standard FuncOp, especially in multiple files that use both `mlir` and `mlir::LLVM` namespaces. PiperOrigin-RevId: 259550940
* Allow std.constant to hold a boolean value.River Riddle2019-07-223-8/+14
| | | | | | This was an oversight in the original implementation, std.constant already supports IntegerAttr just not BoolAttr. PiperOrigin-RevId: 259467710
* Introduce parser library method to parse list of region argumentsUday Bondhugula2019-07-226-12/+104
| | | | | | | | | | | | | | | | | - introduce parseRegionArgumentList (similar to parseOperandList) to parse a list of region arguments with a delimiter - allows defining custom parse for op's with multiple/variadic number of region arguments - use this on the gpu.launch op (although the latter has a fixed number of region arguments) - add a test dialect op to test region argument list parsing (with the no delimiter case) Signed-off-by: Uday Bondhugula <uday@polymagelabs.com> Closes tensorflow/mlir#40 PiperOrigin-RevId: 259442536
* Emit an error for missing '[' when parsing an AffineMapOfSSAIds.River Riddle2019-07-222-1/+10
| | | | | | Fixes tensorflow/mlir#51 PiperOrigin-RevId: 259415034
* (De)serialize composite spv.constantLei Zhang2019-07-225-11/+424
| | | | | | | This CL covers the case of composite spv.constant. We encode/decode them into/from OpConstantComposite/OpConstantNull. PiperOrigin-RevId: 259394700
* NFC: Update the LoopToStd conversion patterns to use RewritePattern instead ↵River Riddle2019-07-221-35/+23
| | | | | | | | of ConversionPattern. These patterns don't require type changes so they don't need to be using ConversionPattern. PiperOrigin-RevId: 259393151
* NFC: Update usage of multi-threading flags.River Riddle2019-07-221-3/+3
| | | | | | The multi-threading flags have changed as the feature is on by default and not experimental. PiperOrigin-RevId: 259369313
* Update style/clang-format (NFC).Jacques Pienaar2019-07-228-80/+102
| | | | | | Update to be consistent & so that future save + clang-format workflows don't introduce extra changes. PiperOrigin-RevId: 259361174
* (De)serialize float scalar spv.constantLei Zhang2019-07-223-2/+104
| | | | | | This CL adds support for float scalar spv.constant in (de)serialization. PiperOrigin-RevId: 259311776
* (De)serialize bool and integer scalar spv.constantLei Zhang2019-07-225-41/+379
| | | | | | | | | | | | | | | | | | | | | SPIR-V has multiple constant instructions covering different constant types: * `OpConstantTrue` and `OpConstantFalse` for boolean constants * `OpConstant` for scalar constants * `OpConstantComposite` for composite constants * `OpConstantNull` for null constants * ... We model them all with a single spv.constant op for uniformity and friendliness to transformations. This does mean that when doing (de)serialization, we need to poke spv.constant's type to determine which SPIR-V binary instruction to use. This CL only covers the case of bool and integer spv.constant. The rest will follow. PiperOrigin-RevId: 259311698
* [spirv] NFC: adjust `encode*` function signatures in SerializerLei Zhang2019-07-222-29/+32
| | | | | | | | | * Let them return `LogicalResult` so we can chain them together with other functions returning `LogicalResult`. * Added "Into" as the suffix to the function name and made the `binary` as the first parameter so that it reads more naturally. PiperOrigin-RevId: 259311636
* ODS: introduce ParamNativeOpTraitAlex Zinenko2019-07-222-6/+19
| | | | | | | | | | | | In MLIR C++ implementation, certain OpTraits are parameterized by values or types using nested class templates. These traits correspond to trait identifiers of the form "OpTrait::TraitName<Parameters>::Impl". Such long names are arguably too verbose to be spelled out entirely as NativeOpTrait in ODS and obscure the fact of parameterization. Introduce ParamNativeOpTrait to generate such trait identifiers from the base name and the parameters directly in ODS. Exercise the functionality on the SingleBlockImplicitTerminator trait. PiperOrigin-RevId: 259308796
* [spirv] Remove one level of indirection: processOp to processOpImplLei Zhang2019-07-224-30/+25
| | | | | | | | | | | We already have two levels of controls in SPIRVBase.td: hasOpcode and autogenSerialization. The former controls whether to add an entry to the dispatch table, while the latter controls whether to autogenerate the op's (de)serialization method specialization. This is enough for our cases. Remove the indirection from processOp to processOpImpl to simplify the picture. PiperOrigin-RevId: 259308711
* Refactor LoopParametricTiling as a test pass - NFCNicolas Vasilache2019-07-226-155/+150
| | | | | | This CL moves LoopParametricTiling into test/lib as a pass for purely testing purposes. PiperOrigin-RevId: 259300264
* SingleBlockImplicitTerminator: report the wrong terminator op foundAlex Zinenko2019-07-222-3/+6
| | | | | | | | | | In the trait verifier of SingleBlockImplicitTerminator, report the name of the unexpected terminator op found in the end of the block in addition to the name of the expected terminator op. This may simplify debugging, especially in cases where the terminator is omitted for brevity and/or after a long series of conversions. PiperOrigin-RevId: 259287452
OpenPOWER on IntegriCloud