Skip to content

Preserve producer-based provenance for dynamic Slice and Range bounds #20

Description

@matthargett

Problem

While enabling SmolLM on RustNN/CoreML, we need exported Slice/Range sizes to retain their runtime dependencies, not just a dimension name and allocation bound. A literal 4096 cannot safely be recovered as the active sequence length, and a label such as past_sequence_length + 1 does not by itself prove that they relate. I do have this working on my local devices with extra work that I wouldn't expect regular app developers to have/want to do (see related issues below for latest demo updates).

In current Slice lowering, dynamic end metadata is reused as the size label even though nonzero starts, clipping and strides can change that extent. Range lowering also derives relationships from dimension-name spelling. Separately, shape-tensor values Must Not be confused with the shape of the tensor containing them (that was annoying to chase down).

Is it possible to preserve a typed producer-based shape dependency through ONNX import, optimization, and WebNN serialization, AND reject unsupported relationships instead of silently freezing their maxima?

Needed coverage

  • Distinguish tensor descriptors from shape-tensor values.
  • Preserve Slice end/start/clipping dependencies and Range start/limit/delta dependencies through intermediate producers, including Concat and unnamed values.
  • Treat dimension names as opaque equality labels; test unrelated arithmetic-looking names as negative controls.
  • Round-trip optimized and unoptimized exports, then check actual shapes and values over grow/shrink/reset, including nonzero Slice starts.
  • State which relationships remain unsupported until the dynamic-shape representation can express them.

This is separate from the positive-stride Slice window bug (start 2/end 10/step 2 on length 16 should produce four values). It also does not require changing current WebNN Slice semantics.

Context:
SmolLM with RustNN on Apple Watch tracking,
runtime Slice draft,
RustNN dynamic-shape work,
WebNN dynamic-shape proposal.

Activity

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