Skip to content

Commit

Permalink
Set dtype when copying empty tensor (#126124)
Browse files Browse the repository at this point in the history
Summary: Forward fix D57251348

Test Plan: `buck2 test 'fbcode//mode/dev' fbcode//executorch/kernels/test:aten_op_copy_test`

Differential Revision: D57304360

Pull Request resolved: #126124
Approved by: https://github.com/bdhirsh
  • Loading branch information
huydhn authored and ZelboK committed May 19, 2024
1 parent 976f0f2 commit b3f0fce
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion aten/src/ATen/native/Copy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ Tensor copy(const Tensor& self, const Tensor& src, bool non_blocking) {
// Instead, generate an empty tensor with the right sizes/strides, since we should be able to assume
// that copy_() will fully overwrite all data with that of src
if (self_storage->nbytes() == 0) {
r = at::empty_strided(self.sizes(), self.strides());
r = at::empty_strided(self.sizes(), self.strides(), self.options());
} else {
r = clone_preserve_strides(self);
}
Expand Down

0 comments on commit b3f0fce

Please sign in to comment.