Better StructArray & StaticArray support#2546
Conversation
| else | ||
| typeof(res_tmp) | ||
| end | ||
| result = similar(first(flat_args), T_res, L) |
There was a problem hiding this comment.
This should be reviewed closely. I had to change this line because now flat_args may have differing array types, e.g., one could be a StructArray. Before we decided the output entirely based on the first element, which could lead to errors, e.g., 2 .* sa would try to write a StructArray to a TracedRArray.
|
@wsmoses @jumerckx I think this is ready for a first review. I'll add some tests tomorrow, but this seems to enable more support for StructArrays. Right now, the only thing that could cause an issue is if one of the underlying arrays isn't a ReactantPrimitive, but that should be enough for what I need. |
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
|
Actually one question is what are the semantics of overloaded_mul(A, B, alpha, beta)typically for the 5-argument mul in place is I'm not sure what this should be when C isn't defined. |
Fix comment typo in overloaded_mul function.
| ) where {T,TI<:Integer} | ||
| valsT = maybe_convert_elt(T, vals) | ||
| foreachfield((col, val) -> (@inbounds col[I] = val), s, valsT) | ||
| foreachfield((col, val) -> (@inbounds Reactant.@allowscalar col[I] = val), s, valsT) |
There was a problem hiding this comment.
lambda functions are going to cause some compile time issues, can we get rid of them with functions defined directly (possibly with fix1/etc as relevant)?
* Draft to figure out better StructArray support * Simplify and generalize structarray type conversion * Start adding StaticArray support * Add StaticArray support and tweak elem_apply_while_loop to select correct container type * Revert tracing.jl * Remove info debug * Remove get_ith * Add _copyto! * format * Fix broken test and add new tests * format * add StaticArrays * Add LinearAlgebra * Remove unused function * Reuse the known destination for while loop if possible * Update ext/ReactantStructArraysExt.jl Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * Proposed improved support for SArrays * fix dumb mistake * Add additional changes for StaticArrays * Apply suggestions from code review Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * Cleanup * Update * Update * Format * Fix for code review * Add comments * So dumb * Correct comment in overloaded_mul function Fix comment typo in overloaded_mul function. * Update to remove anonymous functions * Update * Add a complex test * Update --------- Co-authored-by: Billy Moses <[email protected]> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: Avik Pal <[email protected]>
* force fusion * BFloat16 cuda kernel * add BFloat16s dep * only run bf16 on 1.12 * kernel cast 🪄 * depend on Enzyme-jax kernel-cast pass * remove xla options * Update src/Compiler.jl Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * kernelcast * Copy preserved argument if needed (#2722) * Make copyto! force a new buffer * Update src/Compiler.jl Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * setpahts! * yo * Update src/TracedRArray.jl Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * add aliasing test * pjrt * Update test/core/aliasing.jl Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * Move :new_buffer marking to Base.materialize! instead of _copyto! The :new_buffer path should only be set on the broadcast path (a .= b), not on all copyto! calls that happen to receive a Broadcasted argument. Co-Authored-By: Claude Sonnet 4.6 <[email protected]> * cleanup * Add buffer aliasing test for struct field reassignment with both new buffers Co-Authored-By: Claude Sonnet 4.6 <[email protected]> * less eager * Update src/Compiler.jl Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * use count * fmt * good args * fixup --------- Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: Claude Sonnet 4.6 <[email protected]> * Make the CUDA.jl not loaded error more specific (#2743) * Update LIBTPU_VERSION to 0.0.39.dev20260328 * Update Project.toml * Update WORKSPACE * Update ENZYMEXLA_COMMIT to a new hash * Update ENZYMEXLA_COMMIT to new hash * Regenerate MLIR Bindings (#2750) Co-authored-by: enzyme-ci-bot[bot] <78882869+enzyme-ci-bot[bot]@users.noreply.github.com> * Bump version and update Reactant_jll dependency * Regenerate MLIR Bindings (#2756) Co-authored-by: enzyme-ci-bot[bot] <78882869+enzyme-ci-bot[bot]@users.noreply.github.com> * Multifloat options (#2757) * Multifloat options * fix * fix * fix * Apply suggestions from code review Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --------- Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * Update Project.toml * `div` for ConcreteRNumber (#2674) * div for ConcreteRNumber * Update test/core/math_ops.jl Co-authored-by: Paul Berg <[email protected]> * Update src/ConcreteRArray.jl Co-authored-by: Paul Berg <[email protected]> * Update src/ConcreteRArray.jl Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * Update src/ConcreteRArray.jl Co-authored-by: Paul Berg <[email protected]> * Update src/ConcreteRArray.jl Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * Update src/ConcreteRArray.jl * remove methods * Revert "remove methods" This reverts commit ab20e23. * meth * fix ambiguities --------- Co-authored-by: Paul Berg <[email protected]> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: Paul Berg <[email protected]> * Multifloat fix pass parsing (#2759) * Change shardy_passes default value to post_sdy_propagation This is currently what the docs say * Bump version from 0.2.246 to 0.2.247 * Update ENZYMEXLA_COMMIT hash in WORKSPACE * Update ENZYMEXLA_COMMIT to new hash (#2760) * Regenerate MLIR Bindings (#2761) Co-authored-by: enzyme-ci-bot[bot] <78882869+enzyme-ci-bot[bot]@users.noreply.github.com> * Update LIBTPU_VERSION to 0.0.39.dev20260401 * fix: qa test (#2763) * feat: better StructArray & StaticArray support (#2546) * Draft to figure out better StructArray support * Simplify and generalize structarray type conversion * Start adding StaticArray support * Add StaticArray support and tweak elem_apply_while_loop to select correct container type * Revert tracing.jl * Remove info debug * Remove get_ith * Add _copyto! * format * Fix broken test and add new tests * format * add StaticArrays * Add LinearAlgebra * Remove unused function * Reuse the known destination for while loop if possible * Update ext/ReactantStructArraysExt.jl Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * Proposed improved support for SArrays * fix dumb mistake * Add additional changes for StaticArrays * Apply suggestions from code review Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * Cleanup * Update * Update * Format * Fix for code review * Add comments * So dumb * Correct comment in overloaded_mul function Fix comment typo in overloaded_mul function. * Update to remove anonymous functions * Update * Add a complex test * Update --------- Co-authored-by: Billy Moses <[email protected]> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: Avik Pal <[email protected]> * Update WORKSPACE * untested * turn it down * Attach data-layout to MLIR module * claude is cooking * dl * Add BFloat16 extension * compat * make a hard dep --------- Co-authored-by: Paul Berg <[email protected]> Co-authored-by: Paul Berg <[email protected]> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: Claude Sonnet 4.6 <[email protected]> Co-authored-by: Bart de Koning <[email protected]> Co-authored-by: enzyme-ci-bot[bot] <78882869+enzyme-ci-bot[bot]@users.noreply.github.com> Co-authored-by: Maximilian Gelbrecht <[email protected]> Co-authored-by: Avik Pal <[email protected]> Co-authored-by: dkytezab <[email protected]> Co-authored-by: Paul Tiede <[email protected]>
No description provided.