summaryrefslogtreecommitdiffstats
path: root/mlir/utils
Commit message (Collapse)AuthorAgeFilesLines
* [mlir][spirv] Update SPIR-V enums and ops with availability specLei Zhang2020-01-021-21/+149
| | | | | | | | | | This commit updates gen_spirv_dialect.py to query the grammar and generate availability spec for various enum attribute definitions and all defined ops. Reviewed By: mravishankar Differential Revision: https://reviews.llvm.org/D72095
* Fix the MLIR Vim syntax file: the keyword group was missingchelxom2019-12-261-3/+3
|
* Update SPIR-V.mdLei Zhang2019-12-231-14/+12
| | | | | | | | | This CL updates SPIR-V.md to reflect recent developments in the SPIR-V dialect and its conversions. Along the way, also updates the doc for define_inst.sh. PiperOrigin-RevId: 286933546
* Adjust License.txt file to use the LLVM licenseMehdi Amini2019-12-235-65/+15
| | | | PiperOrigin-RevId: 286906740
* Introduce prefetch op: affine -> std -> llvm intrinsicUday Bondhugula2019-12-181-0/+1
| | | | | | | | | | | | | | | | | | | Introduce affine.prefetch: op to prefetch using a multi-dimensional subscript on a memref; similar to affine.load but has no effect on semantics, but only on performance. Provide lowering through std.prefetch, llvm.prefetch and map to llvm's prefetch instrinsic. All attributes reflected through the lowering - locality hint, rw, and instr/data cache. affine.prefetch %0[%i, %j + 5], false, 3, true : memref<400x400xi32> Signed-off-by: Uday Bondhugula <uday@polymagelabs.com> Closes tensorflow/mlir#225 COPYBARA_INTEGRATE_REVIEW=https://github.com/tensorflow/mlir/pull/225 from bondhugula:prefetch 4c3b4e93bc64d9a5719504e6d6e1657818a2ead0 PiperOrigin-RevId: 286212997
* Add atomic operations to SPIR-V dialect.Mahesh Ravishankar2019-12-162-5/+6
| | | | | | | Some changes to the dialect generation script to allow specification of different base class to derive from in ODS. PiperOrigin-RevId: 285859230
* Drop Markdown style annotationsAlex Zinenko2019-12-101-1/+1
| | | | | | | These come from a non-standard extenion that is not available on Github, so it only clutters the documentation source with {.mlir} or {.ebnf} tags. PiperOrigin-RevId: 284733003
* NFC - update doc, comments, vim syntax fileUday Bondhugula2019-12-061-1/+9
| | | | | | | | | | | - for the symbol rules, the code was updated but the doc wasn't. Signed-off-by: Uday Bondhugula <uday@polymagelabs.com> Closes tensorflow/mlir#284 COPYBARA_INTEGRATE_REVIEW=https://github.com/tensorflow/mlir/pull/284 from bondhugula:doc 9aad8b8a715559f7ce61265f3da3f8a3c11b45ea PiperOrigin-RevId: 284283712
* [spirv] Add spv.SubgroupBallotKHROpLei Zhang2019-12-031-1/+5
| | | | PiperOrigin-RevId: 283522284
* [spirv] NFC: reorder sections in SPIRVBase.tdLei Zhang2019-12-021-1/+4
| | | | | | | Put extensions and capabilities at the very beginning because they will be referenced later by other definitions. PiperOrigin-RevId: 283416972
* De-duplicate EnumAttr overrides by defining defaultsLei Zhang2019-11-251-6/+0
| | | | | | | EnumAttr should provide meaningful defaults so concrete instances do not need to duplicate the fields. PiperOrigin-RevId: 282398431
* Fix gen_spirv_dialect.py regarding 1D/2D/3D Dim symbol nameLei Zhang2019-11-181-2/+12
| | | | PiperOrigin-RevId: 281131561
* Use simpler highlighting textmate syntaxJacques Pienaar2019-11-151-352/+73
| | | | | | | | | | | | Changes from: https://github-lightshow.herokuapp.com/?utf8=%E2%9C%93&scope=from-url&grammar_format=auto&grammar_url=https%3A%2F%2Fraw.githubusercontent.com%2Fjpienaar%2Fmlir-grammar%2Fmaster%2Fgrammars%2Fmlir.json&grammar_text=&code_source=from-url&code_url=https%3A%2F%2Fraw.githubusercontent.com%2Fjpienaar%2Fmlir-grammar%2Fmaster%2Fsample.mlir&code= To: https://github-lightshow.herokuapp.com/?utf8=%E2%9C%93&scope=from-url&grammar_format=auto&grammar_url=https%3A%2F%2Fraw.githubusercontent.com%2Fjpienaar%2Fmlir-grammar%2Fsimpler%2Fgrammars%2Fmlir.json&grammar_text=&code_source=from-url&code_url=https%3A%2F%2Fraw.githubusercontent.com%2Fjpienaar%2Fmlir-grammar%2Fmaster%2Fsample.mlir&code= Which I think is an improvement. PiperOrigin-RevId: 280674770
* Update textmate syntax fileJacques Pienaar2019-11-121-3/+8
| | | | | | Allow comments in more places and fix function params. PiperOrigin-RevId: 279986797
* [spirv] Add cast operationsDenis Khalikov2019-10-301-2/+2
| | | | | | | | | | | | | | | | | | | This CL added op definitions for a few cast operations: * OpConvertFToU * OpConvertFToS * OpConvertSToF * OpConvertUToF * OpUConvert * OpSConvert * OpFConvert Also moved the definition of spv.Bitcast to the new file. Closes tensorflow/mlir#208 and tensorflow/mlir#174 COPYBARA_INTEGRATE_REVIEW=https://github.com/tensorflow/mlir/pull/208 from denis0x0D:sandbox/cast_ops 79bc9b37398aafddee6cf6beb301807988fe67f9 PiperOrigin-RevId: 277587891
* [spirv] Fix gen_spirv_dialect.py and add spv.UnreachableLei Zhang2019-10-301-6/+48
| | | | | | | | | This CL fixed gen_spirv_dialect.py to support nested delimiters when chunking existing ODS entries in .td files and to allow ops without correspondence in the spec. This is needed to pull in the definition of OpUnreachable. PiperOrigin-RevId: 277486465
* Fix minor spelling tweaks (NFC)Kazuaki Ishizaki2019-10-202-3/+3
| | | | | | Closes tensorflow/mlir#175 PiperOrigin-RevId: 275726876
* Update the usage and comments in define_inst.sh.MLIR Team2019-10-091-3/+6
| | | | PiperOrigin-RevId: 273723108
* Add spv.Undef op to support OpUndef instruction in SPIR-V.Mahesh Ravishankar2019-10-041-3/+3
| | | | | | | | Adding support for OpUndef instruction. Updating the dialect generation script to fix a few bugs in the instruction spec generation. PiperOrigin-RevId: 272975685
* [spirv] Change enum case uniquing in gen_spirv_dialect.pyLei Zhang2019-10-011-16/+27
| | | | | | | | | | | | | | | 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
* Add support for Logical Ops in SPIR-V dialectMahesh Ravishankar2019-09-302-22/+49
| | | | | | | | | | | | | | | | | | 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
* [spirv] Add SPV_UnaryOp and spv.FNegateLei Zhang2019-09-251-3/+3
| | | | | | | This CL also moves common parsers and printers to the same section in SPIRVOps.cpp. PiperOrigin-RevId: 271233546
* Introduce splat op + provide its LLVM loweringUday Bondhugula2019-09-241-1/+1
| | | | | | | | | | | | | | | - introduce splat op in standard dialect (currently for int/float/index input type, output type can be vector or statically shaped tensor) - implement LLVM lowering (when result type is 1-d vector) - add constant folding hook for it - while on Ops.cpp, fix some stale names Signed-off-by: Uday Bondhugula <uday@polymagelabs.com> Closes tensorflow/mlir#141 COPYBARA_INTEGRATE_REVIEW=https://github.com/tensorflow/mlir/pull/141 from bondhugula:splat 48976a6aa0a75be6d91187db6418de989e03eb51 PiperOrigin-RevId: 270965304
* Remove unused import and two import formsJacques Pienaar2019-09-191-3/+1
| | | | | | argparse was imported with both 'import' and 'import from' and string import was unused, PiperOrigin-RevId: 270164488
* Add a preprocess pass to remove sequences that are problematic with FileCheckRiver Riddle2019-09-171-0/+19
| | | | | | 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
* [spirv] Add support for BitEnumAttrLei Zhang2019-09-161-5/+9
| | | | | | | | | | | | | | | | | | | | 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
* Update SPIR-V symbols and use GLSL450 instead of VulkanKHRLei Zhang2019-09-131-1/+1
| | | | | | | | | | | | | | 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
* Add floating-point comparison operations to SPIR-V dialect.Mahesh Ravishankar2019-08-312-43/+92
| | | | | | | | | | | | | Use the existing SPV_LogicalOp specification to add the floating-point comparison operations (both ordered and unordered versions). To make it easier to import the op-definitions automatically modify the dialect generation script to update the different .td files based on whether the operation is an arithmetic op, logical op, etc. Also allow specification of multiple opcodes with define_inst.sh. Since this reuses the SPV_LogicalOp framework, no tests specific to the floating point comparison ops are added with this CL. PiperOrigin-RevId: 266561634
* update vim syntax fileUday Bondhugula2019-08-301-10/+22
| | | | | | | | | | | | - more highlighting: numbers, elemental types inside shaped types - add some more keywords Signed-off-by: Uday Bondhugula <uday@polymagelabs.com> Closes tensorflow/mlir#110 COPYBARA_INTEGRATE_REVIEW=https://github.com/tensorflow/mlir/pull/110 from bondhugula:vim 029777db0ecb95bfc6453c0869af1c233d84d521 PiperOrigin-RevId: 266487768
* Add spv.Branch and spv.BranchConditionalLei Zhang2019-08-301-2/+2
| | | | | | | | This CL just covers the op definition, its parsing, printing, and verification. (De)serialization is to be implemented in a subsequent CL. PiperOrigin-RevId: 266431077
* Add vim scripts for indent/syntaxUday Bondhugula2019-08-286-51/+192
| | | | | | | | | | | - some of it has been adapted from LLVM's vim utils Signed-off-by: Uday Bondhugula <uday@polymagelabs.com> Closes tensorflow/mlir#90 COPYBARA_INTEGRATE_REVIEW=https://github.com/tensorflow/mlir/pull/90 from bondhugula:vim 22b1c958818c4b09de0ec8e1d7a4893171a03dbf PiperOrigin-RevId: 266071752
* Add BuiltIn EnumAttr to SPIR-V dialectMahesh Ravishankar2019-08-151-1/+1
| | | | | | | | | | 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
* Add a utility script to auto-generate CHECK commands for mlir test cases.River Riddle2019-08-131-0/+201
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This script is a utility to add FileCheck patterns to an mlir file. The script will heuristically insert CHECK/CHECK-LABEL commands for each line within the file. By default this script will also try to insert string substitution blocks for all SSA value names. The script is designed to make adding checks to a test case fast, it is *not* designed to be authoritative about what constitutes a good test! Note: Some cases may not be handled well, e.g. operands to operations with regions, but this script is only intended to be a starting point. Example usage: $ generate-test-checks.py foo.mlir $ mlir-opt foo.mlir -transformation | generate-test-checks.py module { func @fold_extract_element(%arg0: index) -> (f32, f16, f16, i32) { %cst = constant 4.500000e+00 : f32 %cst_0 = constant -2.000000e+00 : f16 %cst_1 = constant 0.000000e+00 : f16 %c64_i32 = constant 64 : i32 return %cst, %cst_0, %cst_1, %c64_i32 : f32, f16, f16, i32 } } // CHECK-LABEL: func @fold_extract_element( // CHECK-SAME: [[VAL_0:%.*]]: index) -> (f32, f16, f16, i32) { // CHECK: [[VAL_1:%.*]] = constant 4.500000e+00 : f32 // CHECK: [[VAL_2:%.*]] = constant -2.000000e+00 : f16 // CHECK: [[VAL_3:%.*]] = constant 0.000000e+00 : f16 // CHECK: [[VAL_4:%.*]] = constant 64 : i32 // CHECK: return [[VAL_1]], [[VAL_2]], [[VAL_3]], [[VAL_4]] : f32, f16, f16, i32 // CHECK: } PiperOrigin-RevId: 263242983
* Add start of textmate language grammar.Jacques Pienaar2019-08-121-0/+387
| | | | | | | | | | | | | Basic* grammar to start of with, this doesn't handle custom ops and doesn't handle ops with regions. But useful enough to make reading the .mlir files easier. Followed the approach used for emacs & vim and placed in separate directory under utils. * I got a little bit carried away trying to handle attributes and tried to do some custom op printing handling, but finally abandoned it. Also first time writing a textmate grammar so I assume a lot can be improved :) PiperOrigin-RevId: 262985490
* Add support for (de)serialization of SPIR-V Op DecorationsMahesh Ravishankar2019-07-301-0/+23
| | | | | | | | | | | | 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
* Fix script relative path after moving SPIR-V dialectLei Zhang2019-07-193-3/+3
| | | | PiperOrigin-RevId: 258786729
* Add serialization and deserialization of FuncOps. To support this theMahesh Ravishankar2019-07-121-1/+0
| | | | | | | | | | | | following SPIRV Instructions serializaiton/deserialization are added as well OpFunction OpFunctionParameter OpFunctionEnd OpReturn PiperOrigin-RevId: 257869806
* [spirv] Add script to auto-generate SPIR-V op template from specLei Zhang2019-07-122-36/+403
| | | | | | | | | | | | | | | | | | | SPIR-V has a JSON grammar file that defines the syntax of SPIR-V instructions. However, its lacks fine-grained constraints on instruction operands; those information is only available as natural language sentences in the SPIR-V spec, which also contains the detailed documentation for each SPIR-V instruction. This CL pulls information from both the JSON grammar and HTML spec. It right now uses the former to deduce the arguments and results (with coarse-grained constraints) and the latter for documentation. In the future we can add the functionality to match certain natural language sentences for more fine-grained constraints, but right now the developer is expected to update the generated op definition. This should serve as a nice bootstrap step to save efforts. PiperOrigin-RevId: 257821205
* Update the gen_spirv_dialect.py script to add opcodes from the SPIR-VMahesh Ravishankar2019-07-122-2/+121
| | | | | | | | JSON spec into the SPIRBase.td file. This is done incrementally to only import those opcodes that are needed, through use of the script define_opcode.sh added. PiperOrigin-RevId: 257517343
* [spirv] Use I32EnumAttr for enum attributesLei Zhang2019-07-021-6/+8
| | | | | | | | | | | | This saves us the excessive string conversions and comparisons in verification and transformation and scopes them only to parsing and printing, which are meant for I/O so string conversions should be fine. In order to do this, changed the custom assembly format of spv.module regarding addressing model and memory model. PiperOrigin-RevId: 256149856
* [spirv] Add SPV_StorageClassAttr and PointerTypeLei Zhang2019-06-191-1/+1
| | | | | | | | | Pointer types need to specify the storage class. We use the utility functions generated from SPV_StorageClassAttr to parse and print the storage classes. Also improved the case that no element type is provided for (runtime) array. PiperOrigin-RevId: 252935599
* [spirv] Add values for enum cases and generate the enum utilitiesLei Zhang2019-06-111-5/+12
| | | | PiperOrigin-RevId: 252494957
* [spirv] NFC: use two spaces for indentation in gen_spirv_dialect.pyLei Zhang2019-06-111-87/+87
| | | | PiperOrigin-RevId: 252469663
* [spirv] Add a script to update SPIRVBase.td with new enum attributesLei Zhang2019-06-012-0/+209
| | | | | | | | | | | | This script parses the SPIR-V JSON grammar to extract operand kinds that are enums and generate TableGen definitions for them. Also added a shell script to point to the correct relative file location to simplify command invocation. -- PiperOrigin-RevId: 251041084
* Update header notices.Jacques Pienaar2019-03-292-2/+27
| | | | PiperOrigin-RevId: 240457737
* Automated rollback of changelist 232728977.Uday Bondhugula2019-03-292-2/+2
| | | | PiperOrigin-RevId: 232944889
* Automated rollback of changelist 232717775.Uday Bondhugula2019-03-292-3/+3
| | | | PiperOrigin-RevId: 232807986
* Rename the 'if' operation in the AffineOps dialect to 'affine.if' and namespaceRiver Riddle2019-03-292-2/+2
| | | | | | the AffineOps dialect with 'affine'. PiperOrigin-RevId: 232728977
* NFC: Rename the 'for' operation in the AffineOps dialect to 'affine.for'. ↵River Riddle2019-03-292-3/+3
| | | | | | The is the second step to adding a namespace to the AffineOps dialect. PiperOrigin-RevId: 232717775
* NFC: Rename affine_apply to affine.apply. This is the first step to adding a ↵River Riddle2019-03-291-1/+1
| | | | | | namespace to the affine dialect. PiperOrigin-RevId: 232707862
OpenPOWER on IntegriCloud