summaryrefslogtreecommitdiffstats
path: root/mlir/tools
Commit message (Collapse)AuthorAgeFilesLines
* [mlir] Mark the MLIR tools for installation in CMakeKern Handa2020-02-053-3/+3
| | | | | | | | This binplaces `mlir-translate`, `mlir-cuda-runner`, and `mlir-cpu-runner` when building the CMake install target. Differential Revision: https://reviews.llvm.org/D73986 (cherry picked from commit b8004b7308b490b93231789cd05f86294a77d663)
* Revert "[mlir] Create a gpu.module operation for the GPU Dialect."Benjamin Kramer2020-01-161-1/+1
| | | | | | | This reverts commit 4624a1e8ac8a3f69cc887403b976f538f587744a. Causing problems downstream. (cherry picked from commit 0133cc60e4e230ee2c176c23eff5aa2f4ee17a75)
* [mlir] Create a gpu.module operation for the GPU Dialect.Tres Popp2020-01-141-1/+1
| | | | | | | | | | | | | | | | | Summary: This is based on the use of code constantly checking for an attribute on a model and instead represents the distinct operaion with a different op. Instead, this op can be used to provide better filtering. Reviewers: herhut, mravishankar, antiagainst, rriddle Reviewed By: herhut, antiagainst, rriddle Subscribers: liufengdb, aartbik, jholewinski, mgorny, mehdi_amini, rriddle, jpienaar, burmako, shauheen, antiagainst, nicolasvasilache, csigg, arpith-jacob, mgester, lucyrfox, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D72336
* [mlir] NFC: Remove Value::operator* and Value::operator-> now that Value is ↵River Riddle2020-01-113-13/+13
| | | | | | | | | | properly value-typed. Summary: These were temporary methods used to simplify the transition. Reviewed By: antiagainst Differential Revision: https://reviews.llvm.org/D72548
* [mlir][ods] Support dialect specific content emission via hooksLei Zhang2020-01-101-1/+36
| | | | | | | | | | | | | Thus far we can only generate the same set of methods even for operations in different dialects. This is problematic for dialects that want to generate additional operation class methods programmatically, e.g., a special builder method or attribute getter method. Apparently we cannot update the OpDefinitionsGen backend every time when such a need arises. So this CL introduces a hook into the OpDefinitionsGen backend to allow dialects to emit additional methods and traits to operation classes. Differential Revision: https://reviews.llvm.org/D72514
* [mlir] NFC: put C++ code emission classes in their own filesLei Zhang2020-01-101-340/+5
| | | | | | This exposes thse classes so that they can be used in interfaces. Differential Revision: https://reviews.llvm.org/D72514
* [mlir] Compilation fix: use LLVM_ATTRIBUTE_UNUSED following ↵Alexandre Ganea2020-01-031-6/+2
| | | | | | 6656e961c08393c3949412ef945ade0272b66fca Differential Revision: https://reviews.llvm.org/D72124
* [mlir] Enhance classof() checks in StructsGenLei Zhang2020-01-031-3/+6
| | | | | | | | | | | Previously we only check that each field is of the correct mlir::Attribute subclass. This commit enhances to also consider the attribute's types, by leveraging the constraints already encoded in TableGen attribute definitions. Reviewed By: rsuderman Differential Revision: https://reviews.llvm.org/D72162
* [mlir] Only generate default for uncovered casesJacques Pienaar2020-01-021-0/+4
| | | | Have to explicitly check if all cases are covered instead.
* [mlir] Revert default case that was neededJacques Pienaar2020-01-021-0/+2
| | | | This one isn't always complete.
* [mlir] Remove redudant default casesJacques Pienaar2020-01-021-4/+0
| | | | These provide no value and trigger -Wcovered-switch-default.
* [mlir][Linalg] Extend generic ops to allow tensorsNicolas Vasilache2020-01-021-3/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: This diff adds support to allow `linalg.generic` and `linalg.indexed_generic` to take tensor input and output arguments. The subset of output tensor operand types must appear verbatim in the result types after an arrow. The parser, printer and verifier are extended to accomodate this behavior. The Linalg operations now support variadic ranked tensor return values. This extension exhibited issues with the current handling of NativeCall in RewriterGen.cpp. As a consequence, an explicit cast to `SmallVector<Value, 4>` is added in the proper place to support the new behavior (better suggestions are welcome). Relevant cleanups and name uniformization are applied. Relevant invalid and roundtrip test are added. Reviewers: mehdi_amini, rriddle, jpienaar, antiagainst, ftynse Subscribers: burmako, shauheen, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D72022
* [mlir][spirv] Allow specifying availability on enum attribute casesLei Zhang2020-01-021-12/+258
| | | | | | | | | | | | | | Lots of SPIR-V ops take enum attributes and certain enum cases need extra capabilities or extensions to be available. This commit extends to allow specifying availability spec on enum cases. Extra utility functions are generated for the corresponding enum classes to return the availability requirement. The availability interface implemention for a SPIR-V op now goes over all enum attributes to collect the availability requirements. Reviewed By: mravishankar Differential Revision: https://reviews.llvm.org/D71947
* [mlir] Fix -Wrange-loo-analysis warningsFangrui Song2020-01-011-1/+1
| | | | | | | | | | | | for (const auto &x : llvm::zip(..., ...)) -> for (auto x : llvm::zip(..., ...)) The return type of zip() is a wrapper that wraps a tuple of references. > warning: loop variable 'p' is always a copy because the range of type 'detail::zippy<detail::zip_shortest, ArrayRef<long> &, ArrayRef<long> &>' does not return a reference [-Wrange-loop-analysis]
* [mlir] Fix compilation warningsAlexandre Ganea2020-01-011-2/+5
| | | | | | Fixes: - (MSVC) F:\llvm-project\mlir\lib\Dialect\Linalg\Analysis\DependenceAnalysis.cpp(103): warning C4551: function call missing argument list - (Clang) tools\mlir\lib\Dialect\SPIRV\SPIRVCanonicalization.inc(232,1): warning: unused function 'populateWithGenerated' [-Wunused-function]
* [mlir][spirv] Add basic definitions for supporting availabilityLei Zhang2019-12-272-8/+321
| | | | | | | | | | | | | | | | | | | | | | | | SPIR-V has a few mechanisms to control op availability: version, extension, and capabilities. These mechanisms are considered as different availability classes. This commit introduces basic definitions for modelling SPIR-V availability classes. Specifically, an `Availability` class is added to SPIRVBase.td, along with two subclasses: MinVersion and MaxVersion for versioning. SPV_Op is extended to take a list of `Availability`. Each `Availability` instance carries information for generating op interfaces for the corresponding availability class and also the concrete availability requirements. With the availability spec on ops, we can now auto-generate the op interfaces of all SPIR-V availability classes and also synthesize the op's implementations of these interfaces. The interface generation is done via new TableGen backends -gen-avail-interface-{decls|defs}. The op's implementation is done via -gen-spirv-avail-impls. Differential Revision: https://reviews.llvm.org/D71930
* Add an __attribute__((unused)) to populateWithGenerated since it mightEric Christopher2019-12-261-1/+2
| | | | not be used where defined and is autogenerated.
* NFC: Replace ValuePtr with Value and remove it now that Value is value-typed.River Riddle2019-12-233-15/+15
| | | | | | ValuePtr was a temporary typedef during the transition to a value-typed Value. PiperOrigin-RevId: 286945714
* Adjust License.txt file to use the LLVM licenseMehdi Amini2019-12-2316-208/+64
| | | | PiperOrigin-RevId: 286906740
* NFC: Introduce new ValuePtr/ValueRef typedefs to simplify the transition to ↵River Riddle2019-12-223-24/+25
| | | | | | | | | | Value being value-typed. This is an initial step to refactoring the representation of OpResult as proposed in: https://groups.google.com/a/tensorflow.org/g/mlir/c/XXzzKhqqF_0/m/v6bKb08WCgAJ This change will make it much simpler to incrementally transition all of the existing code to use value-typed semantics. PiperOrigin-RevId: 286844725
* Add support for providing a default implementation for an interface method.River Riddle2019-12-181-0/+26
| | | | | | | | | | | | | | | | | | | | This enables providing a default implementation of an interface method. This method is defined on the Trait that is attached to the operation, and thus has all of the same constraints and properties as any other interface method. This allows for interface authors to provide a conservative default implementation for certain methods, without requiring that all users explicitly define it. The default implementation can be specified via the argument directly after the interface method body: StaticInterfaceMethod< /*desc=*/"Returns whether two array of types are compatible result types for an op.", /*retTy=*/"bool", /*methodName=*/"isCompatibleReturnTypes", /*args=*/(ins "ArrayRef<Type>":$lhs, "ArrayRef<Type>":$rhs), /*methodBody=*/[{ return ConcreteOp::isCompatibleReturnTypes(lhs, rhs); }], /*defaultImplementation=*/[{ /// Returns whether two arrays are equal as strongest check for /// compatibility by default. return lhs == rhs; }] PiperOrigin-RevId: 286226054
* Fix (de)serialization generation for SPV_ScopeAttr, SPV_MemorySemanticsAttr.Mahesh Ravishankar2019-12-161-2/+14
| | | | | | | | Scope and Memory Semantics attributes need to be serialized as a constant integer value and the <id> needs to be used to specify the value. Fix the auto-generated SPIR-V (de)serialization to handle this. PiperOrigin-RevId: 285849431
* Remove unused variable (fix warning) NFCMehdi Amini2019-12-161-2/+1
| | | | PiperOrigin-RevId: 285799680
* Skip generating C++ for "DeclareOpInterfaceMethods" in op interface gen.Jing Pu2019-12-131-6/+16
| | | | | | This is needed for calling the generator on a .td file that contains both OpInterface definitions and op definitions with DeclareOpInterfaceMethods<...> Traits. PiperOrigin-RevId: 285465784
* Fix logic on when to emit collective type but separate arg builderJacques Pienaar2019-12-121-1/+1
| | | | | | Got the comment right but the code wrong :/ PiperOrigin-RevId: 285270561
* Add type inference variant for separate params builder generatedJacques Pienaar2019-12-121-93/+90
| | | | | | Add variant that does invoke infer type op interface where defined. Also add entry function that invokes that different separate argument builders for wrapped, unwrapped and inference variant. PiperOrigin-RevId: 285220709
* ODS: Generate named accessors for raw attributesJacques Pienaar2019-12-091-21/+36
| | | | | | | | | | | | | | Currently named accessors are generated for attributes returning a consumer friendly type. But sometimes the attributes are used while transforming an existing op and then the returned type has to be converted back into an attribute or the raw `getAttr` needs to be used. Generate raw named accessor for attributes to reference the raw attributes without having to use the string interface for better compile time verification. This allows calling `blahAttr()` instead of `getAttr("blah")`. Raw here refers to returning the underlying storage attribute. PiperOrigin-RevId: 284583426
* Minor spelling tweaksKazuaki Ishizaki2019-12-091-1/+1
| | | | | | Closes tensorflow/mlir#304 PiperOrigin-RevId: 284568358
* Update the builder API to take ValueRange instead of ArrayRef<Value *>River Riddle2019-12-071-9/+8
| | | | | | This allows for users to provide operand_range and result_range in builder.create<> calls, instead of requiring an explicit copy into a separate data structure like SmallVector/std::vector. PiperOrigin-RevId: 284360710
* Change inferReturnTypes to return LogicalResult and valuesJacques Pienaar2019-12-061-11/+15
| | | | | | | | Previously the error case was using a sentinel in the error case which was bad. Also make the one `build` invoke the other `build` to reuse verification there. And follow up on suggestion to use formatv which I missed during previous review. PiperOrigin-RevId: 284265762
* Generate builder for ops that use InferTypeOpInterface trait in ODSJacques Pienaar2019-12-061-10/+38
| | | | | | | | | | For ops with infer type op interface defined, generate version that calls the inferal method on build. This is intermediate step to removing special casing of SameOperandsAndResultType & FirstAttrDereivedResultType. After that would be generating the inference code, with the initial focus on shaped container types. In between I plan to refactor these a bit to reuse generated paths. The intention would not be to add the type inference trait in multiple places, but rather to take advantage of the current modelling in ODS where possible to emit it instead. Switch the `inferReturnTypes` method to be static. Skipping ops with regions here as I don't like the Region vs unique_ptr<Region> difference at the moment, and I want the infer return type trait to be useful for verification too. So instead, just skip it for now to avoid churn. PiperOrigin-RevId: 284217913
* minor spelling tweaksKazuaki Ishizaki2019-12-063-5/+5
| | | | | | | Closes tensorflow/mlir#290 COPYBARA_INTEGRATE_REVIEW=https://github.com/tensorflow/mlir/pull/290 from kiszk:spelling_tweaks_201912 9d9afd16a723dd65754a04698b3976f150a6054a PiperOrigin-RevId: 284169681
* Refactor dependencies to expose Vector transformations as patterns - NFCNicolas Vasilache2019-12-031-2/+3
| | | | | | | | | This CL refactors some of the MLIR vector dependencies to allow decoupling VectorOps, vector analysis, vector transformations and vector conversions from each other. This makes the system more modular and allows extracting VectorToVector into VectorTransforms that do not depend on vector conversions. This refactoring exhibited a bunch of cyclic library dependencies that have been cleaned up. PiperOrigin-RevId: 283660308
* NFC: use `&&` instead of `and`Lei Zhang2019-12-021-1/+1
| | | | PiperOrigin-RevId: 283392575
* [ODS] Generate builders taking unwrapped value and defaults for attributesLei Zhang2019-12-022-40/+167
| | | | | | | | | | | | | | | | | | Existing builders generated by ODS require attributes to be passed in as mlir::Attribute or its subclasses. This is okay foraggregate- parameter builders, which is primarily to be used by programmatic C++ code generation; it is inconvenient for separate-parameter builders meant to be called in manually written C++ code because it requires developers to wrap raw values into mlir::Attribute by themselves. This CL extends to generate additional builder methods that take raw values for attributes and handles the wrapping in the builder implementation. Additionally, if an attribute appears late in the arguments list and has a default value, the default value is supplied in the declaration if possible. PiperOrigin-RevId: 283355919
* [DRR] Introduce `$_` to ignore op argument matchLei Zhang2019-12-021-2/+5
| | | | | | | | Right now op argument matching in DRR is position-based, meaning we need to specify N arguments for an op with N ODS-declared argument. This can be annoying when we don't want to capture all the arguments. `$_` is to remedy the situation. PiperOrigin-RevId: 283339992
* mlir-tblgen: Dump input records when no generator is setJacques Pienaar2019-11-291-1/+4
| | | | | | Follow LLVM's tblgen convention when no generator is set instead of asserting. PiperOrigin-RevId: 283073690
* Add support for AttrSizedOperandSegments/AttrSizedResultSegmentsLei Zhang2019-11-252-28/+119
| | | | | | | | | | | | | | | | | Certain operations can have multiple variadic operands and their size relationship is not always known statically. For such cases, we need a per-op-instance specification to divide the operands into logical groups or segments. This can be modeled by attributes. This CL introduces C++ trait AttrSizedOperandSegments for operands and AttrSizedResultSegments for results. The C++ trait just guarantees such size attribute has the correct type (1D vector) and values (non-negative), etc. It serves as the basis for ODS sugaring that with ODS argument declarations we can further verify the number of elements match the number of ODS-declared operands and we can generate handy getter methods. PiperOrigin-RevId: 282467075
* Move Linalg Transforms that are actually Conversions - NFCNicolas Vasilache2019-11-211-1/+3
| | | | PiperOrigin-RevId: 281844602
* Add support for using the ODS result names as the Asm result names for ↵River Riddle2019-11-211-0/+36
| | | | | | | | | | | | | | | multi-result operations. This changes changes the OpDefinitionsGen to automatically add the OpAsmOpInterface for operations with multiple result groups using the provided ODS names. We currently just limit the generation to multi-result ops as most single result operations don't have an interesting name(result/output/etc.). An example is shown below: // The following operation: def MyOp : ... { let results = (outs AnyType:$first, Variadic<AnyType>:$middle, AnyType); } // May now be printed as: %first, %middle:2, %0 = "my.op" ... PiperOrigin-RevId: 281834156
* Change CUDA tests to use print_memref.Christian Sigg2019-11-211-13/+0
| | | | | | Swap dimensions in all-reduce-op test. PiperOrigin-RevId: 281791744
* Implement unrolling of vector ops to finer-grained vector ops as a pattern.Nicolas Vasilache2019-11-201-1/+1
| | | | | | | | | This CL uses the pattern rewrite infrastructure to implement a simple VectorOps -> VectorOps legalization strategy to unroll coarse-grained vector operations into finer grained ones. The transformation is written using local pattern rewrites to allow composition with other rewrites. It proceeds by iteratively introducing fake cast ops and cleaning canonicalizing or lowering them away where appropriate. This is an example of writing transformations as compositions of local pattern rewrites that should enable us to make them significantly more declarative. PiperOrigin-RevId: 281555100
* Add some CMake rules for installing headers, mlir-tblgen, and mlir-optEric Schweitz2019-11-191-1/+1
| | | | | | Closes tensorflow/mlir#246 PiperOrigin-RevId: 281442685
* Make type and rank explicit in mcuMemHostRegister function.Christian Sigg2019-11-191-18/+24
| | | | | | Fix registered size of indirect MemRefType kernel arguments. PiperOrigin-RevId: 281362940
* Drop unnecessary dependences from mlir-translateUday Bondhugula2019-11-181-6/+0
| | | | | | | Closes tensorflow/mlir#243 COPYBARA_INTEGRATE_REVIEW=https://github.com/tensorflow/mlir/pull/243 from bondhugula:patch-2 fb682996efde001189414a4c7aa59ce42ace7831 PiperOrigin-RevId: 281167834
* Use aggregate-parameter builder for ops having autogen type-deduction builderLei Zhang2019-11-152-86/+247
| | | | | | | | | | | | | | | | | | | | | | Thus far DRR always invokes the separate-parameter builder (i.e., requiring a separate parameter for each result-type/operand/attribute) for creating ops, no matter whether we can auto-generate a builder with type-deduction ability or not. This CL changes the path for ops that we can auto-generate type-deduction builders, i.e., with SameOperandsAndResultType/FirstAttrDerivedResultType traits. Now they are going through a aggregate-parameter builder (i.e., requiring one parameter for all result-types/operands/attributes). attributes.) It is expected this approach will be more friendly for future shape inference function autogen and calling those autogen'd shape inference function without excessive packing and repacking operand/attribute lists. Also, it would enable better support for creating ops with optional attributes because we are not required to provide an Attribute() as placeholder for an optional attribute anymore. PiperOrigin-RevId: 280654800
* NFC: Refactor Dialect Conversion targeting SPIR-V.Mahesh Ravishankar2019-11-141-1/+1
| | | | | | | | | | | | Refactoring the conversion from StandardOps/GPU dialect to SPIR-V dialect: 1) Move the SPIRVTypeConversion and SPIRVOpLowering class into SPIR-V dialect. 2) Add header files that expose functions to add patterns for the dialects to SPIR-V lowering, as well as a pass that does the dialect to SPIR-V lowering. 3) Make SPIRVOpLowering derive from OpLowering class. PiperOrigin-RevId: 280486871
* Move Affine to Standard conversion to lib/ConversionAlex Zinenko2019-11-141-0/+1
| | | | | | | This is essentially a dialect conversion and conceptually belongs to conversions. PiperOrigin-RevId: 280460034
* Make VariableOp instructions be in the first block in the function.Hanhan Wang2019-11-121-1/+1
| | | | | | | | | | | Since VariableOp is serialized during processBlock, we add two more fields, `functionHeader` and `functionBody`, to collect instructions for a function. After all the blocks have been processed, we append them to the `functions`. Also, fix a bug in processGlobalVariableOp. The global variables should be encoded into `typesGlobalValues`. PiperOrigin-RevId: 280105366
* [spirv] Properly return when finding error in serializationLei Zhang2019-11-121-4/+3
| | | | PiperOrigin-RevId: 280001339
OpenPOWER on IntegriCloud