Skip to content

Support array construction syntax in kernels - #289

Draft
AntonOresten wants to merge 7 commits into
mainfrom
ao/tile-construction
Draft

Support array construction syntax in kernels#289
AntonOresten wants to merge 7 commits into
mainfrom
ao/tile-construction

Conversation

@AntonOresten

@AntonOresten AntonOresten commented Jul 31, 2026

Copy link
Copy Markdown
Collaborator

Closes #271, deprecates ct.cat in favor of Base.cat and friends.

Currently documented under Construction, with ct.cat removed from Shape.

AntonOresten and others added 7 commits July 31, 2026 18:00
Tiles, scalars, and mixed blocks are one case: bracket syntax
concatenates tiles and scalars (e.g. [1; [1]] works).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Bracket syntax in kernels now follows Julia's concatenation semantics
(closes #271) instead of supporting only compile-time-constant scalar
literals:

- runtime scalar elements: broadcast to unit tiles and merged with a
  balanced cat tree (balanced so every intermediate keeps power-of-two
  dimensions); constant elements still emit one dense ConstantOp
- tile elements concatenate ([q1; q2], [t1 t2; t3 t4], [t1;;; t2]) via
  balanced Intrinsics.cat trees built by @generated helpers
- scalars and tiles mix as blocks ([x [y z]; t M]): scalars lift to
  unit tiles, vectors to columns, and element types promote across
  blocks -- though under Tile IR's power-of-two rule, mixed-size blocks
  only fit along dimensions where the sizes agree
- single-dim syntax ([1;; 2], Base.hvncat with an Int dim) now works
- the hvncat tuple-of-tuples shape form (ragged/mixed N-D syntax) is
  decoded by probing Base's own hvncat on the host, so invalid literals
  surface Julia's exact DimensionMismatch as a compile-time error
- comma collection of tiles ([t1, t2]) and power-of-two violations get
  clean compile-time errors

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
- Base.cat with the dims keyword (Int or Val) is the generic function
  form of bracket concatenation: variadic, scalars lift to unit tiles,
  element types promote. ct.cat stays public but is deprecated.
- typed T[...] concatenation (typed_vcat/hcat/hvcat/hvncat) now accepts
  tiles and mixed scalar/tile blocks, converting every element to T.
- The hvncat tuple-of-tuples shape form is decoded by probing Base's
  own hvncat with linear indices, so invalid ragged literals surface
  Julia's exact DimensionMismatch instead of a made-up message.
- Drop Base.@constprop :aggressive from the construction overlays:
  literal arguments and kwargs const-prop through @inline frames on
  their own (verified by the construction tests).
- Docs: concatenation (bracket syntax and cat) now lives under
  Construction; Shape keeps single-tile rearrangement ops.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
A bare @Assert in compiler/intrinsics/core.jl (included before
language/operations.jl) resolved Base's implicit binding in the module,
making the later `macro assert` (ct.@Assert) definition an invalid
extension on 1.11. Julia 1.12's binding partitions tolerate this, which
is why local tests passed.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Base.vect()'s Array allocation lowers to the memorynew intrinsic only on
1.12+; 1.11 fails through the GenericMemory path with a different
message. Assert the common "Unsupported" prefix instead.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
T[] builds a ghost Tile{T, Tuple{0}} with no Tile IR representation:
concatenation drops zero-length operands (n + 0 = n, so power-of-two
constraints are unaffected) while their element type still participates
in promotion, matching Base (vcat(Float64[], t32) is Float64).

Untyped [] cannot infer an element type; its Base.vect() overlay throws,
so an unconditional [] surfaces as a compile-time diagnostic and a
conditional one as a device-side trap. The throwing body infers as
Union{}, which keeps kernel-reachable Base error paths that call vect()
dead instead of derailing inference the way an Any-returning overlay
once did. This also replaces the Julia-version-dependent memorynew test.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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.

hvcat, hvncat, vect for tile construction

1 participant