Skip to content

Commit a5e27c4

Browse files
Samantha Andowpytorchmergebot
Samantha Andow
authored andcommitted
Use new_empty in dropout (pytorch#72078)
Summary: This will be needed by functorch to have the expected behavior of randomness: Dropout generates a tensor of the right size and then calls `bernoulli_` on that. In order to get the expected behavior from ensembled creation, we'll need to make sure that the generated tensor is a batched tensor.This works mostly because most tensors are created as `empty_like` but this one just creates `empty` because it needs a new shape, only for feature dropout. There is also no analogous version in CUDA because this directly calls`_dropout_impl` here (not in native_functions.yaml) This shouldn't change the behavior outside of functorch Pull Request resolved: pytorch#72078 Reviewed By: zou3519 Differential Revision: D33898338 Pulled By: samdow fbshipit-source-id: 9d9ed59d138d732d9647b2771ccf2ea97cffae1c (cherry picked from commit e51cf3e)
1 parent 44e2b8d commit a5e27c4

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

aten/src/ATen/native/Dropout.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ Tensor make_feature_noise(const Tensor& input) {
2222
(void)i; //Suppress unused variable warning
2323
sizes.push_back(1);
2424
}
25-
return at::empty(sizes, input.options());
25+
return input.new_empty(sizes);
2626
}
2727

2828
bool is_fused_kernel_acceptable(const Tensor& input, double p) {

0 commit comments

Comments
 (0)