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

Add partial implementation of Einsum and Segment Anything example #295

Merged
merged 4 commits into from
Jul 30, 2024

Conversation

robertknight
Copy link
Owner

Add an initial version of the Einsum operator, and a Segment Anything model example, whose image encoder model requires it.

The initial Einsum implementation is limited to equations that can be efficiently executed as a single matrix multiplication, with permutations of the inputs and outputs if needed.

The example uses the sam-vit-base model variant in its documentation, but I have also tested with sam-vit-large and slimsam.

`InputList::push` is useful for building up an `InputList` in operator tests.
At the same time, update the documentation following the change to make
`InputList` a copy-on-write data structure.
At clippy's request, add this impl.
@robertknight robertknight force-pushed the segment-anything-einsum branch from 44db797 to df66776 Compare July 29, 2024 07:24
@robertknight robertknight marked this pull request as ready for review July 29, 2024 17:04
@robertknight robertknight marked this pull request as draft July 29, 2024 17:05
@robertknight robertknight force-pushed the segment-anything-einsum branch 2 times, most recently from 3e8c1ad to 99145ae Compare July 29, 2024 20:26
This initial implementation is limited to supporting equations which can be
implemented as a single matrix multiplication, with permutation of the inputs
and outputs if needed. This is sufficient to support the Einsum operations that
appear in Segment Anything [1] models. Simple transpositions are also supported.

[1] https://huggingface.co/facebook/sam-vit-base
This takes an image and a query point as input and outputs a segmentation mask.
@robertknight robertknight force-pushed the segment-anything-einsum branch from 99145ae to 64d5b05 Compare July 30, 2024 05:26
@robertknight robertknight marked this pull request as ready for review July 30, 2024 05:44
@robertknight robertknight merged commit 6304eb0 into main Jul 30, 2024
2 checks passed
@robertknight robertknight deleted the segment-anything-einsum branch July 30, 2024 05:44
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.

1 participant