Skip to content

HLO: collapse uniform-value constants to dense<v> splat (relates to #519)#522

Merged
michalharakal merged 1 commit intodevelopfrom
feature/hlo-splat-uniform-constants
Apr 18, 2026
Merged

HLO: collapse uniform-value constants to dense<v> splat (relates to #519)#522
michalharakal merged 1 commit intodevelopfrom
feature/hlo-splat-uniform-constants

Conversation

@michalharakal
Copy link
Copy Markdown
Contributor

Summary

Background

Zero-initialized VoidTensorOps tensors are uniform by construction. Previously a 10x10 zero weight rendered as 100 floats of text; now it's one scalar. For Whisper-tiny.en, this is mostly cosmetic — the heavy cost is the real (non-uniform) learned weights, which still blow up inline text MLIR. The architectural fix is PR B–E in the forthcoming design issue.

Test plan

  • New regression test testTensorConstantWithUniformValuesEmitsSplat — uniform zeros on a 10x10 tensor asserts dense<0.0> and no spelled-out array.
  • New regression test testTensorConstantWithNonUniformValuesKeepsNestedLiteral — non-uniform values must still render as [[1.0, 2.0], [3.0, 4.0]].
  • :skainet-compile:skainet-compile-hlo:jvmTest passes, no regressions in existing tests.

Relates to #519

🤖 Generated with Claude Code

formatTensorValues now detects a uniform value list covering the
declared shape and emits the scalar splat form (`dense<0.0>`) instead
of spelling out every element. A 10x10 zero-initialized weight drops
from 100 floats in text to a single scalar; larger
VoidTensorOps-backed tensors scale the same way. Non-uniform values
continue to render as nested array literals, so real learned weights
are unaffected.

This is polish on the inline path — it does not solve #519's 151 MB
blowup for non-uniform weights on its own. The architectural fix for
that case is to stop inlining weights at all and reference them via
IREE's util.parameter.load, with a `.irpa` sidecar written by a new
`skainet-io-iree-params` module; a design issue tracking that work
will follow and supersede #519.

Relates to #519

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@michalharakal michalharakal merged commit a289fdb into develop Apr 18, 2026
3 of 4 checks passed
@michalharakal michalharakal deleted the feature/hlo-splat-uniform-constants branch April 18, 2026 19:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant