Skip to content

[LLM runner] Align make_image_input HWC contract with runtime behavior #22685

Description

@mergennachin

Problem

The Python type stub and pybind docstring advertise HWC, 1xHWC, CHW, and 1xCHW image tensors. Runtime checks accept contiguous CHW and 1xCHW, but reject ordinary contiguous HWC and 1xHWC.

The implementation squeezes rank-4 input before checking ChannelsLast; PyTorch reports that memory format as false for the resulting rank-3 tensor, so the HWC branch is effectively unreachable. Direct tests with the built binding confirmed both CHW forms pass and both HWC forms fail.

The examples in #22620 document only the verified CHW behavior. Runtime and type-stub changes are intentionally excluded from that documentation-only PR.

Proposed resolution

Choose and enforce one contract:

  1. Implement real HWC and 1xHWC support with shape-aware conversion, or
  2. Remove the unreachable HWC path and narrow the pybind docstring and _llm_runner.pyi contract to contiguous CHW and 1xCHW.

Test plan

Add positive and negative coverage for all four layouts, both supported dtypes, invalid batch size, and noncontiguous tensors.

cc @larryliu0820 @cccclai @helunwencser @jackzhxng @digantdesai

Activity

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

Metadata

Metadata

Labels

bugmodule: llmIssues related to LLM examples and apps, and to the extensions/llm/ code

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions