-
Notifications
You must be signed in to change notification settings - Fork 3.4k
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
Avoid torchscript export for Metric forward #4428
Avoid torchscript export for Metric forward #4428
Conversation
Codecov Report
@@ Coverage Diff @@
## master #4428 +/- ##
=======================================
+ Coverage 90% 93% +3%
=======================================
Files 116 116
Lines 8742 8718 -24
=======================================
+ Hits 7845 8075 +230
+ Misses 897 643 -254 |
Maybe add this test to def test_scriptable(tmpdir):
class TestModel(BoringModel):
def __init__(self):
super().__init__()
self.metric = SumMetric()
self.sum = 0.0
def training_step(self, batch, batch_idx):
x = batch
self.metric(x.sum())
self.sum += x.sum()
self.log("sum", self.metric, on_epoch=True, on_step=False)
return self.step(x)
model = TestModel()
script_model = torch.jit.script(model)
# test that we can still do inference
output = script_model(torch.randn(10, 32)) |
3f5f1b9
to
ac00fcc
Compare
6523a09
to
d8ff339
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
the time-outed test came from the master... |
* Update metric.py * add test * Update CHANGELOG.md * Update test_metric_lightning.py * Update test_metric_lightning.py Co-authored-by: Jirka Borovec <[email protected]> (cherry picked from commit 5d08559)
* Update metric.py * add test * Update CHANGELOG.md * Update test_metric_lightning.py * Update test_metric_lightning.py Co-authored-by: Jirka Borovec <[email protected]> (cherry picked from commit 5d08559)
* Update metric.py * add test * Update CHANGELOG.md * Update test_metric_lightning.py * Update test_metric_lightning.py Co-authored-by: Jirka Borovec <[email protected]>
What does this PR do?
Fixes #4416
https://pytorch.org/docs/stable/generated/torch.jit.unused.html#torch.jit.unused
Before submitting
PR review
Anyone in the community is free to review the PR once the tests have passed.
If we didn't discuss your PR in Github issues there's a high chance it will not be merged.
Did you have fun?
Make sure you had fun coding 🙃