Skip to content

PackConstants can produce zero-sized buffers #23926

@schuermans-roofline

Description

@schuermans-roofline

What happened?

Under certain circumstances, the PackConstants pass can produce buffers with zero size. Those zero-sized buffers can cause downstream passes or the runtime to fail.

Steps to reproduce your issue

  1. Create a MLIR file small_constant_for_reproducer.mlir with the following contents:
util.func public @smallConstantForReproducer() -> (!stream.resource<constant>, !stream.timepoint) {
  %c256 = arith.constant 256 : index
  %0:2 = stream.resource.constants :
    !stream.resource<constant>{%c256} = dense<42> : tensor<64xi32>
    => !stream.timepoint
  util.return %0#0, %0#1 : !stream.resource<constant>, !stream.timepoint
}
  1. Run
iree-compile --iree-hal-target-backends=llvm-cpu --iree-llvmcpu-target-triple=x86_64-linux-gnu --iree-llvmcpu-target-cpu=host --iree-stream-resource-max-allocation-size=128 -o small_constant_for_reproducer.vmfb -dump-compilation-phases-to=dump small_constant_for_reproducer.mlir

The important point is here that the limit (128) provided on the command line is less than the size of the first constant in the input MLIR.
3. Check first line of dump/small_constant_for_reproducer.7.stream.mlir:

#composite_of_0b = #util.composite<0xi8, []>

What component(s) does this issue relate to?

Compiler

Version information

7703cd6

Additional context

I have a suggested fix in a PR: #23927.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug 🐞Something isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions