Skip to content

Add DynamicReshape and DynamicBroadcastInDim ops#15

Merged
janpfeifer merged 1 commit into
gomlx:mainfrom
ajroetker:resurrect-dynamic-ops
Jan 25, 2026
Merged

Add DynamicReshape and DynamicBroadcastInDim ops#15
janpfeifer merged 1 commit into
gomlx:mainfrom
ajroetker:resurrect-dynamic-ops

Conversation

@ajroetker

@ajroetker ajroetker commented Jan 25, 2026

Copy link
Copy Markdown
Contributor

Summary

Resurrect dynamic shape support that was partially lost during PR merges.

Shape struct changes

  • Add DimensionBounds and EncodeBounds fields to Shape struct
  • Add HasBoundedDynamism() method for checking bounded dynamic dimensions
  • Add bounds encoding in StableHLO output using #stablehlo.bounds<...> syntax

New dynamic ops

  • DynamicReshape - reshape with runtime-determined shape
  • DynamicBroadcastInDim - broadcast with runtime-determined shape
  • DynamicIota - iota with runtime-determined output shape
  • DynamicGather - gather with runtime-determined slice sizes
  • DynamicPad - pad with runtime-determined padding amounts
  • DynamicConv - convolution with runtime-determined padding

All ops require explicit bounds parameters since XLA needs to know maximum allocation sizes at compile time.

Also fixes missing go.sum entry for golang.org/x/sys.

Test plan

  • All existing tests pass (go test ./...)
  • go build ./... succeeds
  • New tests added for all dynamic ops in TestDynamicOperations
  • Shape encoding with bounds produces correct StableHLO syntax (verified in test output)

@ajroetker
ajroetker force-pushed the resurrect-dynamic-ops branch from 6d8e8a1 to 3e1e8f7 Compare January 25, 2026 02:26
Resurrect dynamic shape support that was partially lost during PR merges:

Shape struct changes:
- Add DimensionBounds and EncodeBounds fields
- Add HasBoundedDynamism() method for checking bounded dynamic dimensions
- Add bounds encoding in StableHLO output using #stablehlo.bounds<...> syntax

New dynamic ops added:
- DynamicReshape: reshape with runtime-determined shape
- DynamicBroadcastInDim: broadcast with runtime-determined shape
- DynamicIota: iota with runtime-determined output shape
- DynamicGather: gather with runtime-determined slice sizes
- DynamicPad: pad with runtime-determined padding amounts
- DynamicConv: convolution with runtime-determined padding

All ops require explicit bounds parameters since XLA needs to know
maximum allocation sizes at compile time.

Also includes comprehensive tests for all dynamic ops and fixes
missing go.sum entry for golang.org/x/sys.
@ajroetker
ajroetker force-pushed the resurrect-dynamic-ops branch from 3e1e8f7 to a8bf2cb Compare January 25, 2026 02:36

@janpfeifer janpfeifer left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very neat!

Does this work with PJRT ?

@janpfeifer
janpfeifer merged commit 7cf3fde into gomlx:main Jan 25, 2026
5 checks passed
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.

2 participants