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

[2/n] MultiEmbeddingTensor: Add MultiEmbeddingTensor #181

Merged
merged 17 commits into from
Nov 8, 2023

Conversation

akihironitta
Copy link
Member

@akihironitta akihironitta commented Nov 6, 2023

Adds MultiEmbeddingTensor as part of #88.

Follow-up tasks:

torch_frame/data/multi_embedding_tensor.py Show resolved Hide resolved
torch_frame/data/multi_embedding_tensor.py Outdated Show resolved Hide resolved
torch_frame/data/multi_embedding_tensor.py Show resolved Hide resolved
torch_frame/data/multi_embedding_tensor.py Show resolved Hide resolved
torch_frame/data/multi_embedding_tensor.py Outdated Show resolved Hide resolved
Copy link
Contributor

@weihua916 weihua916 left a comment

Choose a reason for hiding this comment

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

Thanks for starting. I think we can create a base class to share basic logics with MultiNestedTensor. For MultiEmbeddingTensor, I think you can first implement MultiEmbeddingTensor.from_tensor_list and make sure met[i, j] is working properly. Then, we can gradually build up advanced indexing and concatenation in separate PRs.

test/data/test_multi_embedding_tensor.py Show resolved Hide resolved
torch_frame/data/multi_embedding_tensor.py Show resolved Hide resolved
torch_frame/data/multi_embedding_tensor.py Show resolved Hide resolved
Copy link
Contributor

@yiweny yiweny left a comment

Choose a reason for hiding this comment

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

Thank you for your work. I think there are some small bugs and edge case handling that need to be resolved in this pr.
Also, I think it might be better to create a base class for this and MultiNestedTensor.

torch_frame/data/multi_embedding_tensor.py Outdated Show resolved Hide resolved
torch_frame/data/multi_embedding_tensor.py Outdated Show resolved Hide resolved
torch_frame/data/multi_embedding_tensor.py Outdated Show resolved Hide resolved
torch_frame/data/multi_embedding_tensor.py Outdated Show resolved Hide resolved
torch_frame/data/multi_embedding_tensor.py Outdated Show resolved Hide resolved
torch_frame/data/multi_embedding_tensor.py Outdated Show resolved Hide resolved
torch_frame/data/multi_embedding_tensor.py Outdated Show resolved Hide resolved
num_rows = 3
num_cols = 2
offset = torch.tensor([0, 2, 4])
values = torch.tensor([
Copy link
Contributor

Choose a reason for hiding this comment

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

Use rand to generate tensor.

Copy link
Member Author

Choose a reason for hiding this comment

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

I prefer this way to random tensors for readability, but I can replace this if you'd advocate for it

test/data/test_multi_embedding_tensor.py Outdated Show resolved Hide resolved
test/data/test_multi_embedding_tensor.py Outdated Show resolved Hide resolved
Copy link

codecov bot commented Nov 7, 2023

Codecov Report

Merging #181 (bab9c1f) into master (a6a3bae) will increase coverage by 0.18%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##           master     #181      +/-   ##
==========================================
+ Coverage   91.86%   92.05%   +0.18%     
==========================================
  Files         105      107       +2     
  Lines        4376     4480     +104     
==========================================
+ Hits         4020     4124     +104     
  Misses        356      356              
Files Coverage Δ
test/data/test_multi_embedding_tensor.py 100.00% <100.00%> (ø)
torch_frame/data/__init__.py 100.00% <100.00%> (ø)
torch_frame/data/multi_embedding_tensor.py 100.00% <100.00%> (ø)

📣 Codecov offers a browser extension for seamless coverage viewing on GitHub. Try it in Chrome or Firefox today!

@akihironitta akihironitta changed the title Add MultiEmbeddingTensor [2/n] MultiEmbeddingTensor: Add MultiEmbeddingTensor Nov 7, 2023
@akihironitta akihironitta marked this pull request as draft November 7, 2023 06:00
Rename _to_positive_index _normalize_index

[pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

unused imports

docs

update
akihironitta and others added 3 commits November 8, 2023 03:17
[pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci
Base automatically changed from aki/refactor-tensors to master November 8, 2023 03:41
Copy link
Member Author

@akihironitta akihironitta left a comment

Choose a reason for hiding this comment

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

@yiweny @rusty1s @weihua916 @zechengz Ready for your second review ;)

@akihironitta akihironitta marked this pull request as ready for review November 8, 2023 04:13
Copy link
Contributor

@weihua916 weihua916 left a comment

Choose a reason for hiding this comment

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

LGM, thanks!

torch_frame/data/multi_embedding_tensor.py Outdated Show resolved Hide resolved
torch_frame/data/multi_embedding_tensor.py Outdated Show resolved Hide resolved
@akihironitta akihironitta enabled auto-merge (squash) November 8, 2023 04:46

def __getitem__(
self,
index: Any,
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
index: Any,
index: IndexSelectType,

Copy link
Member Author

Choose a reason for hiding this comment

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

Will address in a follow-up!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants