Skip to content

[PTO][Lowering] subset lowering forces contiguous child strides and may break address semantics #104

@WenboCodes

Description

@WenboCodes

Problem

pto.subset is described as a strided view inheriting source strides, but lowering rewrites result strides to contiguous [child_width, 1].

Evidence

  • ODS description says inherited strides: include/PTO/IR/PTOOps.td:168
  • Lowering hardcodes child strides:
    • lib/PTO/Transforms/PTOViewToMemref.cpp:527
    • lib/PTO/Transforms/PTOViewToMemref.cpp:533
    • lib/PTO/Transforms/PTOViewToMemref.cpp:542

Repro

build/tools/ptoas/ptoas test/samples/_out/Subset/subset-pto-ir.pto

Observed lowering output includes:

  • parent: memref<32x64xf32, strided<[64, 1], ...>
  • child subset: to memref<32x32xf32, strided<[32, 1], ...>

Why this is risky

For parent 32x64 and child 32x32, row step changes from 64 to 32, so address formula changes for rows > 0.

Expected behavior

Either:

  1. Preserve view semantics by keeping source-compatible strides, or
  2. Explicitly materialize contiguous memory (alloc+copy) if contiguous child layout is intended.

Acceptance criteria

  • Decide and document canonical subset semantics.
  • Align ODS docs + lowering implementation.
  • Add regression test proving row-stride correctness for 32x64 -> subset 32x32.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions