%attr = pdl.attribute : %type
// Define an attribute with a constant value:
- %attr = pdl.attribute "hello"
+ %attr = pdl.attribute = "hello"
```
}];
let arguments = (ins Optional<PDL_Type>:$type,
OptionalAttr<AnyAttr>:$value);
let results = (outs PDL_Attribute:$attr);
- let assemblyFormat = "(`:` $type^)? ($value^)? attr-dict-with-keyword";
+ let assemblyFormat = "(`:` $type^)? (`=` $value^)? attr-dict-with-keyword";
let builders = [
OpBuilder<(ins CArg<"Value", "Value()">:$type), [{
// RUN: mlir-opt -split-input-file %s | mlir-opt
-// Verify the generic form can be parsed.
-// RUN: mlir-opt -split-input-file -mlir-print-op-generic %s | mlir-opt
+// RUN: mlir-opt -split-input-file -mlir-print-op-generic -mlir-print-local-scope %s | FileCheck %s --check-prefix=CHECK-GENERIC
// -----
pdl.pattern @attribute_with_dict : benefit(1) {
%root = operation
rewrite %root {
- %attr = attribute {some_unit_attr} attributes {pdl.special_attribute}
+ %attr = attribute = {some_unit_attr} attributes {pdl.special_attribute}
apply_native_rewrite "NativeRewrite"(%attr : !pdl.attribute)
}
}
+
+// -----
+
+// Check that we don't treat the trailing location of a pdl.attribute as the
+// attribute value.
+
+pdl.pattern @attribute_with_loc : benefit(1) {
+ // CHECK-GENERIC: "pdl.attribute"
+ // CHECK-GENERIC-NOT: value = loc
+ %attr = attribute loc("bar")
+
+ %root = operation {"attribute" = %attr}
+ rewrite %root with "rewriter"
+}
%rxact = pdl.operand : %in_type
%weight = pdl.operand : %weight_type
- %attr0 = pdl.attribute false
+ %attr0 = pdl.attribute = false
%op0 = pdl.operation "tf.MatMul" (%rxact, %weight : !pdl.value, !pdl.value) {"transpose_a" = %attr0, "transpose_b" = %attr0} -> (%out_type : !pdl.type)
pdl.rewrite %op0 {
%rxdelta = pdl.operand : %out_type
%weight = pdl.operand : %weight_type
- %attr0 = pdl.attribute true
- %attr1 = pdl.attribute false
+ %attr0 = pdl.attribute = true
+ %attr1 = pdl.attribute = false
%op0 = pdl.operation "tf.MatMul" (%rxact, %rxdelta : !pdl.value, !pdl.value) {"transpose_a" = %attr0, "transpose_b" = %attr1} -> (%weight_type : !pdl.type)
%val0 = pdl.result 0 of %op0
%op1 = pdl.operation "tf.Const" -> (%const_type : !pdl.type)
%weight = pdl.operand : %weight_type
%bias = pdl.operand : %bias_type
- %attr0 = pdl.attribute false
+ %attr0 = pdl.attribute = false
%op0 = pdl.operation "tf.MatMul" (%rxact, %weight : !pdl.value, !pdl.value) {"transpose_a" = %attr0, "transpose_b" = %attr0} -> (%out_type : !pdl.type)
%val0 = pdl.result 0 of %op0
%op1 = pdl.operation "tf.BiasAdd" (%val0, %bias : !pdl.value, !pdl.value) -> (%out_type : !pdl.type)
%val2 = pdl.result 0 of %op2
%op3 = pdl.operation "tf.ReluGrad" (%rxdelta, %val2 : !pdl.value, !pdl.value) -> (%out_type : !pdl.type)
%val3 = pdl.result 0 of %op3
- %attr1 = pdl.attribute true
+ %attr1 = pdl.attribute = true
%op4 = pdl.operation "tf.MatMul" (%rxact, %val3 : !pdl.value, !pdl.value) {"transpose_a" = %attr1, "transpose_b" = %attr0} -> (%weight_type : !pdl.type)
%val4 = pdl.result 0 of %op4
%op5 = pdl.operation "kernel.GD" (%weight, %val4 : !pdl.value, !pdl.value) -> (%weight_type : !pdl.type)
%rxdelta = pdl.operand : %out_type
%weight = pdl.operand : %weight_type
- %attr0 = pdl.attribute false
+ %attr0 = pdl.attribute = false
%op0 = pdl.operation "tf.MatMul" (%rxact, %weight : !pdl.value, !pdl.value) {"transpose_a" = %attr0, "transpose_b" = %attr0} -> (%out_type : !pdl.type)
- %attr1 = pdl.attribute true
+ %attr1 = pdl.attribute = true
%op1 = pdl.operation "tf.MatMul" (%rxdelta, %weight : !pdl.value, !pdl.value) {"transpose_a" = %attr0, "transpose_b" = %attr1} -> (%in_type : !pdl.type)
%op2 = pdl.operation "tf.MatMul" (%rxact, %rxdelta : !pdl.value, !pdl.value) {"transpose_a" = %attr1, "transpose_b" = %attr0} -> (%weight_type : !pdl.type)
%val2 = pdl.result 0 of %op2