Skip to content

Add eachtile for stepped tile windows#281

Merged
maleadt merged 5 commits into
mainfrom
tb/eachtile
Jul 23, 2026
Merged

Add eachtile for stepped tile windows#281
maleadt merged 5 commits into
mainfrom
tb/eachtile

Conversation

@maleadt

@maleadt maleadt commented Jul 22, 2026

Copy link
Copy Markdown
Member

Adds eachtile, a Julia-facing array-of-tiles view:

tiles = eachtile(a, (8, 8); step=(4, 8))
tile = tiles[i, j]
tiles[i, j] = tile

step controls the distance between tile origins:

  • omitted or equal to tile_shape: adjacent partitions;
  • smaller: overlapping windows;
  • larger: gapped windows.

This mirrors cuTile Python’s Array.tiled_view(..., traversal_steps=...), with Julia-native API choices:

  • step instead of traversal_steps;
  • 1-based tile indices;
  • size(tiles) instead of num_tiles;
  • indexing plus ct.load/ct.store instead of .load/.store.

Equal/default steps preserve the existing PartitionView lowering and work on older bytecode versions. Unequal steps lower through Tile IR v13.3 StridedView.

It's a bit of a pun on eachslice, but still reads significantly nicer than Python's traversal_steps, I think. @AntonOresten, any thoughts?

@maleadt
maleadt requested a review from AntonOresten July 22, 2026 17:36
Comment thread src/compiler/intrinsics/views.jl
Comment thread src/language/types.jl
Comment thread src/language/types.jl
@AntonOresten

Copy link
Copy Markdown
Collaborator

eachtile is a nice interface!

maleadt and others added 3 commits July 23, 2026 11:06
The load/store emit code for partition and strided views was near-identical:
both lower to the same load_view_tko/store_view_tko ops. Factor it into
shared emit_view_load!/emit_view_store! helpers (and a shared tfunc helper),
keeping the four distinct intrinsic identities that token_order_pass! relies
on to treat overlapping strided windows conservatively.

Also let get_index_space_shape accept a StridedView operand — the Tile IR op
takes any tile view since v13.1 — and drop the make_strided_view version
check that merely duplicated the bytecode-layer v13.3 gates.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
- Drop underscore prefixes from the eachtile helpers and collapse the
  duplicated step accessor; the type-parameter accessors now live on the
  type with instance forwarders.
- Define Base.eltype on TiledView: the element is a whole tile of the
  user-requested shape.
- Require `step` to match `tile_shape` in length instead of padding short
  steps with 1s, which silently meant "overlap with step 1" on padded
  dimensions; a short shape/step pair now pads the trailing dimensions
  together.
- Overlay Base.size on TiledView in kernels to defer the tile count to the
  backend via get_index_space_shape (matching cuTile Python's num_tiles
  lowering) instead of baking in the host cld formula; the host method
  keeps cld for launch-grid sizing.
- Return the collection from setindex!, per convention.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Expose the view dim_map through the same 1-indexed `order` kwarg that
ct.load/ct.store already provide: tile_shape[i], step[i], and tile index i
describe tile dimension i, which maps to array dimension order[i]. The
permutation is carried as a sixth TiledView type parameter and threaded into
both the partition and strided view constructors, making the previously
unreachable make_strided_view dim_map arm exercisable from the public API.

The host-side size(tiles) pairs step[i] with array dim order[i]; the
device-side overlay needs no change since get_index_space_shape respects the
view's dim_map in the backend.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@maleadt
maleadt merged commit 690b3c3 into main Jul 23, 2026
1 check passed
@maleadt
maleadt deleted the tb/eachtile branch July 23, 2026 09:33
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