Skip to content

[Fix][WebGPU] Validate and bound symbolic stack allocations - #20132

Open
akaashrp wants to merge 1 commit into
apache:mainfrom
akaashrp:upstream/webgpu-symbolic-stack-allocation
Open

[Fix][WebGPU] Validate and bound symbolic stack allocations#20132
akaashrp wants to merge 1 commit into
apache:mainfrom
akaashrp:upstream/webgpu-symbolic-stack-allocation

Conversation

@akaashrp

Copy link
Copy Markdown
Contributor

Allow WebGPU code generation for local and workgroup allocations whose symbolic extents have finite compile-time upper bounds. WGSL requires array lengths to be compile-time constants, so codegen uses arithmetic analysis to derive and emit a static upper bound for expressions such as min(n, 64) (unbounded or nonpositive extents are rejected).

This PR:

  • Detects element-count, byte-size, and aggregate workgroup-memory overflow
  • Computes allocation sizes using WGSL array element stride
  • Applies WebGPU's per-workgroup-variable 16-byte size rounding
  • Tracks total workgroup storage used by each generated entry point
  • Enforces max_shared_memory_per_block, corresponding to WebGPU's maxComputeWorkgroupStorageSize
  • Sets the default WebGPU limit to 32 KiB to match TVM's JavaScript runtime contract while permitting target-specific overrides

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