diff --git a/aten/src/ATen/native/mps/operations/BitwiseOps.mm b/aten/src/ATen/native/mps/operations/BitwiseOps.mm index 5b57693296b12..0633acd82b4d3 100644 --- a/aten/src/ATen/native/mps/operations/BitwiseOps.mm +++ b/aten/src/ATen/native/mps/operations/BitwiseOps.mm @@ -313,6 +313,11 @@ void handle_tensor_scalar_binary_op(const at::Tensor& self, const at::Scalar& ot getMetalType(self), getMetalType(self), "bitwise_not"); + uint32_t length = output.numel(); + if (length == 0) { + return output_; + } + dispatch_sync(stream->queue(), ^(){ id buffer = stream->commandBuffer(); id commandEncoder = [buffer computeCommandEncoder];