From f755a58e56597f690be4a0c4bdb549ce0ffd4e03 Mon Sep 17 00:00:00 2001 From: Ilyas Moutawwakil <57442720+IlyasMoutawwakil@users.noreply.github.com> Date: Tue, 2 Jul 2024 18:50:36 +0200 Subject: [PATCH] Remove inplace op in mistral patcher (#1938) remove bitwise inplace op --- optimum/exporters/onnx/model_patcher.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/optimum/exporters/onnx/model_patcher.py b/optimum/exporters/onnx/model_patcher.py index f3a3ad78dbf..5e720d0cd7d 100644 --- a/optimum/exporters/onnx/model_patcher.py +++ b/optimum/exporters/onnx/model_patcher.py @@ -1031,9 +1031,10 @@ def _update_causal_mask_patched( if self.config.sliding_window is not None: if not using_sliding_window_cache or sequence_length > self.config.sliding_window: # ---------------- NOTE: This part is patched ----------------------------- - exclude_mask.bitwise_or_( + exclude_mask = torch.bitwise_or( + exclude_mask, torch.arange(target_length, device=device) - <= (cache_position.reshape(-1, 1) - self.config.sliding_window) + <= (cache_position.reshape(-1, 1) - self.config.sliding_window), ) # ---------------- NOTE: patch end ----------------------------------------