summaryrefslogtreecommitdiffstats
path: root/mlir/lib/IR/Attributes.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* Add an AttrBase class to simplify defining derived Attributes. This ↵River Riddle2019-05-101-91/+78
| | | | | | | | class serves the same purpose as TypeBase, and thus the duplicated functionality has been split into a new support class 'StorageUserBase'. -- PiperOrigin-RevId: 247358373
* Simplify several usages of attributes now that they always have a type ↵River Riddle2019-05-101-22/+27
| | | | | | | | | | and, transitively, access to the context. This also fixes a bug where FunctionAttrs were not being remapped for function and function argument attributes. -- PiperOrigin-RevId: 246876924
* Add a static utility to FloatAttr for converting an APFloat to double.River Riddle2019-05-061-4/+5
| | | | | | -- PiperOrigin-RevId: 246671765
* Fix up some mixed sign warnings.Jacques Pienaar2019-05-061-6/+5
| | | | | | -- PiperOrigin-RevId: 246614498
* Make the Twine parameter of the current diagnostic emit functions ↵River Riddle2019-05-061-1/+1
| | | | | | | | optional. This allows for the ability to exclusively use the new diagnostic interface without breaking all of the existing usages. Several diagnostics emitted in lib/IR have been updated to make use of this functionality. -- PiperOrigin-RevId: 246546044
* NFC: Move AttributeStorage and AttributeUniquer into a new header ↵River Riddle2019-05-061-0/+34
| | | | | | | | AttributeSupport.h in preparation for them to be used by dialect defined attributes. -- PiperOrigin-RevId: 246385860
* Remove NumericAttr. Now that all attributes contain a type, this ↵River Riddle2019-05-061-9/+0
| | | | | | | | subclass is no longer necessary. -- PiperOrigin-RevId: 246061024
* Ensure that every Attribute contains a Type. If an Attribute does not ↵River Riddle2019-05-061-26/+10
| | | | | | | | provide a type explicitly, the type is defaulted to NoneType. -- PiperOrigin-RevId: 246021088
* Refactor Attribute uniquing to use StorageUniquer instead of being hard ↵River Riddle2019-05-061-1/+197
| | | | | | | | coded in the MLIRContext. This allows for attributes to be uniqued similarly to types. This is the second step towards allowing dialects to define attributes. -- PiperOrigin-RevId: 245974705
* Add iterator support to DenseIntElementsAttr and DenseFPElementsAttr. ↵River Riddle2019-04-071-52/+100
| | | | | | | | This avoids the need to load all of the values from a DenseElementsAttr inorder to process them. -- PiperOrigin-RevId: 242212741
* Add support for building a DenseIntElementsAttr with ArrayRef<int64_t> values.River Riddle2019-03-291-3/+19
| | | | PiperOrigin-RevId: 239616595
* Add support for named function argument attributes. The attribute dictionary ↵River Riddle2019-03-291-1/+4
| | | | | | | | | | is printed after the argument type: func @arg_attrs(i32 {arg_attr: 10}) func @arg_attrs(%arg0: i32 {arg_attr: 10}) PiperOrigin-RevId: 236136830
* Add a generic getValue to ElementsAttr for accessing a value at a given index.River Riddle2019-03-291-0/+18
| | | | PiperOrigin-RevId: 236013669
* Add a new class NamedAttributeList to deduplicate named attribute handling ↵River Riddle2019-03-291-0/+77
| | | | | | between Function and Instruction. PiperOrigin-RevId: 235830304
* Add support for constructing DenseIntElementsAttr with an array of APInt andRiver Riddle2019-03-291-0/+41
| | | | | | DenseFPElementsAttr with an array of APFloat. PiperOrigin-RevId: 235581794
* Add constant folding for ExtractElementOp when the aggregate is an ↵River Riddle2019-03-291-0/+8
| | | | | | OpaqueElementsAttr. PiperOrigin-RevId: 235533283
* Add dialect-specific decoding for opaque constants.Tatiana Shpeisman2019-03-291-0/+11
| | | | | | | | Associates opaque constants with a particular dialect. Adds general mechanism to register dialect-specific hooks defined in external components. Adds hooks to decode opaque tensor constant and extract an element of an opaque tensor constant. This CL does not change the existing mechanism for registering constant folding hook yet. One thing at a time. PiperOrigin-RevId: 233544757
* Define NumericAttr as the base class for BoolAttr, IntegerAttr, FloatAttr, ↵Lei Zhang2019-03-291-0/+22
| | | | | | | | | | | | | | and ElementsAttr These attribute kinds are different from the rest in the sense that their types are defined in MLIR's type hierarchy and we can build constant op out of them. By defining this middle-level base class, we have a unified way to test and query the type of these attributes, which will be useful when constructing constant ops of various dialects. This CL also added asserts to reject non-NumericAttr in constant op's build() method. PiperOrigin-RevId: 232188178
* Migrate VectorOrTensorType/MemRefType shape api to use int64_t instead of int.River Riddle2019-03-291-2/+2
| | | | PiperOrigin-RevId: 230605756
* Add a constant folding hook to ExtractElementOp to fold extracting the ↵River Riddle2019-03-291-2/+86
| | | | | | element of a constant. This also adds a 'getValue' function to DenseElementsAttr and SparseElementsAttr to get the element at a constant index. PiperOrigin-RevId: 230098938
* [MLIR] Add functionality for constructing a DenseElementAttr from an array ↵River Riddle2019-03-291-98/+90
| | | | | | of attributes and rerwite DenseElementsAttr::writeBits/readBits to handle non uniform bitwidths. This fixes asan failures that happen when using non uniform bitwidths. PiperOrigin-RevId: 229815107
* Emit unsupported error when parsing a DenseElementAttr with an integer type ↵River Riddle2019-03-291-0/+4
| | | | | | | | of greater than 64 bits. DenseElementAttr currently does not support value bitwidths of > 64. This can result in asan failures and crashes when trying to invoke DenseElementsAttr::writeBits/DenseElementsAttr::readBits. PiperOrigin-RevId: 229241125
* Simplify Attribute constructor definitions.River Riddle2019-03-291-22/+16
| | | | PiperOrigin-RevId: 228926113
* add a method to get FloatAttr value as doubleFeng Liu2019-03-291-1/+10
| | | | | | | | | | | | | | | | | Sometimes we have to get the raw value of the FloatAttr to invoke APIs from non-MLIR libraries (i.e. in the tpu_ops.inc and convert_tensor.cc files). Using `FloatAttr::getValue().convertToFloat()` and `FloatAttr::getValue().convertToDouble()` is not safe because interally they checke the semantics of the APFloat in the attribute, and the semantics is not always specified (the default value is f64 then convertToFloat will fail) or inferred incorrectly (for example, using 1.0 instead of 1.f for IEEEFloat). Calling these convert methods without knowing the semantics can usually crash the compiler. This new method converts the value of a FloatAttr to double even if it loses precision. Currently this method can be used to read in f32 data from arrays. PiperOrigin-RevId: 227076616
* Densify storage for f16, f32 and support f16 semantics in FloatAttrsAlex Zinenko2019-03-291-12/+36
| | | | | | | | | | | | | | | | | | Existing implementation always uses 64 bits to store floating point values in DenseElementsAttr. This was due to FloatAttrs always a `double` for storage independently of the actual type. Recent commits added support for FloatAttrs with the proper f32 type and floating semantics and changed the bitwidth reporting on FloatType. Use the existing infrastructure for densely storing 16 and 32-bit values in DenseElementsAttr storage to store f16 and f32 values. Move floating semantics definition to the FloatType level. Properly support f16 / IEEEhalf semantics at the FloatAttr level and in the builder. Note that bf16 is still stored as a 64-bit value with IEEEdouble semantics because APFloat does not have first-class support for bf16 types. PiperOrigin-RevId: 225981289
* Add Type to int/float attributes.Jacques Pienaar2019-03-291-5/+10
| | | | | | | | | | | | * Optionally attach the type of integer and floating point attributes to the attributes, this allows restricting a int/float to specific width. - Currently this allows suffixing int/float constant with type [this might be revised in future]. - Default to i64 and f32 if not specified. * For index types the APInt width used is 64. * Change callers to request a specific attribute type. * Store iN type with APInt of width N. * This change does not handle the folding of constants of different types (e.g., doing int type promotions to support constant folding i3 and i32), and instead restricts the constant folding to only operate on the same types. PiperOrigin-RevId: 221722699
* ConvertToCFG: properly remap nested function attributes.Alex Zinenko2019-03-291-0/+33
| | | | | | | | | | | | Array attributes can nested and function attributes can appear anywhere at that level. They should be remapped to point to the generated CFGFunction after ML-to-CFG conversion, similarly to plain function attributes. Extract the nested attribute remapping functionality from the Parser to Utils. Extract out the remapping function for individual Functions from the module remapping function. Use these new functions in the ML-to-CFG conversion pass and in the parser. PiperOrigin-RevId: 221510997
* Switch IntegerAttr to use APInt.Jacques Pienaar2019-03-291-2/+4
| | | | | | | | Change the storage type to APInt from int64_t for IntegerAttr (following the change to APFloat storage in FloatAttr). Effectively a direct change from int64_t to 64-bit APInt throughout (the bitwidth hardcoded). This change also adds a getInt convenience method to IntegerAttr and replaces previous getValue calls with getInt calls. While this changes updates the storage type, it does not update all constant folding calls. PiperOrigin-RevId: 221082788
* Implement value type abstraction for types.River Riddle2019-03-291-9/+7
| | | | | | This is done by changing Type to be a POD interface around an underlying pointer storage and adding in-class support for isa/dyn_cast/cast. PiperOrigin-RevId: 219372163
* Introduce integer set attributeUday Bondhugula2019-03-291-0/+8
| | | | | | | - add IntegerSetAttr to Attributes; add parsing and other support for it (builder, etc.). PiperOrigin-RevId: 218804579
* Implement value type abstraction for attributes.River Riddle2019-03-291-0/+214
| | | | | | This is done by changing Attribute to be a POD interface around an underlying pointer storage and adding in-class support for isa/dyn_cast/cast. PiperOrigin-RevId: 218764173
* Support for AffineMapAttr.MLIR Team2019-03-291-53/+0
| | | | PiperOrigin-RevId: 205157390
* Add parsing for attributes and attibutes on operations. Add IR representationChris Lattner2019-03-291-9/+5
| | | | | | | for attributes on operations. Split Operation out from OperationInst so it can be shared with OperationStmt one day. PiperOrigin-RevId: 203325366
* Implement IR support for attributes.Chris Lattner2019-03-291-0/+57
PiperOrigin-RevId: 203293376
OpenPOWER on IntegriCloud