Skip to content

Commit

Permalink
[TTIR] Remove TTIR operand_constraints
Browse files Browse the repository at this point in the history
  • Loading branch information
jserbedzijaTT committed Dec 9, 2024
1 parent fecec9c commit aeb4de0
Show file tree
Hide file tree
Showing 175 changed files with 529 additions and 1,016 deletions.
94 changes: 34 additions & 60 deletions include/ttmlir/Dialect/TTIR/IR/TTIROps.td
Original file line number Diff line number Diff line change
Expand Up @@ -185,8 +185,7 @@ class TTIR_ElementwiseOp<string mnemonic, list<Trait> traits = []> :
}];

let arguments = (ins Variadic<AnyRankedTensor>:$inputs,
Variadic<AnyRankedTensor>:$outputs,
TT_OperandConstraintArrayAttr:$operand_constraints);
Variadic<AnyRankedTensor>:$outputs);
let results = (outs Variadic<AnyRankedTensor>:$results);
}

Expand All @@ -199,9 +198,9 @@ class TTIR_ElementwiseTernaryOp<string mnemonic, list<Trait> traits = []> :

let builders =
[
OpBuilder<(ins "Value": $first, "Value": $second, "Value": $third, "Value": $out, "ArrayAttr": $operand_constraints),
OpBuilder<(ins "Value": $first, "Value": $second, "Value": $third, "Value": $out),
[{
build($_builder, $_state, {out.getType()}, {first, second, third}, out, operand_constraints);
build($_builder, $_state, {out.getType()}, {first, second, third}, out);
}]>
];
}
Expand All @@ -222,9 +221,9 @@ class TTIR_ElementwiseUnaryOp<string mnemonic, list<Trait> traits = []> :

let builders =
[
OpBuilder<(ins "Value": $in, "Value": $out, "ArrayAttr": $operand_constraints),
OpBuilder<(ins "Value": $in, "Value": $out),
[{
build($_builder, $_state, {out.getType()}, in, out, operand_constraints);
build($_builder, $_state, {out.getType()}, in, out);
}]>
];
}
Expand Down Expand Up @@ -406,14 +405,13 @@ class TTIR_ElementwiseUnaryWithFloatParameterOp<string mnemonic, list<Trait> tra

let arguments = (ins Variadic<AnyRankedTensor>:$inputs,
Variadic<AnyRankedTensor>:$outputs,
F32Attr:$parameter,
TT_OperandConstraintArrayAttr:$operand_constraints);
F32Attr:$parameter);

let builders =
[
OpBuilder<(ins "Value": $in, "Value": $out, "FloatAttr":$parameter, "ArrayAttr": $operand_constraints),
OpBuilder<(ins "Value": $in, "Value": $out, "FloatAttr":$parameter),
[{
build($_builder, $_state, {out.getType()}, {in}, {out}, parameter, operand_constraints);
build($_builder, $_state, {out.getType()}, {in}, {out}, parameter);
}]>
];
}
Expand Down Expand Up @@ -450,9 +448,9 @@ class TTIR_ElementwiseBinaryOp<string mnemonic, list<Trait> traits = []> :

let builders =
[
OpBuilder<(ins "Value": $lhs, "Value": $rhs, "Value": $out, "ArrayAttr": $operand_constraints),
OpBuilder<(ins "Value": $lhs, "Value": $rhs, "Value": $out),
[{
build($_builder, $_state, {out.getType()}, {lhs, rhs}, out, operand_constraints);
build($_builder, $_state, {out.getType()}, {lhs, rhs}, out);
}]>
];
}
Expand Down Expand Up @@ -566,8 +564,7 @@ class TTIR_ReductionOp<string mnemonic, list<Trait> traits = []> :
let arguments = (ins AnyRankedTensor:$input,
AnyRankedTensor:$output,
BoolAttr:$keep_dim,
OptionalAttr<I32ArrayAttr>:$dim_arg,
TT_OperandConstraintArrayAttr:$operand_constraints);
OptionalAttr<I32ArrayAttr>:$dim_arg);

