Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions lib/Conversion/TorchToTosa/TorchToTosa.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@ static Value emitInclusiveScanByPowersOfTwo(Value running,

SmallVector<int64_t, 3> sliceStart(3, 0);
SmallVector<int64_t, 3> sliceSize = {outer, dimSize, inner};
Value sliceStartConstShape =
tosa::getTosaConstShape(rewriter, loc, sliceStart);
Value sliceSizeConstShape = tosa::getTosaConstShape(rewriter, loc, sliceSize);

for (int64_t offset = 1; offset < dimSize; offset <<= 1) {
SmallVector<int64_t, 6> padSpec = {0, 0, offset, 0, 0, 0};
Expand All @@ -79,11 +82,10 @@ static Value emitInclusiveScanByPowersOfTwo(Value running,
padShape, zeroConst)
.getResult();

Value shifted = tosa::SliceOp::create(
rewriter, loc, nkcTy, padded,
tosa::getTosaConstShape(rewriter, loc, sliceStart),
tosa::getTosaConstShape(rewriter, loc, sliceSize))
.getResult();
Value shifted =
tosa::SliceOp::create(rewriter, loc, nkcTy, padded,
sliceStartConstShape, sliceSizeConstShape)
.getResult();

running =
tosa::AddOp::create(rewriter, loc, nkcTy, running, shifted).getResult();
Expand Down
4 changes: 2 additions & 2 deletions test/Conversion/TorchToTosa/basic.mlir
Original file line number Diff line number Diff line change
Expand Up @@ -4445,10 +4445,10 @@ func.func @torch.aten.linear$f16(%arg0: !torch.vtensor<[2,4],f16>, %arg1: !torch
// CHECK: %[[RESHAPE_SHAPE:.*]] = tosa.const_shape {values = dense<[2, 3, 1]> : tensor<3xindex>} : () -> !tosa.shape<3>
// CHECK: %[[RESHAPED:.*]] = tosa.reshape %[[IN]], %[[RESHAPE_SHAPE]] : (tensor<2x3xf32>, !tosa.shape<3>) -> tensor<2x3x1xf32>
// CHECK: %[[ZERO:.*]] = "tosa.const"() <{values = dense<0.000000e+00> : tensor<1xf32>}> : () -> tensor<1xf32>
// CHECK-DAG: %[[SLICE_START:.*]] = tosa.const_shape {values = dense<0> : tensor<3xindex>} : () -> !tosa.shape<3>
// CHECK-DAG: %[[SLICE_SIZE:.*]] = tosa.const_shape {values = dense<[2, 3, 1]> : tensor<3xindex>} : () -> !tosa.shape<3>
// CHECK: %[[PAD_SPEC:.*]] = tosa.const_shape {values = dense<[0, 0, 1, 0, 0, 0]> : tensor<6xindex>} : () -> !tosa.shape<6>
// CHECK: %[[PADDED:.*]] = tosa.pad %[[RESHAPED]], %[[PAD_SPEC]], %[[ZERO]] : (tensor<2x3x1xf32>, !tosa.shape<6>, tensor<1xf32>) -> tensor<2x4x1xf32>
// CHECK: %[[SLICE_START:.*]] = tosa.const_shape {values = dense<0> : tensor<3xindex>} : () -> !tosa.shape<3>
// CHECK: %[[SLICE_SIZE:.*]] = tosa.const_shape {values = dense<[2, 3, 1]> : tensor<3xindex>} : () -> !tosa.shape<3>
// CHECK: %[[SLICE:.*]] = tosa.slice %[[PADDED]], %[[SLICE_START]], %[[SLICE_SIZE]] : (tensor<2x4x1xf32>, !tosa.shape<3>, !tosa.shape<3>) -> tensor<2x3x1xf32>
// CHECK: %[[ACC1:.*]] = tosa.add %[[RESHAPED]], %[[SLICE]] : (tensor<2x3x1xf32>, tensor<2x3x1xf32>) -> tensor<2x3x1xf32>
// CHECK: %[[ACC2:.*]] = tosa.add %[[ACC1]], %{{.*}} : (tensor<2x3x1xf32>, tensor<2x3x1xf32>) -> tensor<2x3x1xf32>
Expand Down
Loading