Skip to content

Commit 1e85342

Browse files
committed
Revert "Introduce MLIR Op Properties"
This reverts commit d572cd1. Some bots are broken and investigation is needed before relanding.
1 parent c3efd7e commit 1e85342

File tree

84 files changed

+478
-3081
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

84 files changed

+478
-3081
lines changed

mlir/docs/LangRef.md

Lines changed: 9 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -290,14 +290,12 @@ Syntax:
290290
operation ::= op-result-list? (generic-operation | custom-operation)
291291
trailing-location?
292292
generic-operation ::= string-literal `(` value-use-list? `)` successor-list?
293-
dictionary-properties? region-list? dictionary-attribute?
294-
`:` function-type
293+
region-list? dictionary-attribute? `:` function-type
295294
custom-operation ::= bare-id custom-operation-format
296295
op-result-list ::= op-result (`,` op-result)* `=`
297296
op-result ::= value-id (`:` integer-literal)
298297
successor-list ::= `[` successor (`,` successor)* `]`
299298
successor ::= caret-id (`:` block-arg-list)?
300-
dictionary-propertes ::= `<` dictionary-attribute `>`
301299
region-list ::= `(` region (`,` region)* `)`
302300
dictionary-attribute ::= `{` (attribute-entry (`,` attribute-entry)*)? `}`
303301
trailing-location ::= (`loc` `(` location `)`)?
@@ -314,10 +312,9 @@ semantics. For example, MLIR supports
314312
The internal representation of an operation is simple: an operation is
315313
identified by a unique string (e.g. `dim`, `tf.Conv2d`, `x86.repmovsb`,
316314
`ppc.eieio`, etc), can return zero or more results, take zero or more operands,
317-
has storage for [properties](#properties), has a dictionary of
318-
[attributes](#attributes), has zero or more successors, and zero or more
319-
enclosed [regions](#regions). The generic printing form includes all these
320-
elements literally, with a function type to indicate the types of the
315+
has a dictionary of [attributes](#attributes), has zero or more successors, and
316+
zero or more enclosed [regions](#regions). The generic printing form includes
317+
all these elements literally, with a function type to indicate the types of the
321318
results and operands.
322319

323320
Example:
@@ -331,11 +328,8 @@ Example:
331328
%foo, %bar = "foo_div"() : () -> (f32, i32)
332329
333330
// Invoke a TensorFlow function called tf.scramble with two inputs
334-
// and an attribute "fruit" stored in properties.
335-
%2 = "tf.scramble"(%result#0, %bar) <{fruit = "banana"}> : (f32, i32) -> f32
336-
337-
// Invoke an operation with some discardable attributes
338-
%foo, %bar = "foo_div"() {some_attr = "value", other_attr = 42 : i64} : () -> (f32, i32)
331+
// and an attribute "fruit".
332+
%2 = "tf.scramble"(%result#0, %bar) {fruit = "banana"} : (f32, i32) -> f32
339333
```
340334

341335
In addition to the basic syntax above, dialects may register known operations.
@@ -739,15 +733,6 @@ The [builtin dialect](Dialects/Builtin.md) defines a set of types that are
739733
directly usable by any other dialect in MLIR. These types cover a range from
740734
primitive integer and floating-point types, function types, and more.
741735

742-
## Properties
743-
744-
Properties are extra data members stored directly on an Operation class. They
745-
provide a way to store [inherent attributes](#attributes) and other arbitrary
746-
data. The semantics of the data is specific to a given operation, and may be
747-
exposed through [Interfaces](Interfaces.md) accessors and other methods.
748-
Properties can always be serialized to Attribute in order to be printed
749-
generically.
750-
751736
## Attributes
752737

753738
Syntax:
@@ -766,10 +751,9 @@ values. MLIR's builtin dialect provides a rich set of
766751
arrays, dictionaries, strings, etc.). Additionally, dialects can define their
767752
own [dialect attribute values](#dialect-attribute-values).
768753

769-
For dialects which haven't adopted properties yet, the top-level attribute
770-
dictionary attached to an operation has special semantics. The attribute
771-
entries are considered to be of two different kinds based on whether their
772-
dictionary key has a dialect prefix:
754+
The top-level attribute dictionary attached to an operation has special
755+
semantics. The attribute entries are considered to be of two different kinds
756+
based on whether their dictionary key has a dialect prefix:
773757

774758
- *inherent attributes* are inherent to the definition of an operation's
775759
semantics. The operation itself is expected to verify the consistency of
@@ -787,10 +771,6 @@ Note that attribute values are allowed to themselves be dictionary attributes,
787771
but only the top-level dictionary attribute attached to the operation is subject
788772
to the classification above.
789773

790-
When properties are adopted, only discardable attributes are stored in the
791-
top-level dictionary, while inherent attributes are stored in the properties
792-
storage.
793-
794774
### Attribute Value Aliases
795775

796776
```

mlir/include/mlir/Conversion/LLVMCommon/Pattern.h

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -145,11 +145,6 @@ class ConvertOpToLLVMPattern : public ConvertToLLVMPattern {
145145
/// Wrappers around the RewritePattern methods that pass the derived op type.
146146
void rewrite(Operation *op, ArrayRef<Value> operands,
147147
ConversionPatternRewriter &rewriter) const final {
148-
if constexpr (SourceOp::hasProperties())
149-
rewrite(cast<SourceOp>(op),
150-
OpAdaptor(operands, op->getAttrDictionary(),
151-
cast<SourceOp>(op).getProperties()),
152-
rewriter);
153148
rewrite(cast<SourceOp>(op), OpAdaptor(operands, op->getAttrDictionary()),
154149
rewriter);
155150
}
@@ -159,11 +154,6 @@ class ConvertOpToLLVMPattern : public ConvertToLLVMPattern {
159154
LogicalResult
160155
matchAndRewrite(Operation *op, ArrayRef<Value> operands,
161156
ConversionPatternRewriter &rewriter) const final {
162-
if constexpr (SourceOp::hasProperties())
163-
return matchAndRewrite(cast<SourceOp>(op),
164-
OpAdaptor(operands, op->getAttrDictionary(),
165-
cast<SourceOp>(op).getProperties()),
166-
rewriter);
167157
return matchAndRewrite(cast<SourceOp>(op),
168158
OpAdaptor(operands, op->getAttrDictionary()),
169159
rewriter);

mlir/include/mlir/IR/DialectBase.td

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,9 +103,6 @@ class Dialect {
103103

104104
// If this dialect can be extended at runtime with new operations or types.
105105
bit isExtensible = 0;
106-
107-
// Whether inherent Attributes defined in ODS will be stored as Properties.
108-
bit usePropertiesForAttributes = 0;
109106
}
110107

111108
#endif // DIALECTBASE_TD

mlir/include/mlir/IR/ExtensibleDialect.h

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,6 @@
2626
#include "mlir/IR/OpDefinition.h"
2727
#include "mlir/Support/TypeID.h"
2828
#include "llvm/ADT/StringMap.h"
29-
#include "llvm/Support/ErrorHandling.h"
30-
#include <optional>
3129

3230
namespace mlir {
3331
class AsmParser;
@@ -464,35 +462,6 @@ class DynamicOpDefinition : public OperationName::Impl {
464462
return verifyRegionFn(op);
465463
}
466464

467-
/// Implementation for properties (unsupported right now here).
468-
std::optional<Attribute> getInherentAttr(Operation *op,
469-
StringRef name) final {
470-
llvm::report_fatal_error("Unsupported getInherentAttr on Dynamic dialects");
471-
}
472-
void setInherentAttr(Operation *op, StringAttr name, Attribute value) final {
473-
llvm::report_fatal_error("Unsupported setInherentAttr on Dynamic dialects");
474-
}
475-
void populateInherentAttrs(Operation *op, NamedAttrList &attrs) final {}
476-
LogicalResult
477-
verifyInherentAttrs(OperationName opName, NamedAttrList &attributes,
478-
function_ref<InFlightDiagnostic()> getDiag) final {
479-
return success();
480-
}
481-
int getOpPropertyByteSize() final { return 0; }
482-
void initProperties(OperationName opName, OpaqueProperties storage,
483-
OpaqueProperties init) final {}
484-
void deleteProperties(OpaqueProperties prop) final {}
485-
void populateDefaultProperties(OperationName opName,
486-
OpaqueProperties properties) final {}
487-
488-
LogicalResult setPropertiesFromAttr(Operation *op, Attribute attr,
489-
InFlightDiagnostic *diag) final {
490-
return failure();
491-
}
492-
Attribute getPropertiesAsAttr(Operation *op) final { return {}; }
493-
void copyProperties(OpaqueProperties lhs, OpaqueProperties rhs) final {}
494-
llvm::hash_code hashProperties(OpaqueProperties prop) final { return {}; }
495-
496465
private:
497466
DynamicOpDefinition(
498467
StringRef name, ExtensibleDialect *dialect,

mlir/include/mlir/IR/ODSSupport.h

Lines changed: 0 additions & 45 deletions
This file was deleted.

mlir/include/mlir/IR/OpBase.td

Lines changed: 0 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -179,69 +179,6 @@ class TypeConstraint<Pred predicate, string summary = "",
179179
string cppClassName = cppClassNameParam;
180180
}
181181

182-
// Base class for defining properties.
183-
class Property<string storageTypeParam = "", string desc = ""> {
184-
// User-readable one line summary used in error reporting messages. If empty,
185-
// a generic message will be used.
186-
string summary = desc;
187-
// The full description of this property.
188-
string description = "";
189-
code storageType = storageTypeParam;
190-
code interfaceType = storageTypeParam;
191-
192-
// The expression to convert from the storage type to the Interface
193-
// type. For example, an enum can be stored as an int but returned as an
194-
// enum class.
195-
//
196-
// Format:
197-
// - `$_storage` will contain the property in the storage type.
198-
// - `$_ctxt` will contain an `MLIRContext *`.
199-
code convertFromStorage = "$_storage";
200-
201-
// The call expression to build a property storage from the interface type.
202-
//
203-
// Format:
204-
// - `$_storage` will contain the property in the storage type.
205-
// - `$_value` will contain the property in the user interface type.
206-
code assignToStorage = "$_storage = $_value";
207-
208-
// The call expression to convert from the storage type to an attribute.
209-
//
210-
// Format:
211-
// - `$_storage` is the storage type value.
212-
// - `$_ctxt` is a `MLIRContext *`.
213-
//
214-
// The expression must result in an Attribute.
215-
code convertToAttribute = [{
216-
convertToAttribute($_ctxt, $_storage)
217-
}];
218-
219-
// The call expression to convert from an Attribute to the storage type.
220-
//
221-
// Format:
222-
// - `$_storage` is the storage type value.
223-
// - `$_attr` is the attribute.
224-
// - `$_diag` is an optional Diagnostic pointer to emit error.
225-
//
226-
// The expression must return a LogicalResult
227-
code convertFromAttribute = [{
228-
return convertFromAttribute($_storage, $_attr, $_diag);
229-
}];
230-
231-
// The call expression to hash the property.
232-
//
233-
// Format:
234-
// - `$_storage` is the variable to hash.
235-
//
236-
// The expression should define a llvm::hash_code.
237-
code hashProperty = [{
238-
llvm::hash_value($_storage);
239-
}];
240-
241-
// Default value for the property.
242-
string defaultValue = ?;
243-
}
244-
245182
// Subclass for constraints on an attribute.
246183
class AttrConstraint<Pred predicate, string summary = ""> :
247184
Constraint<predicate, summary>;
@@ -1153,16 +1090,6 @@ class DefaultValuedStrAttr<Attr attr, string val>
11531090
class DefaultValuedOptionalStrAttr<Attr attr, string val>
11541091
: DefaultValuedOptionalAttr<attr, "\"" # val # "\"">;
11551092

1156-
//===----------------------------------------------------------------------===//
1157-
// Primitive property kinds
1158-
1159-
class ArrayProperty<string storageTypeParam = "", int n, string desc = ""> :
1160-
Property<storageTypeParam # "[" # n # "]", desc> {
1161-
let interfaceType = "::llvm::ArrayRef<" # storageTypeParam # ">";
1162-
let convertFromStorage = "$_storage";
1163-
let assignToStorage = "::llvm::copy($_value, $_storage)";
1164-
}
1165-
11661093
//===----------------------------------------------------------------------===//
11671094
// Primitive attribute kinds
11681095

0 commit comments

Comments
 (0)