Skip to content

conv1d/conv3d emit tensor<?xf32> in HLO output due to missing shape attributes on tape #530

@michalharakal

Description

@michalharakal

Summary

When a model traced through the KSP-generated tracer wrapper reaches the StableHLO converter, conv1d (and conv3d) outputs are emitted as tensor<?xf32> instead of their correct static shape. This breaks iree-compile with type-mismatch errors on every downstream op that consumes the conv result.

Observed 12 occurrences in the Whisper encoder during the IREE / Vulkan GPU bring-up.

Example MLIR fragment produced today:

%v116 = stablehlo.add %v116_conv, %v1 : tensor<?xf32>

%v1 is a static tensor<384xf32> bias, so the add is rejected as a type mismatch.

Root cause

VoidTensorOps.conv1d already computes a static output shape — that path is correct. The shape is lost in DefaultExecutionTape.recordTrace (skainet-compile-dag), which builds TensorSpecs from trace.attributes["outputShapes"] / ["inputShapes"].

The KSP-generated tracer wrapper only populates those attributes for ops in a hard-coded allowlist (conv2d, unary/binary/scalar ops, shape ops). conv1d and conv3d fall through to AttributeStrategy.DefaultMapping, which records only stride/padding/dilation/groups. With the shape attributes absent, TensorSpec.shape becomes null and TypeMapper.formatShape(null) emits ?.

The TensorRef objects in the trace already carry the correct static Shape (captured from the runtime tensor via TraceSession.refOf), so there's a free, always-correct fallback available.

Fix

In DefaultExecutionTape.recordTrace, fall back to TensorRef.shape.dimensions.toList() (and TensorRef.dtype.name) when the attributes are missing.

Related / out of scope

RecordingTensorOpsDecorator.conv1d / .conv3d in skainet-compile-core override the parent but don't call record(...) at all (unlike conv2d). That's a separate latent gap — a tracked follow-up issue.

Context

  • Whisper-on-GPU pipeline for MagentaTV One (Amlogic, Mali Valhall, Android 14)
  • Branch: feature/iree-vulkan-gpu in skainet-whisper
  • Upstream issues log: skainet-hlo-issues.md (Issue 5)

Reproduction

./gradlew :SKaiNET-voice:testDebugUnitTest --tests "*WhisperHloExportTest*"
iree-compile SKaiNET-voice/build/iree/encoder_skainet.mlir \
  --iree-hal-target-backends=vulkan-spirv --iree-vulkan-target=valhall4 \
  -o encoder_skainet_vulkan.vmfb

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions