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

Introducing Block #1087

Merged
merged 11 commits into from
May 17, 2023
Merged

Introducing Block #1087

merged 11 commits into from
May 17, 2023

Conversation

marcromeyn
Copy link
Contributor

@marcromeyn marcromeyn commented May 11, 2023

Goals ⚽

First PR for the new PyTorch backend, this PR introduces the following user-facing classes:

  • Block
  • Batch
  • Sequence

And internal classes:

  • TorchScriptWrapper
  • BlockContainer

Implementation Details 🚧

TorchScriptWrapper makes it easier to work with torch-script. It will check the forward method and then stores various properties of it as constants. This way, torchscript doesn't need to worry about it.

Testing Details 🔍

Since these are some of the lowest-level classes, I tried to maximize test-coverage as much as possible

CleanShot 2023-05-12 at 13 47 22@2x

@marcromeyn marcromeyn self-assigned this May 11, 2023
@marcromeyn marcromeyn added the enhancement New feature or request label May 11, 2023
@github-actions
Copy link

Documentation preview

https://nvidia-merlin.github.io/models/review/pr-1087

@marcromeyn marcromeyn mentioned this pull request May 12, 2023
Comment on lines +85 to +86
if self.accepts_batch:
if self.requires_batch:
Copy link
Contributor

Choose a reason for hiding this comment

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

Curious if these two lines can be collapsed into if self.accepts_batch and self.requires_batch and the rest of this code block be outdented once, or if it's due to quirks of Torchscript?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's so that if requires_batch is false, we cast Optional[Batch] into Batch and throw an RuntimeException if it's None.

merlin/models/torch/batch.py Show resolved Hide resolved
merlin/models/torch/container.py Show resolved Hide resolved
merlin/models/torch/container.py Show resolved Hide resolved
merlin/models/torch/container.py Show resolved Hide resolved
merlin/models/torch/container.py Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/pytorch enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants