Skip to content

Commit 8da704c

Browse files
malfetpytorchmergebot
authored andcommitted
[MPS] Remove incorrect asserts from Copy.mm (pytorch#86184)
Those asserts simply do not work for views. I.e. they are erroneously triggered for in `copy_to_mps_` when running something like `python -c "import torch;x=torch.empty(10,device='mps');y=torch.tensor([10]);print(x.shape);x[2]=y[0]"` And in `copy_from_mps_` when running the same script, but with order of devices inverted: `python -c "import torch;x=torch.empty(10);y=torch.tensor([10], device="mps");print(x.shape);x[2]=y[0]"` If this was supposed to be a boundary check, than it should have validated, that `storage_offset() + nbytes() <= storage.nbytes()`, but this check is already done by the upper layer, isn't it? Fixes pytorch#86153 Pull Request resolved: pytorch#86184 Approved by: https://github.com/kulinseth
1 parent 9da5646 commit 8da704c

File tree

1 file changed

+0
-2
lines changed
  • aten/src/ATen/native/mps/operations

1 file changed

+0
-2
lines changed

aten/src/ATen/native/mps/operations/Copy.mm

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,6 @@ void copy_cast_mps(at::Tensor& dst, const at::Tensor& src,
156156

157157
// If there's anything wrong with source, we shouldn't return dst_ silently and must error out.
158158
TORCH_INTERNAL_ASSERT(sourceBuffer && dst_tensor_nbytes > 0);
159-
TORCH_INTERNAL_ASSERT(dst_tensor_nbytes >= (dst.storage_offset() * dst.element_size()));
160159

161160
stream->copy_and_sync(tmpBuffer, destBuffer, size_to_copy, storage_byte_offset, destOffset, non_blocking);
162161
[destBuffer release];
@@ -199,7 +198,6 @@ void copy_cast_mps(at::Tensor& dst, const at::Tensor& src,
199198
const size_t size_to_copy = src.nbytes();
200199
const void* host_src = src.storage().data();
201200
TORCH_INTERNAL_ASSERT(src_total_size >= (src.storage_offset() * src.element_size()));
202-
TORCH_INTERNAL_ASSERT(dst_.nbytes() >= dst_byte_offset);
203201

204202
NSUInteger sourceOffset = 0;
205203
@autoreleasepool {

0 commit comments

Comments
 (0)