summaryrefslogtreecommitdiffstats
path: root/mlir/lib/Dialect
Commit message (Collapse)AuthorAgeFilesLines
...
* [spirv] Extend spv.array with LayoutinfoDenis Khalikov2019-08-164-20/+107
| | | | | | | | Extend spv.array with Layoutinfo to support (de)serialization. Closes tensorflow/mlir#80 PiperOrigin-RevId: 263795304
* Add BuiltIn EnumAttr to SPIR-V dialectMahesh Ravishankar2019-08-153-7/+50
| | | | | | | | | | Generate the EnumAttr to represent BuiltIns in SPIR-V dialect. The builtIn can be specified as a StringAttr with value being the name of the builtin. Extend Decoration (de)serialization to handle BuiltIns. Also fix an error in the SPIR-V dialect generator script. PiperOrigin-RevId: 263596624
* Refactor ElementsAttr::getValue and DenseElementsAttr::getSplatValue.River Riddle2019-08-141-22/+20
| | | | | | All 'getValue' variants now require that the index is valid, queryable via 'isValidIndex'. 'getSplatValue' now requires that the attribute is a proper splat. This allows for querying these methods on DenseElementAttr with all possible value types; e.g. float, int, APInt, etc. This also allows for removing unnecessary conversions to Attribute that really want the underlying value. PiperOrigin-RevId: 263437337
* Express ownership transfer in PassManager API through std::unique_ptr (NFC)Mehdi Amini2019-08-123-6/+7
| | | | | | | | | | | | | | Since raw pointers are always passed around for IR construct without implying any ownership transfer, it can be error prone to have implicit ownership transferred the same way. For example this code can seem harmless: Pass *pass = .... pm.addPass(pass); pm.addPass(pass); pm.run(module); PiperOrigin-RevId: 263053082
* Refactor DenseElementAttr::getValues methods to return full ranges for splats.River Riddle2019-08-111-3/+8
| | | | | | The current implementation only returns one element for the splat case, which often comes as a surprise; leading to subtle/confusing bugs. The new behavior will include an iterate over the full range of elements, as defined by the shaped type, by providing the splat value for each iterator index. PiperOrigin-RevId: 262756780
* NFC: Standardize the terminology used for parent ops/regions/etc.River Riddle2019-08-091-1/+1
| | | | | | There are currently several different terms used to refer to a parent IR unit in 'get' methods: getParent/getEnclosing/getContaining. This cl standardizes all of these methods to use 'getParent*'. PiperOrigin-RevId: 262680287
* NFC: Update usages of OwningRewritePatternList to pass by & instead of &&.River Riddle2019-08-093-4/+4
| | | | | | This will allow for reusing the same pattern list, which may be costly to continually reconstruct, on multiple invocations. PiperOrigin-RevId: 262664599
* Build SymbolTable upfront in ModuleOp verification.Mahesh Ravishankar2019-08-081-1/+2
| | | | | | | | Building the symbol table upfront from module op allows for O(1) lookup of the function while verifying duplicate EntryPointOp within the module. PiperOrigin-RevId: 262435697
* Add SymbolTable trait to spirv::ModuleOp.Mahesh Ravishankar2019-08-081-9/+4
| | | | | | | | Adding the SymbolTable trait allows looking up the name of the functions using the symbol table while verifying EntryPointOps instead of manually tracking the function names. PiperOrigin-RevId: 262431220
* NFC: Update FuncOp::addEntryBlock to return the newly inserted block.River Riddle2019-08-071-2/+1
| | | | | | The entry block is often used recently after insertion. This removes the need to perform an additional lookup in such cases. PiperOrigin-RevId: 262265671
* Initialize local variables for opcode to fix MSAN failuresLei Zhang2019-08-071-3/+3
| | | | PiperOrigin-RevId: 262225919
* NFC: Implement OwningRewritePatternList as a class instead of a using directive.River Riddle2019-08-055-9/+6
| | | | | | This allows for proper forward declaration, as opposed to leaking the internal implementation via a using directive. This also allows for all pattern building to go through 'insert' methods on the OwningRewritePatternList, replacing uses of 'push_back' and 'RewriteListBuilder'. PiperOrigin-RevId: 261816316
* Use SingleBlockImplicitTerminator trait for spv.moduleLei Zhang2019-08-051-8/+4
| | | | | | | | This trait provides the ensureTerminator() utility function and the checks to make sure a spv.module is indeed terminated with spv._module_end. PiperOrigin-RevId: 261664153
* [spirv] Add support for specialization constantLei Zhang2019-08-013-86/+144
| | | | | | | | This CL extends the existing spv.constant op to also support specialization constant by adding an extra unit attribute on it. PiperOrigin-RevId: 261194869
* [spirv] Add binary logical operations.Denis Khalikov2019-08-011-0/+23
| | | | | | | | | | | Add binary logical operations regarding to the spec section 3.32.15: OpIEqual, OpINotEqual, OpUGreaterThan, OpSGreaterThan, OpUGreaterThanEqual, OpSGreaterThanEqual, OpULessThan, OpSLessThan, OpULessThanEqual, OpSLessThanEqual. Closes tensorflow/mlir#61 PiperOrigin-RevId: 261181281
* Add support for (de)serialization of SPIR-V Op DecorationsMahesh Ravishankar2019-07-303-14/+104
| | | | | | | | | | | | All non-argument attributes specified for an operation are treated as decorations on the result value and (de)serialized using OpDecorate instruction. An error is generated if an attribute is not an argument, and the name doesn't correspond to a Decoration enum. Name of the attributes that represent decoerations are to be the snake-case-ified version of the Decoration name. Add utility methods to convert to snake-case and camel-case. PiperOrigin-RevId: 260792638
* Initial implementation to translate kernel fn in GPU Dialect to SPIR-V DialectMahesh Ravishankar2019-07-302-20/+51
| | | | | | | | | | | | | | | This CL adds an initial implementation for translation of kernel function in GPU Dialect (used with a gpu.launch_kernel) op to a spv.Module. The original function is translated into an entry function. Most of the heavy lifting is done by adding TypeConversion and other utility functions/classes that provide most of the functionality to translate from Standard Dialect to SPIR-V Dialect. These are intended to be reusable in implementation of different dialect conversion pipelines. Note : Some of the files for have been renamed to be consistent with the norm used by the other Conversion frameworks. PiperOrigin-RevId: 260759165
* [spirv] Add basic infrastructure for negative deserializer testsLei Zhang2019-07-305-99/+93
| | | | | | | | | | | | | We are relying on serializer to construct positive cases to drive the test for deserializer. This leaves negative cases untested. This CL adds a basic test fixture for covering the negative corner cases to enforce a more robust deserializer. Refactored common SPIR-V building methods out of serializer to share it with the deserialization test. PiperOrigin-RevId: 260742733
* [spirv] Add AccessChainOp operation.Denis Khalikov2019-07-251-0/+138
| | | | | | | | | AccessChainOp creates a pointer into a composite object that can be used with OpLoad and OpStore. Closes tensorflow/mlir#52 PiperOrigin-RevId: 260035676
* Move GPU dialect to {lib,include/mlir}/DialectAlex Zinenko2019-07-255-0/+604
| | | | | | | 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
* (De)serialize composite spv.constantLei Zhang2019-07-222-5/+382
| | | | | | | This CL covers the case of composite spv.constant. We encode/decode them into/from OpConstantComposite/OpConstantNull. PiperOrigin-RevId: 259394700
* (De)serialize float scalar spv.constantLei Zhang2019-07-222-2/+77
| | | | | | 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-222-34/+325
| | | | | | | | | | | | | | | | | | | | | 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-221-26/+29
| | | | | | | | | * 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
* [spirv] Remove one level of indirection: processOp to processOpImplLei Zhang2019-07-222-11/+2
| | | | | | | | | | | 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
* Add (de)serialization of EntryPointOp and ExecutionModeOpMahesh Ravishankar2019-07-202-38/+261
| | | | | | | | | Since the serialization of EntryPointOp contains the name of the function as well, the function serialization emits the function name using OpName instruction, which is used during deserialization to get the correct function name. PiperOrigin-RevId: 259158784
* [spirv] Avoid printing duplicate trailing typeLei Zhang2019-07-191-2/+4
| | | | | | | | | When printing the value attribute in spv.constant, OpAsmPrinter already attaches a trailing type. So we don't need to duplicate it again unless it's an array attribute, which does not have type by default but we use it for spirv::ArrayType. PiperOrigin-RevId: 258994197
* Replace bitwiseCast with llvm::bit_castLei Zhang2019-07-191-12/+5
| | | | PiperOrigin-RevId: 258986485
* Wrap op (de)serialization methods in anonymous namespaceLei Zhang2019-07-192-0/+4
| | | | | | | | | | | | It's a known bug that older GCC is not happy with method specialization in the enclosing (global) namespace: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=56480 This CL wraps the generated specialization methods in the anonymous namespace to make sure the specialization is in the same namespace as the class. PiperOrigin-RevId: 258983181
* Switch C++14 std::equal usage to for-loop.Jacques Pienaar2019-07-191-2/+6
| | | | | | Version of std::equal used required C++14, switching to for-loop for now. Just a direct change from std::equal to the equivalent using for loop. PiperOrigin-RevId: 258970366
* Make SPIR-V spv.EntryPoint and spv.ExecutionMode consistent with SPIR-V specMahesh Ravishankar2019-07-193-28/+6
| | | | | | | | | | | | | This CL changes the Op definition of spirv::EntryPointOp and spirv::ExecutionModeOp to be consistent with the SPIR-V spec. 1) The EntryPointOp doesn't return a value 2) The ExecutionModeOp takes as argument, the SymbolRefAttr to refer to the function, instead of the result of the EntryPointOp. Following this, the spirv::EntryPointType is no longer necessary, and is removed. PiperOrigin-RevId: 258964027
* Generalize implicit terminator into an OpTraitAlex Zinenko2019-07-191-32/+6
| | | | | | | | | | | | | Several groups of operations in different dialects (e.g. AffineForOp, AffineIfOp; loop::ForOp, loop::IfOp) share the requirement for their regions to contain 0 or 1 block, and for blocks to always have a specific terminator type. Furthermore, this terminator may be omitted from the custom syntax. Generalize this behavior into OpTrait::SingleBlockImplicitTerminator, parameterized by the terminator operation type. This trait provides the verifier that checks the presence of the terminator, and utility functions adding the terminator in case of absence. PiperOrigin-RevId: 258957180
* [spirv] group methods better and improve commentsLei Zhang2019-07-192-253/+310
| | | | | | | | This CL groups (de)serialization methods logically and improves comments at various places. It also sorted method implementations to follow the order of their declarations. There is NFC. PiperOrigin-RevId: 258843490
* Add an "is_signed" attribute to the quant_ConstFakeQuant opFeng Liu2019-07-192-4/+10
| | | | | | | | | | | Some TensorFlow simulated quantize ops such as QuantizeAndDequantizeV2Op have attribute for the sign of the quantization, so quant_ConstFakeQuant should be able to represent it with the new attribute is added. The method for converting these attributes to an QuantizedType is updated to handle this new argument. PiperOrigin-RevId: 258810290
* Automatically generate (de)serialization methods for SPIR-V opsMahesh Ravishankar2019-07-193-38/+118
| | | | | | | | | | | | | | | | For ops in SPIR-V dialect that are a direct mirror of SPIR-V operations, the serialization/deserialization methods can be automatically generated from the Op specification. To enable this an 'autogenSerialization' field is added to SPV_Ops. When set to non-zero, this will enable the automatic (de)serialization function generation Also adding tests that verify the spv.Load, spv.Store and spv.Variable ops are serialized and deserialized correctly. To fully support these tests also add serialization and deserialization of float types and spv.ptr types PiperOrigin-RevId: 258684764
* Relax Broadcastable trait to only reject instances that are statically ↵Smit Hinsu2019-07-191-10/+36
| | | | | | | | | | | | incompatible Currently, Broadcastable trait also rejects instances when the op result has shape other than what can be statically inferred based on the operand shapes even if the result shape is compatible with the inferred broadcasted shape. For example, (tensor<3x2xi32>, tensor<*xi32>) -> tensor<4x3x2xi32> (tensor<2xi32>, tensor<2xi32>) -> tensor<*xi32> PiperOrigin-RevId: 258647493
* Move affine.for and affine.if to ODSNicolas Vasilache2019-07-161-1/+1
| | | | | | As the move to ODS is made, body and region names across affine and loop dialects are uniformized. PiperOrigin-RevId: 258416590
* Support signed and unsigned quantization typesFeng Liu2019-07-161-8/+13
| | | | | | | | This patch added a new argument to the fakeQuantAttrsToType utility method, so it can be used to convert min/max to quantized type with different signed storage types. PiperOrigin-RevId: 258382538
* Fix build by making LoopOps depend on StandardOpsAlex Zinenko2019-07-161-1/+1
| | | | | | LoopOps needs the definition ConstantIndexOp in the verifier of loop::ForOp. PiperOrigin-RevId: 258355329
* NFC: Move SPIR-V dialect to Dialect/ subdirectoryLei Zhang2019-07-1612-0/+2897
| | | | PiperOrigin-RevId: 258345603
* Extract std.for std.if and std.terminator in their own dialectNicolas Vasilache2019-07-164-0/+266
| | | | | | | These ops should not belong to the std dialect. This CL extracts them in their own dialect and updates the corresponding conversions and tests. PiperOrigin-RevId: 258123853
* NFC: Refactor Function to be value typed.River Riddle2019-07-013-4/+4
| | | | | | Move the data members out of Function and into a new impl storage class 'FunctionStorage'. This allows for Function to become value typed, which will greatly simplify the transition of Function to FuncOp(given that FuncOp is also value typed). PiperOrigin-RevId: 255983022
* Move the emitError/Warning/Remark utility methods out of MLIRContext and ↵River Riddle2019-06-254-16/+15
| | | | | | | | into the mlir namespace. Now that Locations are attributes, they have direct access to the MLIR context. This allows for simplifying error emission by removing unnecessary context lookups. PiperOrigin-RevId: 255112791
* Simplify usages of SplatElementsAttr now that it inherits from ↵River Riddle2019-06-192-39/+3
| | | | | | DenseElementsAttr. PiperOrigin-RevId: 253910543
* Refactor SplatElementsAttr to inherit from DenseElementsAttr as opposed to ↵River Riddle2019-06-191-2/+2
| | | | | | being a separate Attribute type. DenseElementsAttr provides a better internal representation for splat values as well as better API for accessing elements. PiperOrigin-RevId: 253138287
* Refactor DenseElementsAttr to support auto-splatting the dense data on ↵River Riddle2019-06-191-1/+1
| | | | | | construction. This essentially means that we always auto-detect splat data and only store the minimum amount of data necessary. Support for parsing dense splats, and removing SplatElementsAttr(now that it is redundant) will come in followup cls PiperOrigin-RevId: 252720561
* Add a templated wrapper around RewritePattern that allows for defining ↵River Riddle2019-06-013-78/+52
| | | | | | | | match/rewrite methods with an instance of the source op instead of a raw Operation*. -- PiperOrigin-RevId: 250003405
* Update the rewrite methods of each of the DialectConversion patterns to ↵River Riddle2019-05-201-1/+1
| | | | | | | | notify the PatternRewriter that the operation is being replaced. -- PiperOrigin-RevId: 248965082
* Allow for the case where ShapedType is a MemRef in fixed point math ↵Geoffrey Martin-Noble2019-05-201-4/+7
| | | | | | | | | | kernel utils MemRef may soon be a subclass of ShapedType. -- PiperOrigin-RevId: 248788950
* Rename VectorOrTensorType to ShapedTypeGeoffrey Martin-Noble2019-05-205-46/+45
| | | | | | | | | | | | This is in preparation for making it also support/be a parent class of MemRefType. MemRefs have similar shape/rank/element semantics and it would be useful to be able to use these same utilities for them. This CL should not change any semantics and only change variables, types, string literals, and comments. In follow-up CLs I will prepare all callers to handle MemRef types or remove their dependence on ShapedType. Discussion/Rationale in https://groups.google.com/a/tensorflow.org/forum/#!topic/mlir/cHLoyfGu8y8 -- PiperOrigin-RevId: 248476449
OpenPOWER on IntegriCloud