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

reshape function #558

Open
mtsokol opened this issue May 14, 2024 · 5 comments
Open

reshape function #558

mtsokol opened this issue May 14, 2024 · 5 comments
Labels
enhancement New feature or request
Milestone

Comments

@mtsokol
Copy link
Member

mtsokol commented May 14, 2024

Hi @willow-ahrens,

I wanted to discuss feasibility of eager only (and simplest possible) reshape function in Finch.

It looks like most of the Array API test suites require reshape to run (test_signatures.py test suite that I ran to count the number of supported functions is an exception).

To run them locally I used a crude/test only implementation:

def reshape(x: Tensor, shape: tuple[int, ...]) -> Tensor:
    arr = x.todense()
    arr = arr.reshape(shape)
    return Tensor(arr)

Do you think it would be feasible to have an eager only reshape(::SwizzleArray, ...)? Even if it would be as simple as copy to a dense format ([EDIT] or COO?), reshape and then copy back to the original format?

@mtsokol mtsokol added the enhancement New feature or request label May 14, 2024
@hameerabbasi
Copy link
Collaborator

copy to a dense format

This is exactly what I'd like to avoid -- COO should be doable though.

@willow-ahrens
Copy link
Collaborator

willow-ahrens commented May 14, 2024

I believe we can do this. The main challenge I have a hard time designing for is the selection of an appropriate output format. If we know the appropriate output format, I don't think it would be so hard to do a direct copy. We would need to use one of the randomly accessible sparse formats if the swizzles don't match up. I think we could implement something similar to the style of our getindex kernel, where we use a generated function to write some Finch code and call it.

@willow-ahrens
Copy link
Collaborator

willow-ahrens commented May 14, 2024

@mtsokol Is this is a blocker for you?

@hameerabbasi
Copy link
Collaborator

@willow-ahrens It's needed for doing finch-tensor/finch-tensor-python#48 cleanly.

@willow-ahrens
Copy link
Collaborator

hmm. Okay! I'll do it today then.

@willow-ahrens willow-ahrens modified the milestones: v1.1, v1.2 Nov 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants