Support array construction syntax in kernels - #289
Draft
AntonOresten wants to merge 7 commits into
Draft
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #271, deprecates
ct.catin favor ofBase.catand friends.Currently documented under Construction, with
ct.catremoved from Shape.