Skip to content

Comments

fix: convert AbstractRange to concrete types (#2276)#2309

Open
KookiesNKareem wants to merge 1 commit intoEnzymeAD:mainfrom
KookiesNKareem:fix-abstract-range-conversion
Open

fix: convert AbstractRange to concrete types (#2276)#2309
KookiesNKareem wants to merge 1 commit intoEnzymeAD:mainfrom
KookiesNKareem:fix-abstract-range-conversion

Conversation

@KookiesNKareem
Copy link
Contributor

Fixes #2276.

  • Adds support for converting AbstractRange types (e.g., range(), reshape(range(...))) to ConcreteRArray when using to_rarray or Adapt.adapt
  • Added AbstractArray constructors for ConcretePJRTArray and ConcreteIFRTArray
  • Added to_rarray_internal methods for AbstractArray types
  • Added Adapt.adapt_structure overrides for range types
  • Added tests for AbstractRange conversion

Comment on lines +10 to +13
r = range(1.0f0, 10.0f0; length=10)
a = Reactant.to_rarray(r)
@test a isa ConcreteRArray{Float32,1}
@test Array(a) ≈ collect(r)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not the right solution. Eagerly materializing any structured data structure will hurt perf really bad

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ahh, good point. Would limiting to AbstractRange only also cause performance degradation or no?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the context within which we need the support (eg the root cause of the issue)?

Eg are we materializing a large constant?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I updated to limit only to AbstractRange if this support is needed at all.

@KookiesNKareem KookiesNKareem force-pushed the fix-abstract-range-conversion branch from 9493038 to 4ab092b Compare January 30, 2026 01:39
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.

AbstractRange not converted to Concrete Types

3 participants