Skip to content

Commit 98581b9

Browse files
colesburysoumith
authored andcommitted
Fix conv1d segfault when weight doesn't require grad (pytorch#1646)
Fixes pytorch#1600
1 parent 9a497f8 commit 98581b9

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

torch/csrc/autograd/functions/convolution.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -307,10 +307,12 @@ auto ConvBackward::apply(const variable_list& grad_outputs) -> variable_list {
307307
}
308308

309309
if (k == 3) {
310-
if (should_compute_output(0)) {
311-
grad_input = view3d(*grad_input);
310+
if (grad_input) {
311+
grad_input = view3d(*grad_input);
312+
}
313+
if (grad_weight) {
314+
grad_weight = view3d(*grad_weight);
312315
}
313-
grad_weight = view3d(*grad_weight);
314316
}
315317

316318
auto outputs = as_tensor_list(std::move(grad_input),

0 commit comments

Comments
 (0)