I have an op<mydialect.ConvOp>
with some attributes of the convOp
info like padding, stride… The attributes names would be customer-like. Then i want to convert a pattern with ConvOp in it to the destination pattern with the conv info copy to it. So i think i will use the rewrite func on C++ to realize it and treat the attr of ConvOp
as the arguments of the func. Having lots of customer patterns to fuse, so i want to treat a DictionaryAttr
as an argument. Then i can use the api setAttr
, just traverse the DictionaryAttr
from PDLL, and set a customer NamedAttribute
.
Rewrite addDictoryAttr(src: Op, DictoryAttr dt) -> Op;
Pattern {
let dimension_numbers : Attr;
let padding : Attr;
let rhs_dilation : Attr;
let window_strides : Attr;
let batch_group_count : Attr;
let feature_group_count : Attr;
let broadcast_dimensions : Attr;
let conv = op<mhlo.convolution>(input: Value, weight: Value) {
dimension_numbers = dimension_numbers,
padding = padding,
rhs_dilation = rhs_dilation,
window_strides = window_strides,
batch_group_count = batch_group_count,
feature_group_count = feature_group_count};
let broadcast_bias = op<mhlo.broadcast_in_dim>(bias: Value) {broadcast_dimensions = broadcast_dimensions};
let conv_add = op<mhlo.add>(conv.0, broadcast_bias.0);
let sigmoid = op<mhlo.logistic>(conv_add.0);
let mul = op<mhlo.multiply>(conv_add.0, sigmoid.0) -> (output : Type);
rewrite mul with {
let custom_op = op<mhlo.custom_call>((input, weight, bias)) {
call_target_name = attr<"\"conv_silu\"">,
has_side_effect = attr<"false">,
backend_config = attr<"\"\"">,
api_version = attr<"1 : i32">
} -> (output);
replace mul with addDictoryAttr(custom_op, ??);
};
}
More specifically, on the code above, how could i set the ??
to match the DictoryAttr, here i don’t hope to set the conv args one by one.
Any suggestions?