Skip to content
Open
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
4 changes: 4 additions & 0 deletions lib/Dialect/Torch/IR/TorchOps.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4147,6 +4147,10 @@ void AtenCatOp::getCanonicalizationPatterns(RewritePatternSet &patterns,
if (!operandTy || !operandTy.hasSizes())
return failure();
int64_t adim = dim < 0 ? dim + operandTy.getSizes().size() : dim;
bool is1DEmptyTensor =
operandTy.getSizes().size() == 1 && operandTy.getSizes()[0] == 0;
if (is1DEmptyTensor)
continue;
if (operandTy.getSizes()[adim] != 0)
filtered.push_back(operand);
}
Expand Down
10 changes: 10 additions & 0 deletions test/Dialect/Torch/canonicalize.mlir
Original file line number Diff line number Diff line change
Expand Up @@ -3242,6 +3242,16 @@ func.func @aten_cat_zero(%arg0 : !torch.vtensor<[4,5,6],f32>, %arg1 : !torch.vte

// -----

// CHECK-LABEL: @aten_cat_empty
func.func @aten_cat_empty(%arg0 : !torch.vtensor<[4,5,6],f32>, %arg1 : !torch.vtensor<[0],f32>) -> !torch.vtensor<[4,5,6],f32> {
// CHECK: return %arg0 : !torch.vtensor<[4,5,6],f32>
%list = torch.prim.ListConstruct %arg0, %arg1 : (!torch.vtensor<[4,5,6],f32>, !torch.vtensor<[0],f32>) -> !torch.list<vtensor>
%dim = torch.constant.int -2
%0 = torch.aten.cat %list, %dim : !torch.list<vtensor>, !torch.int -> !torch.vtensor<[4,5,6],f32>
return %0 : !torch.vtensor<[4,5,6],f32>
}
// -----

// CHECK-LABEL: @aten_tensor_scalar_lt
func.func @aten_tensor_scalar_lt() -> (!torch.vtensor<[4],i1>, !torch.vtensor<[4],i1>) {
// CHECK: %[[CST:.+]] = torch.vtensor.literal(dense<true> : tensor<4xi1>) : !torch.vtensor<[4],i1>
Expand Down