let results = (outs AnyRankedTensor:$result);

Expand Down Expand Up @@ -634,8 +631,7 @@ def TTIR_EmbeddingOp : TTIR_DPSOp<"embedding"> {

let arguments = (ins AnyRankedTensor:$input,
AnyRankedTensor:$weight,
AnyRankedTensor:$output,
TT_OperandConstraintArrayAttr:$operand_constraints);
AnyRankedTensor:$output);

let results = (outs AnyRankedTensor:$result);

Expand All @@ -654,8 +650,7 @@ def TTIR_SoftmaxOp : TTIR_DPSOp<"softmax"> {

let arguments = (ins AnyRankedTensor:$input,
AnyRankedTensor:$output,
SI32Attr:$dimension,
TT_OperandConstraintArrayAttr:$operand_constraints);
SI32Attr:$dimension);

let results = (outs AnyRankedTensor:$result);

Expand All @@ -675,8 +670,7 @@ def TTIR_TransposeOp : TTIR_DPSOp<"transpose"> {
let arguments = (ins AnyRankedTensor:$input,
AnyRankedTensor:$output,
SI32Attr:$dim0,
SI32Attr:$dim1,
TT_OperandConstraintArrayAttr:$operand_constraints);
SI32Attr:$dim1);

let results = (outs AnyRankedTensor:$result);

Expand All @@ -695,8 +689,7 @@ def TTIR_ConcatOp : TTIR_DPSOp<"concat"> {

let arguments = (ins Variadic<AnyRankedTensor>:$inputs,
AnyRankedTensor:$output,
SI32Attr:$dim,
TT_OperandConstraintArrayAttr:$operand_constraints);
SI32Attr:$dim);

let results = (outs AnyRankedTensor:$result);

Expand Down Expand Up @@ -756,8 +749,7 @@ def TTIR_BroadcastOp : TTIR_DPSOp<"broadcast"> {

let arguments = (ins AnyRankedTensor:$input,
AnyRankedTensor:$output,
I64ArrayAttr:$dimension,
TT_OperandConstraintArrayAttr:$operand_constraints);
I64ArrayAttr:$dimension);

let results = (outs AnyRankedTensor:$result);

Expand All @@ -784,8 +776,7 @@ def TTIR_Conv2dOp : TTIR_DPSOp<"conv2d"> {
SI32Attr:$padding_left,
SI32Attr:$padding_right,
SI32Attr:$padding_top,
SI32Attr:$padding_bottom,
TT_OperandConstraintArrayAttr:$operand_constraints);
SI32Attr:$padding_bottom);

let results = (outs AnyRankedTensor:$result);

Expand Down Expand Up @@ -818,8 +809,7 @@ def TTIR_ConvolutionOp : TTIR_DPSOp<"convolution"> {
DenseBoolArrayAttr:$window_reversal,
TTIR_ConvolutionLayoutAttr:$convolution_layout,
ConfinedAttr<I64Attr, [IntPositive]>:$feature_group_count,
ConfinedAttr<I64Attr, [IntPositive]>:$batch_group_count,
TT_OperandConstraintArrayAttr:$operand_constraints
ConfinedAttr<I64Attr, [IntPositive]>:$batch_group_count
);

