Skip to content

[Codegen][CPU]InsertBatchDimForBatchlessConv drops the user lowering_config from tuning specs, so batch-1 convs are left untiled #25190

Open

Description

@prakanth97

On LLVMCPU, a tuning-spec config (--iree-codegen-tuning-spec-path / --iree-codegen-transform-dialect-library) that targets a conv with batch 1 is attached and then discarded. Compilation then fails:

error: One or more operations with large vector sizes (16384 bytes) were found:
  %cst = arith.constant dense<0.000000e+00> : vector<1x56x56x64xf32>

The same kind of spec works for batch 2.

Reproducer

conv_n1.mlir:

func.func @conv_n1(%input: tensor<1x58x58x64xf32>, %filter: tensor<3x3x64x64xf32>) -> tensor<1x56x56x64xf32> {
  %cst = arith.constant 0.0 : f32
  %empty = tensor.empty() : tensor<1x56x56x64xf32>
  %fill = linalg.fill ins(%cst : f32) outs(%empty : tensor<1x56x56x64xf32>) -> tensor<1x56x56x64xf32>
  %conv = linalg.conv_2d_nhwc_hwcf {dilations = dense<1> : tensor<2xi64>, strides = dense<1> : tensor<2xi64>}
      ins(%input, %filter : tensor<1x58x58x64xf32>, tensor<3x3x64x64xf32>)
      outs(%fill : tensor<1x56x56x64xf32>) -> tensor<1x56x56x64xf32>
  return %conv : tensor<1x56x56x64xf32>
}

spec.mlir:

module attributes {transform.with_named_sequence} {
  // Matches the convolution after unit-dim folding: a 6-loop generic
  // (oh, ow, oc, kh, kw, ic) with no batch dimension.
  transform.named_sequence @match_conv(%root: !transform.any_op {transform.readonly}) -> !transform.any_op {
    %batch, %out_img, %out_ch, %filt, %in_ch, %depth, %strides, %dilations =
      transform.iree.match.convolution %root,
        lhs_type = f32, rhs_type = f32, output_type = f32 :
        !transform.any_op -> !transform.param<i64>
    transform.iree.match.dims_equal %batch, [] : !transform.param<i64>
    transform.iree.match.dims_equal %out_img, [56, 56] : !transform.param<i64>
    transform.iree.match.dims_equal %out_ch, [64] : !transform.param<i64>
    transform.iree.match.dims_equal %filt, [3, 3] : !transform.param<i64>
    transform.iree.match.dims_equal %in_ch, [64] : !transform.param<i64>
    transform.yield %root : !transform.any_op
  }
  transform.named_sequence @configure_conv(%op: !transform.any_op {transform.readonly}) {
    %info = transform.param.constant #iree_codegen.compilation_info<
      lowering_config = #iree_cpu.lowering_config<
        distribution = [7, 56, 32, 0, 0, 0],
        vector_common_parallel = [1, 8, 16, 0, 0, 0],
        vector_reduction = [0, 0, 0, 1, 1, 8]>,
      translation_info = #iree_codegen.translation_info<pipeline = #iree_cpu.pipeline<ConvTileAndDecomposeExpert>>
    > -> !transform.any_param
    transform.annotate %op "compilation_info" = %info : !transform.any_op, !transform.any_param
    transform.yield
  }
  transform.named_sequence @__kernel_config(%variant_op: !transform.any_op {transform.consumed}) {
    transform.foreach_match in %variant_op
        @match_conv -> @configure_conv
      : (!transform.any_op) -> (!transform.any_op)
    transform.yield
  }
}
iree-compile conv_n1.mlir \
  --iree-hal-target-device=local --iree-hal-local-target-device-backends=llvm-cpu \
  --iree-llvmcpu-target-cpu=x86-64-v3 \
  --iree-codegen-tuning-spec-path=spec.mlir -o /dev/null
  • Without the spec, it compiles.
  • With the spec, it fails with the error above.
  • Control: the same input and spec at N=2, with the matcher on %batch, [2] and a 7-entry config, compiles, and the config reaches LLVMCPUSelectLoweringStrategy.

Activity

  1. github-actions commented on Nov 3, 2026

    @github-actions

    Hello @prakanth97 👋

    Thank you for submitting an issue to IREE! It looks like it's your first one.

    The volume of issues is huge, and triage times may vary. If you need quicker assistance on the issue, consider posting it on IREE Discord and providing short context there.
    Feel free to identify the most frequent contributors to the corresponding part of the codebase via Git history/CODEOWNERS and (gently!) tag them below.


    Action required: acknowledge IREE project policies

    IREE is a Linux Foundation project. All participants are expected to follow the LF Projects Code of Conduct.

    Please note that all contributions to IREE, including GitHub issues, must follow our IREE AI Tool Use Policy. This means:

    • Issue reporters must fully understand the primary issue and the impact of the problem.
      For bug reports, specifics of the use-case, workflow and/or crash scenario usually suffice.
      For improvement suggestions, this usually implies deeper understanding of suboptimal code, IR design choices, assumed performance tradeoffs, etc.
    • Contributors must write the summary of the issue themselves, so that the exact impact and scenario is clear to other participants.
    • Issue authors are expected to review and understand all LLM/AI-assisted segments of the report, if any. E.g.: CLI commands and IR reproducers, model/framework details, lowering pipeline details, assumptions about problematic behaviors of IREE components.
    • Substantial use of LLM/generative AI tools must be disclaimed in the header or footer of the issue description.

    Before the issue can be triaged, we kindly ask you to reply to this message and confirm that you understand and accept the proposed policy. As required, please adjust your initial issue description.


    If you have any questions, feel free to leave a comment here, or ask away on IREE Discord.

    Thank you,
    The IREE Community

  2. changed the title [-]`InsertBatchDimForBatchlessConv` drops the user `lowering_config` from tuning specs, so batch-1 convs are left untiled[/-] [+][Codegen][CPU]`InsertBatchDimForBatchlessConv` drops the user `lowering_config` from tuning specs, so batch-1 convs are left untiled[/+] on Nov 3, 2026
  3. zzznnn-1 commented on Nov 7, 2026

    @zzznnn-1

    Hi, I'd like to work on this issue. I'll start by reproducing the batch-1 tuning-spec failure on the current main branch, then investigate how the CPU lowering configuration should be preserved and remapped across the batch-dimension transformation, and add regression coverage including the batch-2 control.

    If no one is already working on it, could you please assign it to me? Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions