pytorch
bbe5bfaa - Add GradMode::enabled check to max_pool1d (#46767)

Commit
4 years ago
Add GradMode::enabled check to max_pool1d (#46767) Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/46767 ## Benchmark ``` ------------------------------------------------------------------------------------------ benchmark: 2 tests ------------------------------------------------------------------------------------------ Name (time in us) Min Max Mean StdDev Median IQR Outliers OPS Rounds Iterations -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- test_grad_disabled 390.0155 (1.0) 533.4131 (1.0) 392.6161 (1.0) 8.5603 (1.0) 390.7457 (1.0) 0.3912 (1.0) 98;319 2,547.0171 (1.0) 2416 1 test_grad_enabled 3,116.7269 (7.99) 4,073.2883 (7.64) 3,178.0827 (8.09) 122.7487 (14.34) 3,142.2675 (8.04) 33.0228 (84.42) 10;22 314.6551 (0.12) 225 1 -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- ``` *snippet (using pytest benchmark module)* ``` import torch torch.set_num_threads(1) x = torch.randn(1000, 10, 36, requires_grad=True) def test_grad_enabled(benchmark): benchmark(torch.max_pool1d, x, 2) def test_grad_disabled(benchmark): torch.set_grad_enabled(False) benchmark(torch.max_pool1d, x, 2) ``` Test Plan: Imported from OSS Reviewed By: mrshenli Differential Revision: D24565126 Pulled By: heitorschueroff fbshipit-source-id: 91a93be9921f597db21e9dc277f6e36eae85b37a
Parents
Loading