mirror of
https://github.com/zebrajr/pytorch.git
synced 2025-12-06 12:20:52 +01:00
[MPS] Remove incorrect asserts from Copy.mm (#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 https://github.com/pytorch/pytorch/issues/86153 Pull Request resolved: https://github.com/pytorch/pytorch/pull/86184 Approved by: https://github.com/kulinseth
This commit is contained in:
parent
9da5646cdb
commit
8da704cdb7
|
|
@ -156,7 +156,6 @@ static at::Tensor& copy_from_mps_(at::Tensor& dst_, const at::Tensor& src_, bool
|
||||||
|
|
||||||
// If there's anything wrong with source, we shouldn't return dst_ silently and must error out.
|
// If there's anything wrong with source, we shouldn't return dst_ silently and must error out.
|
||||||
TORCH_INTERNAL_ASSERT(sourceBuffer && dst_tensor_nbytes > 0);
|
TORCH_INTERNAL_ASSERT(sourceBuffer && dst_tensor_nbytes > 0);
|
||||||
TORCH_INTERNAL_ASSERT(dst_tensor_nbytes >= (dst.storage_offset() * dst.element_size()));
|
|
||||||
|
|
||||||
stream->copy_and_sync(tmpBuffer, destBuffer, size_to_copy, storage_byte_offset, destOffset, non_blocking);
|
stream->copy_and_sync(tmpBuffer, destBuffer, size_to_copy, storage_byte_offset, destOffset, non_blocking);
|
||||||
[destBuffer release];
|
[destBuffer release];
|
||||||
|
|
@ -199,7 +198,6 @@ static at::Tensor& copy_to_mps_(at::Tensor& dst_, const at::Tensor& src_, bool n
|
||||||
const size_t size_to_copy = src.nbytes();
|
const size_t size_to_copy = src.nbytes();
|
||||||
const void* host_src = src.storage().data();
|
const void* host_src = src.storage().data();
|
||||||
TORCH_INTERNAL_ASSERT(src_total_size >= (src.storage_offset() * src.element_size()));
|
TORCH_INTERNAL_ASSERT(src_total_size >= (src.storage_offset() * src.element_size()));
|
||||||
TORCH_INTERNAL_ASSERT(dst_.nbytes() >= dst_byte_offset);
|
|
||||||
|
|
||||||
NSUInteger sourceOffset = 0;
|
NSUInteger sourceOffset = 0;
|
||||||
@autoreleasepool {
|
@autoreleasepool {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user