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

[Torchscript] Add Vector preprocessing and postprocessing #2160

Merged
merged 13 commits into from
Jun 21, 2022

Conversation

geoffreyangus
Copy link
Collaborator

This PR adds Vector input and output features. There is a small workaround in the Vector postprocessing step to convert preds from Dict[str, torch.Tensor] to Dict[str, Any]. The alternative is to set the return type to Union[Dict[str, torch.Tensor], Dict[str, Any]]. We prefer the former over the latter because Torchscript will complain downstream if we try to do dict operations on variables with type Union[Dict[str, torch.Tensor], Dict[str, Any]] (i.e. if we try to do .items() iteration).

@github-actions
Copy link

github-actions bot commented Jun 17, 2022

Unit Test Results

       6 files  ±0         6 suites  ±0   2h 40m 9s ⏱️ + 28m 1s
2 827 tests ±0  2 793 ✔️ +1    34 💤 ±0  0  - 1 
8 481 runs  ±0  8 375 ✔️ +1  106 💤 ±0  0  - 1 

Results for commit cc52796. ± Comparison against base commit fe77793.

♻️ This comment has been updated with latest results.


logger = logging.getLogger(__name__)


class _VectorPreprocessing(torch.nn.Module):
def forward(self, v: TorchscriptPreprocessingInput):
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: add return type? torch.Tensor?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Added to this function as well as the other torchscript preprocessing modules 🙂

@geoffreyangus geoffreyangus changed the title [Torchscript] Add Vector input and output feature [Torchscript] Add Vector preprocessing and postprocessing Jun 18, 2022
@geoffreyangus geoffreyangus merged commit f764b12 into master Jun 21, 2022
@geoffreyangus geoffreyangus deleted the ts-add-vector-feature branch June 21, 2022 21:38
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.

None yet

2 participants