Update MLIR ODS syntax to use OpBuidlerDAG instead of OpBuilder

The latter has been deprecated in favor of the former and will be removed.

PiperOrigin-RevId: 339523966
This commit is contained in:
Alex Zinenko 2020-10-28 13:15:35 -07:00 committed by TensorFlow MLIR Team
parent 0052913775
commit e77b5ae534
3 changed files with 34 additions and 41 deletions

View File

@ -89,10 +89,9 @@ class HLOClient_BroadcastBinaryElementwiseOp<
OptionalAttr<BroadcastDimAttr>:$broadcast_dimensions
);
let builders = [OpBuilder<
"OpBuilder &builder, OperationState &result, Value left, Value right, "
"DenseIntElementsAttr broadcast_dimensions"
>];
let builders = [
OpBuilderDAG<(ins "Value":$left, "Value":$right,
"DenseIntElementsAttr":$broadcast_dimensions)>];
let results = (outs HLO_Tensor);
@ -445,11 +444,10 @@ def HLOClient_BroadcastCompareOp : HLOClient_BroadcastBinaryElementwiseOp<
);
let results = (outs HLO_PredTensor);
let builders = [OpBuilder<
"OpBuilder &builder, OperationState &result, Value lhs, Value rhs, "
"DenseIntElementsAttr broadcast_dimensions, "
"StringAttr comparison_direction, StringAttr compare_type = {}"
>];
let builders = [
OpBuilderDAG<(ins "Value":$lhs, "Value":$rhs,
"DenseIntElementsAttr":$broadcast_dimensions,
"StringAttr":$comparison_direction, CArg<"StringAttr", "{}">:$compare_type)>];
}
#endif // CHLO_OPS

View File