let results = (outs AnyRankedTensor);
Expand All @@ -846,8 +836,7 @@ def TTIR_GatherOp: TTIR_DPSOp<"gather"> {
DenseI64ArrayAttr:$start_index_map,
SI64Attr:$index_vector_dim,
DenseI64ArrayAttr:$slice_sizes,
BoolAttr:$indices_are_sorted,
TT_OperandConstraintArrayAttr:$operand_constraints);
BoolAttr:$indices_are_sorted);
let results = (outs AnyRankedTensor:$result);
let extraClassDeclaration = [{
MutableOperandRange getDpsInitsMutable() { return getOutputMutable(); }
Expand All @@ -868,8 +857,7 @@ def TTIR_PoolingOp : TTIR_DPSOp<"pooling", [AttrSizedOperandSegments]> {
DenseI64ArrayAttr:$window_strides,
DenseI64ArrayAttr:$base_dilations,
DenseI64ArrayAttr:$window_dilations,
DenseI64ArrayAttr:$padding,
TT_OperandConstraintArrayAttr:$operand_constraints
DenseI64ArrayAttr:$padding
);

let results = (outs Variadic<AnyRankedTensor>);
Expand All @@ -895,8 +883,7 @@ def TTIR_MaxPool2dOp : TTIR_DPSOp<"max_pool2d"> {
SI32Attr:$padding_left,
SI32Attr:$padding_right,
SI32Attr:$padding_top,
SI32Attr:$padding_bottom,
TT_OperandConstraintArrayAttr:$operand_constraints);
SI32Attr:$padding_bottom);

let results = (outs AnyRankedTensor:$result);

Expand All @@ -915,8 +902,7 @@ def TTIR_ReshapeOp: TTIR_DPSOp<"reshape"> {

let arguments = (ins AnyRankedTensor:$input,
AnyRankedTensor:$output,
I32ArrayAttr:$shape,
TT_OperandConstraintArrayAttr:$operand_constraints);
I32ArrayAttr:$shape);

let results = (outs AnyRankedTensor:$result);

Expand All @@ -941,8 +927,7 @@ def TTIR_SliceOp: TTIR_DPSOp<"slice"> {
AnyRankedTensor:$output,
I32ArrayAttr:$begins,
I32ArrayAttr:$ends,
I32ArrayAttr:$step,
TT_OperandConstraintArrayAttr:$operand_constraints);
I32ArrayAttr:$step);

let results = (outs AnyRankedTensor:$result);

Expand All @@ -968,8 +953,7 @@ def TTIR_SelectOp: TTIR_DPSOp<"select"> {
SI32Attr:$dim,
SI32Attr:$begin,
SI32Attr:$length,
DefaultValuedOptionalAttr<SI32Attr, "0">:$stride,
TT_OperandConstraintArrayAttr:$operand_constraints);
DefaultValuedOptionalAttr<SI32Attr, "0">:$stride);

let results = (outs AnyRankedTensor:$result);

Expand All @@ -994,8 +978,7 @@ def TTIR_IndexOp: TTIR_DPSOp<"index"> {
I32Attr:$dim,
I32Attr:$begin,
I32Attr:$end,
I32Attr:$step,
TT_OperandConstraintArrayAttr:$operand_constraints);
I32Attr:$step);

let results = (outs AnyRankedTensor:$result);

Expand All @@ -1015,8 +998,7 @@ def TTIR_SqueezeOp : TTIR_DPSOp<"squeeze"> {

let arguments = (ins AnyRankedTensor:$input,
AnyRankedTensor:$output,
SI32Attr:$dim,
TT_OperandConstraintArrayAttr:$operand_constraints);
SI32Attr:$dim);

let results = (outs AnyRankedTensor:$result);

Expand All @@ -1035,8 +1017,7 @@ def TTIR_UnsqueezeOp : TTIR_DPSOp<"unsqueeze"> {

let arguments = (ins AnyRankedTensor:$input,
AnyRankedTensor:$output,
SI32Attr:$dim,
TT_OperandConstraintArrayAttr:$operand_constraints);
SI32Attr:$dim);

let results = (outs AnyRankedTensor:$result);

Expand Down Expand Up @@ -1064,8 +1045,7 @@ def TTIR_ClampOp : TTIR_DPSOp<"clamp"> {
let arguments = (ins AnyRankedTensor:$input,
AnyRankedTensor:$output,
F32Attr:$min,
F32Attr:$max,
TT_OperandConstraintArrayAttr:$operand_constraints);
F32Attr:$max);

