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

View File

@ -58,9 +58,8 @@ def HLO_ConstOp : HLO_Op<"constant",
HLO_StaticShapeTensor:$output HLO_StaticShapeTensor:$output
); );
let builders = [OpBuilder< let builders = [
"OpBuilder &builder, OperationState &result, Attribute value" OpBuilderDAG<(ins "Attribute":$value)>];
>];
let assemblyFormat = "attr-dict $value"; let assemblyFormat = "attr-dict $value";
@ -147,9 +146,8 @@ class HLO_UnaryElementwiseOp<string mnemonic, list<OpTrait> traits,
def HLO_AbsOp: HLO_UnaryElementwiseOp<"abs", def HLO_AbsOp: HLO_UnaryElementwiseOp<"abs",
[NoSideEffect, SameOperandsAndResultShape], [NoSideEffect, SameOperandsAndResultShape],
TensorOf<[HLO_SInt, AnyFloat, HLO_Complex]>>, BASE_HLO_AbsOp { TensorOf<[HLO_SInt, AnyFloat, HLO_Complex]>>, BASE_HLO_AbsOp {
let builders = [OpBuilder< let builders = [
"Value operand" OpBuilderDAG<(ins "Value":$operand)>];
>];
} }
def HLO_CbrtOp: HLO_UnaryElementwiseOp<"cbrt", def HLO_CbrtOp: HLO_UnaryElementwiseOp<"cbrt",
@ -162,9 +160,8 @@ def HLO_ConvertOp : HLO_UnaryElementwiseOp<
"convert", [NoSideEffect, SameOperandsAndResultShape], HLO_Tensor>, "convert", [NoSideEffect, SameOperandsAndResultShape], HLO_Tensor>,
BASE_HLO_ConvertOp { BASE_HLO_ConvertOp {
let builders = [OpBuilder< let builders = [
"Value operand, Type result_element_ty" OpBuilderDAG<(ins "Value":$operand, "Type":$result_element_ty)>];
>];
let hasFolder = 1; let hasFolder = 1;
@ -618,10 +615,9 @@ def HLO_ReduceOp: HLO_Op<"reduce", [
let results = (outs Variadic<HLO_TensorOrTuple>); let results = (outs Variadic<HLO_TensorOrTuple>);
let builders = [OpBuilder< let builders = [
"OpBuilder &, OperationState &state, ValueRange operands, " OpBuilderDAG<(ins "ValueRange":$operands, "ValueRange":$init_values,
"ValueRange init_values, DenseIntElementsAttr dimensions" "DenseIntElementsAttr":$dimensions)>];
>];
let extraClassDeclaration = [{ let extraClassDeclaration = [{
bool isFusibleWithConsumer() { bool isFusibleWithConsumer() {
@ -657,18 +653,16 @@ def HLO_GetTupleElementOp: HLO_Op<"get_tuple_element", [NoSideEffect]>, BASE_HLO
let hasFolder = 1; let hasFolder = 1;
let builders = [OpBuilder< let builders = [
"OpBuilder &builder, OperationState &results, " OpBuilderDAG<(ins "Value":$value, "int32_t":$index)>];
"Value value, int32_t index">];
} }
def HLO_TupleOp : HLO_Op<"tuple", [NoSideEffect]>, BASE_HLO_TupleOp { def HLO_TupleOp : HLO_Op<"tuple", [NoSideEffect]>, BASE_HLO_TupleOp {
let arguments = (ins Variadic<HLO_TensorOrTokenOrTuple>:$val); let arguments = (ins Variadic<HLO_TensorOrTokenOrTuple>:$val);
let results = (outs HLO_Tuple); let results = (outs HLO_Tuple);
let builders = [OpBuilder< let builders = [
"OpBuilder &builder, OperationState &results, " OpBuilderDAG<(ins "ValueRange":$values)>];
"ValueRange values">];
let hasCanonicalizer = 1; let hasCanonicalizer = 1;
} }
@ -688,8 +682,8 @@ def HLO_CompareOp: HLO_Op<"compare", [NoSideEffect, SameTypeOperands,
let hasFolder = 1; let hasFolder = 1;
let builders = [ let builders = [
OpBuilder<"OpBuilder &builder, OperationState &result, Value lhs, Value rhs, " OpBuilderDAG<(ins "Value":$lhs, "Value":$rhs,
"StringAttr comparison_direction, StringAttr compare_type = {}">, "StringAttr":$comparison_direction, CArg<"StringAttr", "{}">:$compare_type)>,
]; ];
let hasCustomHLOConverter = 1; let hasCustomHLOConverter = 1;
@ -1151,10 +1145,9 @@ def HLO_SortOp : HLO_Op<"sort", [RecursiveSideEffects, SameOperandsAndResultShap
let regions = (region SizedRegion<1>:$comparator); let regions = (region SizedRegion<1>:$comparator);
let builders = [OpBuilder< let builders = [
"OpBuilder &builder, OperationState &state, ValueRange operands, " OpBuilderDAG<(ins "ValueRange":$operands, CArg<"int64_t", "-1">:$dimension,
"int64_t dimension = -1, bool is_stable = false" CArg<"bool", "false">:$is_stable)>];
>];
// TODO(b/129422361): SortOp has special conversion logic to HLO. // TODO(b/129422361): SortOp has special conversion logic to HLO.
let hasCustomHLOConverter = 1; 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 arguments = (ins Arg<LHLO_Buffer, "", []>:$operand);
let results = (outs Res<LHLO_Buffer, "", []>:$result); 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.addOperands(operand);
$_state.types.push_back(resultType); $_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 results = (outs Res<LHLO_Buffer, "", []>:$result);
let builders = [ let builders = [
OpBuilder<"MemRefType resultType, Value operand, ValueRange sizes, " OpBuilderDAG<(ins "MemRefType":$resultType, "Value":$operand,
"ValueRange strides", [{ "ValueRange":$sizes, "ValueRange":$strides),
[{
$_state.addOperands(operand); $_state.addOperands(operand);
$_state.addOperands(sizes); $_state.addOperands(sizes);
$_state.addOperands(strides); $_state.addOperands(strides);
@ -813,7 +815,7 @@ def FusionOp : LHLO_Op<"fusion", [SingleBlockImplicitTerminator<"TerminatorOp">]
let skipDefaultBuilders = 1; let skipDefaultBuilders = 1;
let builders = [ let builders = [
OpBuilder<"ArrayRef<NamedAttribute> attributes"> OpBuilderDAG<(ins "ArrayRef<NamedAttribute>":$attributes)>
]; ];
} }
@ -823,9 +825,9 @@ def TerminatorOp :
let description = [{ let description = [{
Terminator operation for the LHLO dialect. Terminator operation for the LHLO dialect.
}]; }];
let builders = [OpBuilder<"ValueRange operands", let builders = [
[{ build($_builder, $_state, llvm::None, operands, llvm::None); }] OpBuilderDAG<(ins "ValueRange":$operands),
>]; [{ build($_builder, $_state, llvm::None, operands, llvm::None); }]>];
} }
#endif // LHLO_OPS #endif // LHLO_OPS