Skip to content

MLIR, TOSA: Zero-size tensor crashes tosa-to-tensor #63212

@mgehre-amd

Description

@mgehre-amd
func.func @test_reshape_downrank_zero(%arg0: tensor<6x1x0xf32>) -> tensor<6x0xf32> {
  %0 = "tosa.reshape"(%arg0) {new_shape = array<i64: 6, 0>} : (tensor<6x1x0xf32>) -> tensor<6x0xf32>
  return %0 : tensor<6x0xf32>
}

run with
mlir-opt test.mlir --tosa-to-tensor
crashes in createReassociationMapsForCollapse due to

srcSize *= srcShape[currSrcDim];

being out of bounds.

I'm not sure how the correct tensor IR would look like for this case.
Tensors where a dimension have zero size seems to be allowed by the TOSA spec.

Metadata

Metadata

Assignees

Labels

crashPrefer [crash-on-valid] or [crash-on-invalid]mlir:tosa

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions