Skip to content

Commit 54828ce

Browse files
committed
[TOSA] Rename ReduceProd to ReduceProduct
This patch renames TOSA ReduceProd operator to ReduceProduct to align with the TOSA Spec 1.0 Signed-off-by: Tai Ly <[email protected]> Change-Id: I38b05ca70fcd4d1165932165758a22ce6c8da640
1 parent 48db4e8 commit 54828ce

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
@@ -1708,8 +1708,8 @@ def Tosa_ReduceMinOp : Tosa_InferTensorTypeOp<"reduce_min"> {
17081708
//===----------------------------------------------------------------------===//
17091709
// Operator: reduce_prod
17101710
//===----------------------------------------------------------------------===//
1711-
def Tosa_ReduceProdOp : Tosa_InferTensorTypeOp<"reduce_prod"> {
1712-
let summary = "Reduce Prod operator";
1711+
def Tosa_ReduceProductOp : Tosa_InferTensorTypeOp<"reduce_product"> {
1712+
let summary = "Reduce Product operator";
17131713

17141714
let description = [{
17151715
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
@@ -1050,10 +1050,10 @@ static TypedAttr createInitialValueForReduceOp(Operation *op, Type elementTy,
10501050
if (isa<tosa::ReduceSumOp>(op) && isa<IntegerType>(elementTy))
10511051
return rewriter.getIntegerAttr(elementTy, 0);
10521052

1053-
if (isa<tosa::ReduceProdOp>(op) && isa<FloatType>(elementTy))
1053+
if (isa<tosa::ReduceProductOp>(op) && isa<FloatType>(elementTy))
10541054
return rewriter.getFloatAttr(elementTy, 1.0);
10551055

1056-
if (isa<tosa::ReduceProdOp>(op) && isa<IntegerType>(elementTy))
1056+
if (isa<tosa::ReduceProductOp>(op) && isa<IntegerType>(elementTy))
10571057
return rewriter.getIntegerAttr(elementTy, 1);
10581058

10591059
if (isa<tosa::ReduceMinOp>(op) && isa<FloatType>(elementTy))
@@ -1107,11 +1107,11 @@ static Value createLinalgBodyCalculationForReduceOp(Operation *op,
11071107
return rewriter.create<arith::AddIOp>(loc, args);
11081108
}
11091109

1110-
if (isa<tosa::ReduceProdOp>(op) && isa<FloatType>(elementTy)) {
1110+
if (isa<tosa::ReduceProductOp>(op) && isa<FloatType>(elementTy)) {
11111111
return rewriter.create<arith::MulFOp>(loc, args);
11121112
}
11131113

1114-
if (isa<tosa::ReduceProdOp>(op) && isa<IntegerType>(elementTy)) {
1114+
if (isa<tosa::ReduceProductOp>(op) && isa<IntegerType>(elementTy)) {
11151115
return rewriter.create<arith::MulIOp>(loc, args);
11161116
}
11171117

@@ -2869,7 +2869,7 @@ void mlir::tosa::populateTosaToLinalgConversionPatterns(
28692869
ReduceConverter<tosa::ReduceMinOp>,
28702870
ReduceConverter<tosa::ReduceMaxOp>,
28712871
ReduceConverter<tosa::ReduceSumOp>,
2872-
ReduceConverter<tosa::ReduceProdOp>,
2872+
ReduceConverter<tosa::ReduceProductOp>,
28732873
ArgMaxConverter,
28742874
GatherConverter,
28752875
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
@@ -1745,7 +1745,7 @@ REDUCE_SHAPE_INFER(tosa::ReduceAllOp)
17451745
REDUCE_SHAPE_INFER(tosa::ReduceAnyOp)
17461746
REDUCE_SHAPE_INFER(tosa::ReduceMaxOp)
17471747
REDUCE_SHAPE_INFER(tosa::ReduceMinOp)
1748-
REDUCE_SHAPE_INFER(tosa::ReduceProdOp)
1748+
REDUCE_SHAPE_INFER(tosa::ReduceProductOp)
17491749
REDUCE_SHAPE_INFER(tosa::ReduceSumOp)
17501750
#undef REDUCE_SHAPE_INFER
17511751
COMPATIBLE_RETURN_TYPES(tosa::ConcatOp)
@@ -1805,7 +1805,7 @@ LogicalResult tosa::ReduceAllOp::verify() { return verifyReduceOp(*this); }
18051805
LogicalResult tosa::ReduceAnyOp::verify() { return verifyReduceOp(*this); }
18061806
LogicalResult tosa::ReduceMaxOp::verify() { return verifyReduceOp(*this); }
18071807
LogicalResult tosa::ReduceMinOp::verify() { return verifyReduceOp(*this); }
1808-
LogicalResult tosa::ReduceProdOp::verify() { return verifyReduceOp(*this); }
1808+
LogicalResult tosa::ReduceProductOp::verify() { return verifyReduceOp(*this); }
18091809
LogicalResult tosa::ReduceSumOp::verify() { return verifyReduceOp(*this); }
18101810

18111811
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
@@ -478,7 +478,7 @@ func.func @test_reduce_min(%arg0: tensor<13x21x3xf32>) -> tensor<1x21x3xf32> {
478478
func.func @test_reduce_product(%arg0: tensor<13x21x3xf32>) -> tensor<1x21x3xf32> {
479479
// CHECK: profiles: [ [pro_fp] ]
480480
// CHECK: extensions: [ [bf16] ]
481-
%0 = tosa.reduce_prod %arg0 {axis = 0 : i32} : (tensor<13x21x3xf32>) -> tensor<1x21x3xf32>
481+
%0 = tosa.reduce_product %arg0 {axis = 0 : i32} : (tensor<13x21x3xf32>) -> tensor<1x21x3xf32>
482482
return %0 : tensor<1x21x3xf32>
483483
}
484484

mlir/test/Dialect/Tosa/canonicalize.mlir

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

498498
// -----
499499

500-
// CHECK-LABEL: @reduce_prod_fold
501-
func.func @reduce_prod_fold(%arg0: tensor<?x1xf32>) -> tensor<?x1xf32> {
500+
// CHECK-LABEL: @reduce_product_fold
501+
func.func @reduce_product_fold(%arg0: tensor<?x1xf32>) -> tensor<?x1xf32> {
502502
// CHECK: return %arg0
503-
%0 = tosa.reduce_prod %arg0 {axis = 1 : i32}: (tensor<?x1xf32>) -> tensor<?x1xf32>
503+
%0 = tosa.reduce_product %arg0 {axis = 1 : i32}: (tensor<?x1xf32>) -> tensor<?x1xf32>
504504
return %0 : tensor<?x1xf32>
505505
}
506506

507507
// -----
508508

509-
// CHECK-LABEL: @reduce_prod_nofold
510-
func.func @reduce_prod_nofold(%arg0: tensor<?x1xf32>) -> tensor<?x1xf32> {
511-
// CHECK: tosa.reduce_prod
512-
%0 = tosa.reduce_prod %arg0 {axis = 0 : i32}: (tensor<?x1xf32>) -> tensor<?x1xf32>
509+
// CHECK-LABEL: @reduce_product_nofold
510+
func.func @reduce_product_nofold(%arg0: tensor<?x1xf32>) -> tensor<?x1xf32> {
511+
// CHECK: tosa.reduce_product
512+
%0 = tosa.reduce_product %arg0 {axis = 0 : i32}: (tensor<?x1xf32>) -> tensor<?x1xf32>
513513
return %0 : tensor<?x1xf32>
514514
}
515515

0 commit comments

Comments
 (0)