Skip to content

Loss script fixes#1645

Merged
wyli merged 7 commits intoProject-MONAI:masterfrom
ericspod:loss_script_fixes
Feb 25, 2021
Merged

Loss script fixes#1645
wyli merged 7 commits intoProject-MONAI:masterfrom
ericspod:loss_script_fixes

Conversation

@ericspod
Copy link
Copy Markdown
Member

@ericspod ericspod commented Feb 25, 2021

Fixes #1592.

Description

Fixes most of the loss functions to be compatible with Torchscript. Omits LocalNormalizedCrossCorrelationLoss, GlobalMutualInformationLoss, and BendingEnergyLoss as some significant code changes may be necessary. The changes made mostly are about dealing with Torchscript limitations regarding generator expressions or acceptable argument types. Union for example isn't compatible since statically-typed compiled code is targeted by Torchscript and this cannot handle this sort of polymorphism (I think).

One outstanding issue is that Enum classes are not compatible with Torchscript in Pytorch<1.7. The tests for Dice, Tversky, and others is only run for versions 1.7 and up.

Status

Ready

Types of changes

  • Non-breaking change (fix or new feature that would not break existing functionality).
  • Breaking change (fix or new feature that would cause existing functionality to change).
  • New tests added to cover the changes.
  • Integration tests passed locally by running ./runtests.sh --codeformat --coverage.
  • Quick tests passed locally by running ./runtests.sh --quick.
  • In-line docstrings updated.
  • Documentation updated, tested make html command in the docs/ folder.

Signed-off-by: Eric Kerfoot <[email protected]>
Signed-off-by: Eric Kerfoot <[email protected]>
@ericspod
Copy link
Copy Markdown
Member Author

/black

@ericspod ericspod marked this pull request as ready for review February 25, 2021 17:01
@ericspod ericspod requested review from Nic-Ma, rijobro, wyli and yiheng-wang-nv and removed request for yiheng-wang-nv February 25, 2021 17:02
Copy link
Copy Markdown
Contributor

@wyli wyli left a comment

Choose a reason for hiding this comment

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

thanks, these are non-breaking enhancements for torchscript support

@wyli wyli merged commit 3c45f18 into Project-MONAI:master Feb 25, 2021
@ericspod ericspod deleted the loss_script_fixes branch February 25, 2021 18:23
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.

DiceLoss can't support TorchScript

3 participants