summaryrefslogtreecommitdiffstats
path: root/mlir/unittests
Commit message (Collapse)AuthorAgeFilesLines
* [mlir] Use getDenseElementBitwidth instead of Type::getElementTypeBitWidth.River Riddle2020-01-091-0/+10
| | | | | | | | Summary: Some data values have a different storage width than the corresponding MLIR type, e.g. bfloat is currently stored as a double. Reviewed By: nicolasvasilache Differential Revision: https://reviews.llvm.org/D72478
* [mlir] Fix indexed_accessor_range to properly forward the derived class.River Riddle2020-01-033-0/+56
| | | | | | | | Summary: This fixes the return value of helper methods on the base range class. Reviewed By: jpienaar Differential Revision: https://reviews.llvm.org/D72127
* [mlir] Enhance classof() checks in StructsGenLei Zhang2020-01-032-3/+28
| | | | | | | | | | | 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
* NFC: Replace ValuePtr with Value and remove it now that Value is value-typed.River Riddle2019-12-231-4/+4
| | | | | | 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-2318-234/+72
| | | | PiperOrigin-RevId: 286906740
* NFC: Introduce new ValuePtr/ValueRef typedefs to simplify the transition to ↵River Riddle2019-12-221-4/+4
| | | | | | | | | | 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 a new utility class TypeSwitch to ADT.River Riddle2019-12-173-0/+103
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This class provides a simplified mechanism for defining a switch over a set of types using llvm casting functionality. More specifically, this allows for defining a switch over a value of type T where each case corresponds to a type(CaseT) that can be used with dyn_cast<CaseT>(...). An example is shown below: // Traditional piece of code: Operation *op = ...; if (auto constant = dyn_cast<ConstantOp>(op)) ...; else if (auto return = dyn_cast<ReturnOp>(op)) ...; else ...; // New piece of code: Operation *op = ...; TypeSwitch<Operation *>(op) .Case<ConstantOp>([](ConstantOp constant) { ... }) .Case<ReturnOp>([](ReturnOp return) { ... }) .Default([](Operation *op) { ... }); Aside from the above, TypeSwitch supports return values, void return, multiple types per case, etc. The usability is intended to be very similar to StringSwitch. (Using c++14 template lambdas makes everything even nicer) More complex example of how this makes certain things easier: LogicalResult process(Constant op); LogicalResult process(ReturnOp op); LogicalResult process(FuncOp op); TypeSwitch<Operation *, LogicalResult>(op) .Case<ConstantOp, ReturnOp, FuncOp>([](auto op) { return process(op); }) .Default([](Operation *op) { return op->emitError() << "could not be processed"; }); PiperOrigin-RevId: 286003613
* minor spelling tweaksKazuaki Ishizaki2019-12-061-1/+1
| | | | | | | Closes tensorflow/mlir#290 COPYBARA_INTEGRATE_REVIEW=https://github.com/tensorflow/mlir/pull/290 from kiszk:spelling_tweaks_201912 9d9afd16a723dd65754a04698b3976f150a6054a PiperOrigin-RevId: 284169681
* Allow analyses to provide a hook 'isInvalidated' to determine if they are ↵River Riddle2019-12-031-0/+33
| | | | | | | | | | | | | | truly invalidated. The hook has the following form: * `bool isInvalidated(const AnalysisManager::PreservedAnalyses &)` Given a preserved analysis set, the analysis returns true if it should truly be invalidated. This allows for more fine-tuned invalidation in cases where an analysis wasn't explicitly marked preserved, but may be preserved(or invalidated) based upon other properties; such as analyses sets. PiperOrigin-RevId: 283582889
* Move BitEnumAttr from SPIRVBase.td to OpBase.tdLei Zhang2019-11-012-0/+47
| | | | | | | | | | | | | | | | | BitEnumAttr is a mechanism for modelling attributes whose value is a bitfield. It should not be scoped to the SPIR-V dialect and can be used by other dialects too. This CL is mostly shuffling code around and adding tests and docs. Functionality changes are: * Fixed to use `getZExtValue()` instead of `getSExtValue()` when getting the value from the underlying IntegerAttr for a case. * Changed to auto-detect whether there is a case whose value is all bits unset (i.e., zero). If so handle it specially in all helper methods. PiperOrigin-RevId: 277964926
* Fix minor spelling tweaks (NFC)Kazuaki Ishizaki2019-10-203-3/+3
| | | | | | Closes tensorflow/mlir#175 PiperOrigin-RevId: 275726876
* NFC: Remove trivial builder get methods.River Riddle2019-10-171-1/+1
| | | | | | These don't add any value, and some are even more restrictive than the respective static 'get' method. PiperOrigin-RevId: 275391240
* Switch explicit create methods to match generated build's orderJacques Pienaar2019-09-281-2/+2
| | | | | | The generated build methods have result type before the arguments (operands and attributes, which are also now adjacent in the explicit create method). This also results in changing the create method's ordering to match most build method's ordering. PiperOrigin-RevId: 271755054
* Handle OpMemberName instruction in SPIR-V deserializer.Mahesh Ravishankar2019-09-231-4/+72
| | | | | | | | | | Sdd support in deserializer for OpMemberName instruction. For now the name is just processed and not associated with the spirv::StructType being built. That needs an enhancement to spirv::StructTypes itself. Add tests to check for errors reported during deserialization with some refactoring to common out some utility functions. PiperOrigin-RevId: 270794524
* Refactor DiagnosticEngine to support multiple registered diagnostic handlers.River Riddle2019-09-231-1/+1
| | | | | | | | | | | | This fixes a problem with current save-restore pattern of diagnostics handlers, as there may be a thread race between when the previous handler is destroyed. For example, this occurs when using multiple ParallelDiagnosticHandlers asynchronously: Handler A Handler B | - LifeTime - | Restore A here. Handler C | --- LifeTime ---| Restore B after it has been destroyed. The new design allows for multiple handlers to be registered in a stack like fashion. Handlers can return success() to signal that they have fully processed a diagnostic, or failure to propagate otherwise. PiperOrigin-RevId: 270720625
* NFC: Pass OperationState by reference instead of by pointer.River Riddle2019-09-201-1/+1
| | | | | | MLIR follows the LLVM convention of passing by reference instead of by pointer. PiperOrigin-RevId: 270396945
* SDBM: support sum expressions on the LHS of stripe expressionsAlex Zinenko2019-09-181-2/+22
| | | | | | | | | Introduce support for applying the stripe operator to sum expressions, as in (x + A) # B = x + A - (x + A) mod B. This is required to represent a combination of tiling and padding in the SDBM framework, and is a valid SDBM construct that was not originally supported. PiperOrigin-RevId: 269758807
* Simplify SDBM expressions more aggressively in operators and conversionsAlex Zinenko2019-09-181-0/+14
| | | | | | | | | | | | Extend SDBM simplification patterns to support more cases where the addition of two expressions each involving one or two variables would result in a sum expression that only contains one variable and thus remains in the SDBM domain. This is made possible by the new canonical structure of SDBM where the constant term appears once. This simplification will be necessary to support round-tripping of stripe expressions containing constant terms on the LHS through affine expressions. PiperOrigin-RevId: 269757732
* Overhaul the SDBM expression kind hierarchyAlex Zinenko2019-09-161-4/+63
| | | | | | | | | | | | | | | | | | | | | | | | | | Swap the allowed nesting of sum and diff expressions: now a diff expression can contain a sum expression, but only on the left hand side. A difference of two expressions sum must be canonicalized by grouping their constant terms in a single expression. This change of sturcture became possible thanks to the introduction of the "direct" super-kind. It is necessary to enable support of sum expressions on the left hand side of the stripe expression. SDBM expressions are now grouped into the following structure - expression - varying - direct - sum <- (term, constant) - term - symbol - dimension - stripe <- (term, constant) - negation <- (direct) - difference <- (direct, term) - constant The notation <- (...) denotes the types of subexpressions a compound expression can combine. PiperOrigin-RevId: 269337222
* Introduce SDBMDirect expression into the SDBM expression hierarchyAlex Zinenko2019-09-161-0/+4
| | | | | | | | | | Direct expressions are those that do not negate any of the variables they involve. They include input expressions (dimensions and symbols), stripe and sum expressions, and combinations of those. Reifying direct expressions as a class is a precondition for enabling additions on the LHS of a stripe expression. PiperOrigin-RevId: 269336031
* Rename SDBMPositiveExpr to SDBMTermExprAlex Zinenko2019-09-111-3/+3
| | | | | | | | | | | 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
* Fix typos in SDBMTest.cppAlex Zinenko2019-09-111-2/+2
| | | | PiperOrigin-RevId: 268443146
* Avoid sign-compare warningJacques Pienaar2019-09-091-3/+3
| | | | PiperOrigin-RevId: 268132321
* Add missing link dependency to MLIRTableGenTestsLei Zhang2019-08-311-1/+1
| | | | PiperOrigin-RevId: 266561495
* Fix StructsGenTest.cpp CMakeFile build errorRob Suderman2019-08-301-1/+1
| | | | PiperOrigin-RevId: 266452719
* Added a TableGen generator for structured dataRob Suderman2019-08-303-0/+182
| | | | | | Similar to enum, added a generator for structured data. This provide Dictionary that stores a fixed set of values and guarantees the values are valid. It is intended to store a fixed number of values by a given name. PiperOrigin-RevId: 266437460
* Generalize the analysis manager framework to work on any operation at any ↵River Riddle2019-08-281-15/+20
| | | | | | | | nesting. The pass manager is moving towards being able to run on operations at arbitrary nesting. An operation may have both parent and child operations, and the AnalysisManager must be able to handle this generalization. The AnalysisManager class now contains generic 'getCachedParentAnalysis' and 'getChildAnalysis/getCachedChildAnalysis' functions to query analyses on parent/child operations. This removes the hard coded nesting relationship between Module/Function. PiperOrigin-RevId: 266003636
* [spirv] Fix the entry block to start with OpLabelLei Zhang2019-08-271-5/+29
| | | | | | | | Each basic block in SPIR-V must start with an OpLabel instruction. We don't support control flow yet, so this CL just makes sure that the entry block follows this rule and is valid. PiperOrigin-RevId: 265718841
* [spirv] Add Block decoration for spv.struct.Denis Khalikov2019-08-272-0/+127
| | | | | | | | Add Block decoration for top-level spv.struct. Closes tensorflow/mlir#102 PiperOrigin-RevId: 265716241
* NFC: Remove the explicit context from Operation::create and OperationState.River Riddle2019-08-261-1/+1
| | | | | | The context can easily be recovered from the Location in these situations. PiperOrigin-RevId: 265578574
* NFC: Move LLVMIR, SDBM, and StandardOps to the Dialect/ directory.River Riddle2019-08-191-3/+3
| | | | PiperOrigin-RevId: 264193915
* Add missing include file to StringExtrasTest.cppMahesh Ravishankar2019-07-301-1/+1
| | | | | | | Use of std::isupper and std::islower need <cctype> header file. Fix that and also fix the header of a file to match the file name. PiperOrigin-RevId: 260816852
* Add support for (de)serialization of SPIR-V Op DecorationsMahesh Ravishankar2019-07-302-0/+75
| | | | | | | | | | | | 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
* [spirv] Add basic infrastructure for negative deserializer testsLei Zhang2019-07-303-0/+213
| | | | | | | | | | | | | 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
* NFC: Rename Module to ModuleOp.River Riddle2019-07-101-5/+5
| | | | | | Module is a legacy name that only exists as a typedef of ModuleOp. PiperOrigin-RevId: 257427248
* Update ModuleOp::create(...) to take a Location instead of a context.River Riddle2019-07-101-3/+3
| | | | | | This allows for giving a Module a more interesting location than 'Unknown'. PiperOrigin-RevId: 257310117
* NFC: Rename Function to FuncOp.River Riddle2019-07-101-8/+8
| | | | PiperOrigin-RevId: 257293379
* NFC: Refactor Module to be value typed.River Riddle2019-07-021-8/+8
| | | | | | As with Functions, Module will soon become an operation, which are value-typed. This eases the transition from Module to ModuleOp. A new class, OwningModuleRef is provided to allow for owning a reference to a Module, and will auto-delete the held module on destruction. PiperOrigin-RevId: 256196193
* [ODS] NFC: Rename EnumAttr to StrEnumAttr to be consistent with IntEnumAttrLei Zhang2019-07-021-3/+3
| | | | PiperOrigin-RevId: 256169019
* NFC: Refactor Function to be value typed.River Riddle2019-07-011-10/+10
| | | | | | 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
* [ODS] Introduce IntEnumAttrLei Zhang2019-07-012-20/+25
| | | | | | | | | | | | | | | | | | | In ODS, right now we use StringAttrs to emulate enum attributes. It is suboptimal if the op actually can and wants to store the enum as a single integer value; we are paying extra cost on storing and comparing the attribute value. This CL introduces a new enum attribute subclass that are backed by IntegerAttr. The downside with IntegerAttr-backed enum attributes is that the assembly form now uses integer values, which is less obvious than the StringAttr-backed ones. However, that can be remedied by defining custom assembly form with the help of the conversion utility functions generated via EnumsGen. Choices are given to the dialect writers to decide which one to use for their enum attributes. PiperOrigin-RevId: 255935542
* Simplify usages of SplatElementsAttr now that it inherits from ↵River Riddle2019-06-191-1/+1
| | | | | | DenseElementsAttr. PiperOrigin-RevId: 253910543
* Fix the detection of boolean splat values in DenseElementsAttr for arrays ↵River Riddle2019-06-191-0/+11
| | | | | | with <=15 values. PiperOrigin-RevId: 253711372
* Add an overloaded 'get' method to DenseElementsAttr that accepts an ↵River Riddle2019-06-191-8/+4
| | | | | | initializer_list. PiperOrigin-RevId: 253234385
* Explicitly construct ArrayRef in AttributeTest.cppAlex Zinenko2019-06-191-4/+8
| | | | | | | | Some compilers find initializer list constructors from boolean literals ambiguous between ArrayRef<bool> and ArrayRef<Attribute>. Call the ArrayRef<bool> constructor explicitly to disambiguate. PiperOrigin-RevId: 253224859
* Refactor SplatElementsAttr to inherit from DenseElementsAttr as opposed to ↵River Riddle2019-06-191-1/+1
| | | | | | 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
* NFC: Fix a narrowing conversion from size_t to int64_t when constructing a ↵River Riddle2019-06-191-1/+1
| | | | | | VectorType. PiperOrigin-RevId: 253125435
* Refactor DenseElementsAttr to support auto-splatting the dense data on ↵River Riddle2019-06-192-0/+137
| | | | | | 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
* [TableGen] Generating enum definitions and utility functionsLei Zhang2019-06-093-0/+106
| | | | | | | | | | | | | Enum attributes can be defined using `EnumAttr`, which requires all its cases to be defined with `EnumAttrCase`. To facilitate the interaction between `EnumAttr`s and their C++ consumers, add a new EnumsGen TableGen backend to generate a few common utilities, including an enum class, `llvm::DenseMapInfo` for the enum class, conversion functions from/to strings. This is controlled via the `-gen-enum-decls` and `-gen-enum-defs` command-line options of `mlir-tblgen`. PiperOrigin-RevId: 252209623
* Remove the explicit attribute kinds for DenseIntElementsAttr and ↵River Riddle2019-06-091-1/+1
| | | | | | DenseFPElementsAttr in favor of just one DenseElementsAttr. Now that attribute has the ability to define 'classof(Attribute attr)' methods, these derived classes can just be specializations of the main attribute class. PiperOrigin-RevId: 251948820
OpenPOWER on IntegriCloud