Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Backends are adaptors #364

Merged
merged 10 commits into from
Mar 9, 2023
Merged

Backends are adaptors #364

merged 10 commits into from
Mar 9, 2023

Conversation

vchuravy
Copy link
Member

@vchuravy vchuravy commented Mar 9, 2023

No description provided.

@vchuravy
Copy link
Member Author

vchuravy commented Mar 9, 2023

Replaces #353

@maleadt good idea or bad idea?

# Define:
# adapt_storage(::Backend, a::Array) = adapt(BackendArray, a)
# adapt_storage(::Backend, a::BackendArray) = a
Adapt.adapt_storage(::CPU, a::Array) = a
Copy link
Member

Choose a reason for hiding this comment

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

Why the instance and not the type?

Copy link
Member Author

Choose a reason for hiding this comment

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

You mean the ::Type{CPU}< I thought we defined adaptors over the instance. The user might not have the backend type around, but they should always have an instance.

Copy link
Member

Choose a reason for hiding this comment

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

well, for CuArray we do adapt(CuArray, obj), i.e., specifying the type because that's likely the only thing you have at that point. If users don't explicitly mention the backend types I guess it would be fine to use the instance here.

@codecov
Copy link

codecov bot commented Mar 9, 2023

Codecov Report

Patch coverage: 100.00% and project coverage change: -0.53 ⚠️

Comparison is base (b56ecc7) 88.95% compared to head (f460de5) 88.42%.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #364      +/-   ##
==========================================
- Coverage   88.95%   88.42%   -0.53%     
==========================================
  Files           8        8              
  Lines         534      579      +45     
==========================================
+ Hits          475      512      +37     
- Misses         59       67       +8     
Impacted Files Coverage Δ
src/KernelAbstractions.jl 82.97% <100.00%> (-0.24%) ⬇️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

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.

2 participants