Skip to content

Commit 177ede2

Browse files
authored
[mlir][tosa] Rename ReduceProd to ReduceProduct (llvm#128751)
This patch renames TOSA ReduceProd operator to ReduceProduct to align with the TOSA Spec 1.0 Signed-off-by: Tai Ly <[email protected]>
1 parent ca5bb23 commit 177ede2

File tree

15 files changed

+40
-40
lines changed

15 files changed

+40
-40
lines changed

mlir/include/mlir/Dialect/Tosa/IR/TosaOps.td

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1740,8 +1740,8 @@ def Tosa_ReduceMinOp : Tosa_InferTensorTypeOp<"reduce_min"> {
17401740
//===----------------------------------------------------------------------===//
17411741
// Operator: reduce_prod
17421742
//===----------------------------------------------------------------------===//
1743-
def Tosa_ReduceProdOp : Tosa_InferTensorTypeOp<"reduce_prod"> {
1744-
let summary = "Reduce Prod operator";
1743+
def Tosa_ReduceProductOp : Tosa_InferTensorTypeOp<"reduce_product"> {
1744+
let summary = "Reduce Product operator";
17451745

17461746
let description = [{
17471747
Reduce a tensor along the given axis by computing the product of the axis.

mlir/lib/Conversion/TosaToLinalg/TosaToLinalg.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1055,10 +1055,10 @@ static TypedAttr createInitialValueForReduceOp(Operation *op, Type elementTy,
10551055
if (isa<tosa::ReduceSumOp>(op) && isa<IntegerType>(elementTy))
10561056
return rewriter.getIntegerAttr(elementTy, 0);
10571057

1058-
if (isa<tosa::ReduceProdOp>(op) && isa<FloatType>(elementTy))
1058+
if (isa<tosa::ReduceProductOp>(op) && isa<FloatType>(elementTy))
10591059
return rewriter.getFloatAttr(elementTy, 1.0);
10601060

1061-
if (isa<tosa::ReduceProdOp>(op) && isa<IntegerType>(elementTy))
1061+
if (isa<tosa::ReduceProductOp>(op) && isa<IntegerType>(elementTy))
10621062
return rewriter.getIntegerAttr(elementTy, 1);
10631063

10641064
if (isa<tosa::ReduceMinOp>(op) && isa<FloatType>(elementTy))
@@ -1112,11 +1112,11 @@ static Value createLinalgBodyCalculationForReduceOp(Operation *op,
11121112
return rewriter.create<arith::AddIOp>(loc, args);
11131113
}
11141114

1115-
if (isa<tosa::ReduceProdOp>(op) && isa<FloatType>(elementTy)) {
1115+
if (isa<tosa::ReduceProductOp>(op) && isa<FloatType>(elementTy)) {
11161116
return rewriter.create<arith::MulFOp>(loc, args);
11171117
}
11181118

1119-
if (isa<tosa::ReduceProdOp>(op) && isa<IntegerType>(elementTy)) {
1119+
if (isa<tosa::ReduceProductOp>(op) && isa<IntegerType>(elementTy)) {
11201120
return rewriter.create<arith::MulIOp>(loc, args);
11211121
}
11221122

@@ -2874,7 +2874,7 @@ void mlir::tosa::populateTosaToLinalgConversionPatterns(
28742874
ReduceConverter<tosa::ReduceMinOp>,
28752875
ReduceConverter<tosa::ReduceMaxOp>,
28762876
ReduceConverter<tosa::ReduceSumOp>,
2877-
ReduceConverter<tosa::ReduceProdOp>,
2877+
ReduceConverter<tosa::ReduceProductOp>,
28782878
ArgMaxConverter,
28792879
GatherConverter,
28802880
RescaleConverter,

mlir/lib/Dialect/Tosa/IR/TosaCanonicalizations.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -949,7 +949,7 @@ REDUCE_FOLDER(ReduceAllOp)
949949
REDUCE_FOLDER(ReduceAnyOp)
950950
REDUCE_FOLDER(ReduceMaxOp)
951951
REDUCE_FOLDER(ReduceMinOp)
952-
REDUCE_FOLDER(ReduceProdOp)
952+
REDUCE_FOLDER(ReduceProductOp)
953953
REDUCE_FOLDER(ReduceSumOp)
954954
#undef REDUCE_FOLDER
955955

mlir/lib/Dialect/Tosa/IR/TosaOps.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1832,7 +1832,7 @@ REDUCE_SHAPE_INFER(tosa::ReduceAllOp)
18321832
REDUCE_SHAPE_INFER(tosa::ReduceAnyOp)
18331833
REDUCE_SHAPE_INFER(tosa::ReduceMaxOp)
18341834
REDUCE_SHAPE_INFER(tosa::ReduceMinOp)
1835-
REDUCE_SHAPE_INFER(tosa::ReduceProdOp)
1835+
REDUCE_SHAPE_INFER(tosa::ReduceProductOp)
18361836
REDUCE_SHAPE_INFER(tosa::ReduceSumOp)
18371837
#undef REDUCE_SHAPE_INFER
18381838
COMPATIBLE_RETURN_TYPES(tosa::ConcatOp)
@@ -1892,7 +1892,7 @@ LogicalResult tosa::ReduceAllOp::verify() { return verifyReduceOp(*this); }
18921892
LogicalResult tosa::ReduceAnyOp::verify() { return verifyReduceOp(*this); }
18931893
LogicalResult tosa::ReduceMaxOp::verify() { return verifyReduceOp(*this); }
18941894
LogicalResult tosa::ReduceMinOp::verify() { return verifyReduceOp(*this); }
1895-
LogicalResult tosa::ReduceProdOp::verify() { return verifyReduceOp(*this); }
1895+
LogicalResult tosa::ReduceProductOp::verify() { return verifyReduceOp(*this); }
18961896
LogicalResult tosa::ReduceSumOp::verify() { return verifyReduceOp(*this); }
18971897

18981898
static LogicalResult NAryInferReturnTypes(

mlir/lib/Dialect/Tosa/Transforms/TosaFolders.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -408,7 +408,7 @@ void mlir::tosa::populateTosaConstantReduction(MLIRContext *ctx,
408408
ctx, aggressiveReduceConstant);
409409
patterns.add<ReduceConstantOptimization<ReduceMinOp>>(
410410
ctx, aggressiveReduceConstant);
411-
patterns.add<ReduceConstantOptimization<ReduceProdOp>>(
411+
patterns.add<ReduceConstantOptimization<ReduceProductOp>>(
412412
ctx, aggressiveReduceConstant);
413413
patterns.add<ReduceConstantOptimization<ReduceSumOp>>(
414414
ctx, aggressiveReduceConstant);

mlir/lib/Dialect/Tosa/Transforms/TosaProfileCompliance.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ LogicalResult ProfileInfoDepot::populatationDispatch(Operation *op) {
272272
POPULATE_PROFILE_INFO_COMMON(ReduceAny)
273273
POPULATE_PROFILE_INFO_COMMON(ReduceMax)
274274
POPULATE_PROFILE_INFO_COMMON(ReduceMin)
275-
POPULATE_PROFILE_INFO_COMMON(ReduceProd)
275+
POPULATE_PROFILE_INFO_COMMON(ReduceProduct)
276276
POPULATE_PROFILE_INFO_COMMON(ReduceSum)
277277
POPULATE_PROFILE_INFO_COMMON(Equal)
278278
POPULATE_PROFILE_INFO_COMMON(GreaterEqual)

mlir/lib/Dialect/Tosa/Transforms/TosaValidation.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ struct TosaValidation : public tosa::impl::TosaValidationBase<TosaValidation> {
220220
CHECK_RANKS_FOR(ReduceAny);
221221
CHECK_RANKS_FOR(ReduceMax);
222222
CHECK_RANKS_FOR(ReduceMin);
223-
CHECK_RANKS_FOR(ReduceProd);
223+
CHECK_RANKS_FOR(ReduceProduct);
224224
CHECK_RANKS_FOR(ReduceSum);
225225
// all data layout operators:
226226
CHECK_RANKS_FOR(Concat);

mlir/test/Conversion/TosaToLinalg/tosa-to-linalg.mlir

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -951,7 +951,7 @@ func.func @reduce_float(%arg0: tensor<5x4xf32>) -> () {
951951
// CHECK: linalg.fill
952952
// CHECK: linalg.reduce
953953
// CHECK: arith.mulf
954-
%2 = tosa.reduce_prod %arg0 {axis = 0 : i32} : (tensor<5x4xf32>) -> tensor<1x4xf32>
954+
%2 = tosa.reduce_product %arg0 {axis = 0 : i32} : (tensor<5x4xf32>) -> tensor<1x4xf32>
955955

956956
// CHECK: arith.constant 3.40282347E+38 : f32
957957
// CHECK: linalg.fill
@@ -1027,7 +1027,7 @@ func.func @reduce_float_dyn_nonzero_batch(%arg0: tensor<5x?x4xf32>) -> () {
10271027
// CHECK: %[[DIM_1:.+]] = tensor.dim %[[REDUCE]], %[[C1_0]] : tensor<5x?xf32>
10281028
// CHECK: %[[C1_2:.+]] = arith.constant 1 : index
10291029
// CHECK: tensor.expand_shape %[[REDUCE]] {{\[}}[0], [1, 2]] output_shape [5, %[[DIM_1]], 1] : tensor<5x?xf32> into tensor<5x?x1xf32>
1030-
%0 = tosa.reduce_prod %arg0 {axis = 2 : i32} : (tensor<5x?x4xf32>) -> tensor<5x?x1xf32>
1030+
%0 = tosa.reduce_product %arg0 {axis = 2 : i32} : (tensor<5x?x4xf32>) -> tensor<5x?x1xf32>
10311031
return
10321032
}
10331033

@@ -1085,7 +1085,7 @@ func.func @reduce_int(%arg0: tensor<5x4xi32>) -> () {
10851085
// CHECK: linalg.fill
10861086
// CHECK: linalg.reduce
10871087
// CHECK: arith.muli
1088-
%2 = tosa.reduce_prod %arg0 {axis = 0 : i32} : (tensor<5x4xi32>) -> tensor<1x4xi32>
1088+
%2 = tosa.reduce_product %arg0 {axis = 0 : i32} : (tensor<5x4xi32>) -> tensor<1x4xi32>
10891089

10901090
// CHECK: arith.constant 2147483647 : i32
10911091
// CHECK: linalg.fill

mlir/test/Dialect/Tosa/availability.mlir

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -486,7 +486,7 @@ func.func @test_reduce_min(%arg0: tensor<13x21x3xf32>) -> tensor<1x21x3xf32> {
486486
func.func @test_reduce_product(%arg0: tensor<13x21x3xf32>) -> tensor<1x21x3xf32> {
487487
// CHECK: profiles: [ [pro_fp] ]
488488
// CHECK: extensions: [ [bf16] ]
489-
%0 = tosa.reduce_prod %arg0 {axis = 0 : i32} : (tensor<13x21x3xf32>) -> tensor<1x21x3xf32>
489+
%0 = tosa.reduce_product %arg0 {axis = 0 : i32} : (tensor<13x21x3xf32>) -> tensor<1x21x3xf32>
490490
return %0 : tensor<1x21x3xf32>
491491
}
492492

mlir/test/Dialect/Tosa/canonicalize.mlir

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -501,19 +501,19 @@ func.func @reduce_min_nofold(%arg0: tensor<?x1xf32>) -> tensor<?x1xf32> {
501501

502502
// -----
503503

504-
// CHECK-LABEL: @reduce_prod_fold
505-
func.func @reduce_prod_fold(%arg0: tensor<?x1xf32>) -> tensor<?x1xf32> {
504+
// CHECK-LABEL: @reduce_product_fold
505+
func.func @reduce_product_fold(%arg0: tensor<?x1xf32>) -> tensor<?x1xf32> {
506506
// CHECK: return %arg0
507-
%0 = tosa.reduce_prod %arg0 {axis = 1 : i32}: (tensor<?x1xf32>) -> tensor<?x1xf32>
507+
%0 = tosa.reduce_product %arg0 {axis = 1 : i32}: (tensor<?x1xf32>) -> tensor<?x1xf32>
508508
return %0 : tensor<?x1xf32>
509509
}
510510

511511
// -----
512512

513-
// CHECK-LABEL: @reduce_prod_nofold
514-
func.func @reduce_prod_nofold(%arg0: tensor<?x1xf32>) -> tensor<?x1xf32> {
515-
// CHECK: tosa.reduce_prod
516-
%0 = tosa.reduce_prod %arg0 {axis = 0 : i32}: (tensor<?x1xf32>) -> tensor<?x1xf32>
513+
// CHECK-LABEL: @reduce_product_nofold
514+
func.func @reduce_product_nofold(%arg0: tensor<?x1xf32>) -> tensor<?x1xf32> {
515+
// CHECK: tosa.reduce_product
516+
%0 = tosa.reduce_product %arg0 {axis = 0 : i32}: (tensor<?x1xf32>) -> tensor<?x1xf32>
517517
return %0 : tensor<?x1xf32>
518518
}
519519

0 commit comments

Comments
 (0)