let extraClassDeclaration = [{
MutableOperandRange getDpsInitsMutable() { return getOutputMutable(); }
Expand Down Expand Up @@ -1151,8 +1131,7 @@ def TTIR_FillOp : TTIR_DPSOp<"fill", [AllShapesMatch<["value", "result"]>]> {
}];

let arguments = (ins AnyRankedTensor:$output,
ElementsAttr:$value,
TT_OperandConstraintArrayAttr:$operand_constraints);
ElementsAttr:$value);

let results = (outs AnyRankedTensor:$result);

Expand All @@ -1177,8 +1156,7 @@ def TTIR_LinearOp : TTIR_DPSOp<"linear"> {
let arguments = (ins AnyRankedTensor:$a,
AnyRankedTensor:$b,
Optional<AnyRankedTensor>:$bias,
AnyRankedTensor:$output,
TT_OperandConstraintArrayAttr:$operand_constraints);
AnyRankedTensor:$output);

let results = (outs AnyRankedTensor:$result);

Expand All @@ -1198,8 +1176,7 @@ def TTIR_MatmulOp : TTIR_DPSOp<"matmul"> {

let arguments = (ins AnyRankedTensor:$a,
AnyRankedTensor:$b,
AnyRankedTensor:$output,
TT_OperandConstraintArrayAttr:$operand_constraints);
AnyRankedTensor:$output);

let results = (outs AnyRankedTensor:$result);

Expand Down Expand Up @@ -1322,8 +1299,7 @@ def TTIR_ScatterOp: TTIR_DPSOp<"scatter"> {
I32Attr:$index_vector_dim,
BoolAttr:$indices_are_sorted,
BoolAttr:$unique_indices,
AnyRankedTensor:$output,
TT_OperandConstraintArrayAttr:$operand_constraints);
AnyRankedTensor:$output);

let regions = (region SizedRegion<1>:$update_computation);

Expand Down Expand Up @@ -1351,8 +1327,7 @@ def TTIR_KernelOp : TTIR_DPSOp<"kernel", [AttrSizedOperandSegments]> {
let arguments = (ins FlatSymbolRefAttr:$op,
FlatSymbolRefAttr:$kind,
Variadic<AnyRankedTensorOrMemRef>:$inputs,
Variadic<AnyRankedTensorOrMemRef>:$outputs,
TT_OperandConstraintArrayAttr:$operand_constraints);
Variadic<AnyRankedTensorOrMemRef>:$outputs);
let results = (outs Variadic<AnyRankedTensorOrMemRef>:$results);
}

Expand All @@ -1377,8 +1352,7 @@ def TTIR_AllGatherOp : TTIR_DPSOp<"all_gather"> {

let arguments = (ins AnyRankedTensor:$input,
AnyRankedTensor:$output,
SI32Attr:$dim,
TT_OperandConstraintArrayAttr:$operand_constraints);
SI32Attr:$dim);

let results = (outs AnyRankedTensor:$result);

Expand Down
10 changes: 0 additions & 10 deletions include/ttmlir/Dialect/TTIR/IR/TTIROpsInterfaces.td
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,6 @@ include "ttmlir/Dialect/TT/IR/TTOpsTypes.td"
def TTIROpInterface : OpInterface<"TTIROp"> {
let cppNamespace = "::mlir::tt::ttir";
let methods = [
InterfaceMethod<
/*desc=*/[{
Return the constraints on the operands of this operation.
}],
/*retTy=*/"::mlir::ArrayAttr",
/*methodName=*/"getOperandConstraints",
/*args=*/(ins),
/*methodBody=*/"",
/*defaultImplementation=*/""
>,
InterfaceMethod<
/*desc=*/[{
Get the device of the current scope.
Expand Down
Loading

0 comments on commit aeb4de0

Please sign in to comment.