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.
ext/ReactantStructArraysExt.jl
Outdated
| ) 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 <wmoses@google.com> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: Avik Pal <avikpal@mit.edu>
No description provided.