@ -58,9 +58,8 @@ def HLO_ConstOp : HLO_Op<"constant",
HLO_StaticShapeTensor:$output
);
let builders = [OpBuilder<
"OpBuilder &builder, OperationState &result, Attribute value"
>];
let builders = [
OpBuilderDAG<(ins "Attribute":$value)>];
let assemblyFormat = "attr-dict $value";
@ -147,9 +146,8 @@ class HLO_UnaryElementwiseOp<string mnemonic, list<OpTrait> traits,
def HLO_AbsOp: HLO_UnaryElementwiseOp<"abs",
[NoSideEffect, SameOperandsAndResultShape],
TensorOf<[HLO_SInt, AnyFloat, HLO_Complex]>>, BASE_HLO_AbsOp {
let builders = [OpBuilder<
"Value operand"
>];
let builders = [
OpBuilderDAG<(ins "Value":$operand)>];
}
def HLO_CbrtOp: HLO_UnaryElementwiseOp<"cbrt",
@ -162,9 +160,8 @@ def HLO_ConvertOp : HLO_UnaryElementwiseOp<
"convert", [NoSideEffect, SameOperandsAndResultShape], HLO_Tensor>,
BASE_HLO_ConvertOp {
let builders = [OpBuilder<
"Value operand, Type result_element_ty"
>];
let builders = [
OpBuilderDAG<(ins "Value":$operand, "Type":$result_element_ty)>];
let hasFolder = 1;
@ -618,10 +615,9 @@ def HLO_ReduceOp: HLO_Op<"reduce", [
let results = (outs Variadic<HLO_TensorOrTuple>);
let builders = [OpBuilder<
"OpBuilder &, OperationState &state, ValueRange operands, "
"ValueRange init_values, DenseIntElementsAttr dimensions"
>];
let builders = [
OpBuilderDAG<(ins "ValueRange":$operands, "ValueRange":$init_values,
"DenseIntElementsAttr":$dimensions)>];
let extraClassDeclaration = [{
bool isFusibleWithConsumer() {
@ -657,18 +653,16 @@ def HLO_GetTupleElementOp: HLO_Op<"get_tuple_element", [NoSideEffect]>, BASE_HLO
let hasFolder = 1;
let builders = [OpBuilder<
"OpBuilder &builder, OperationState &results, "
"Value value, int32_t index">];
let builders = [
OpBuilderDAG<(ins "Value":$value, "int32_t":$index)>];
}
def HLO_TupleOp : HLO_Op<"tuple", [NoSideEffect]>, BASE_HLO_TupleOp {
let arguments = (ins Variadic<HLO_TensorOrTokenOrTuple>:$val);
let results = (outs HLO_Tuple);
let builders = [OpBuilder<
"OpBuilder &builder, OperationState &results, "
"ValueRange values">];
let builders = [
OpBuilderDAG<(ins "ValueRange":$values)>];
let hasCanonicalizer = 1;
}
@ -688,8 +682,8 @@ def HLO_CompareOp: HLO_Op<"compare", [NoSideEffect, SameTypeOperands,
let hasFolder = 1;
let builders = [
OpBuilder<"OpBuilder &builder, OperationState &result, Value lhs, Value rhs, "
"StringAttr comparison_direction, StringAttr compare_type = {}">,
OpBuilderDAG<(ins "Value":$lhs, "Value":$rhs,
"StringAttr":$comparison_direction, CArg<"StringAttr", "{}">:$compare_type)>,
];
let hasCustomHLOConverter = 1;
@ -1151,10 +1145,9 @@ def HLO_SortOp : HLO_Op<"sort", [RecursiveSideEffects, SameOperandsAndResultShap
let regions = (region SizedRegion<1>:$comparator);
let builders = [OpBuilder<
"OpBuilder &builder, OperationState &state, ValueRange operands, "
"int64_t dimension = -1, bool is_stable = false"
>];
let builders = [
OpBuilderDAG<(ins "ValueRange":$operands, CArg<"int64_t", "-1">:$dimension,
CArg<"bool", "false">:$is_stable)>];
// TODO(b/129422361): SortOp has special conversion logic to HLO.
let hasCustomHLOConverter = 1;

View File

@ -341,7 +341,8 @@ def HLO_StaticMemRefCastOp: Op<LHLO_Dialect, "static_memref_cast",
let arguments = (ins Arg<LHLO_Buffer, "", []>:$operand);
let results = (outs Res<LHLO_Buffer, "", []>:$result);
let builders = [OpBuilder<"MemRefType resultType, Value operand",
let builders = [
OpBuilderDAG<(ins "MemRefType":$resultType, "Value":$operand),
[{
$_state.addOperands(operand);
$_state.types.push_back(resultType);
@ -387,8 +388,9 @@ def HLO_DynamicMemRefCastOp: Op<LHLO_Dialect, "dynamic_memref_cast",
let results = (outs Res<LHLO_Buffer, "", []>:$result);
let builders = [
OpBuilder<"MemRefType resultType, Value operand, ValueRange sizes, "
"ValueRange strides", [{
OpBuilderDAG<(ins "MemRefType":$resultType, "Value":$operand,
"ValueRange":$sizes, "ValueRange":$strides),
[{
$_state.addOperands(operand);
$_state.addOperands(sizes);
$_state.addOperands(strides);
@ -813,7 +815,7 @@ def FusionOp : LHLO_Op<"fusion", [SingleBlockImplicitTerminator<"TerminatorOp">]
let skipDefaultBuilders = 1;
let builders = [
OpBuilder<"ArrayRef<NamedAttribute> attributes">
OpBuilderDAG<(ins "ArrayRef<NamedAttribute>":$attributes)>
];
}
@ -823,9 +825,9 @@ def TerminatorOp :
let description = [{
Terminator operation for the LHLO dialect.
}];
let builders = [OpBuilder<"ValueRange operands",
[{ build($_builder, $_state, llvm::None, operands, llvm::None); }]
>];
let builders = [
OpBuilderDAG<(ins "ValueRange":$operands),
[{ build($_builder, $_state, llvm::None, operands, llvm::None); }]>];
}
#endif // LHLO_OPS