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

Idea: Pre-allocating intermediate arrays #57

Open
tkf opened this issue Sep 17, 2019 · 1 comment
Open

Idea: Pre-allocating intermediate arrays #57

tkf opened this issue Sep 17, 2019 · 1 comment

Comments

@tkf
Copy link
Member

tkf commented Sep 17, 2019

I've been thinking about writing a function cached (or allocate or optimize or something) such that

app = cached(@~ f.(A * B, C))

would be transformed to

app = @~ f.(materialize!(tmp, A * B), C)

with appropriate tmp array. This way, materialize!(dest, app) can be done without allocation. I think pre-allocations like this would be required between every boundary between Applied and Broadcasted, if you want to hoist out allocations.

A few questions:

  • I see that there is a LazyArrays.cache function. Is it related to this idea?
  • Does it make sense to have this in LazyArrays? Should it be developed outside?
@dlfivefifty
Copy link
Member

cache is used to cache the entries of a lazy array, mostly for the infinite-dimensional case, e.g., C = cache(Zeros(∞)); C[100] = 5;.

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

No branches or pull requests

2 participants