From 0525f967c2de075e04152fdd7049d04e07c8be4b Mon Sep 17 00:00:00 2001 From: Ryan Dick Date: Sun, 29 Dec 2024 00:22:37 +0000 Subject: [PATCH] Fix the _autocast_forward_with_patches() function for CustomConv1d and CustomConv2d. --- .../torch_module_autocast/custom_modules/custom_conv1d.py | 6 +++--- .../torch_module_autocast/custom_modules/custom_conv2d.py | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/invokeai/backend/model_manager/load/model_cache/torch_module_autocast/custom_modules/custom_conv1d.py b/invokeai/backend/model_manager/load/model_cache/torch_module_autocast/custom_modules/custom_conv1d.py index d86a721e5a..ba64357406 100644 --- a/invokeai/backend/model_manager/load/model_cache/torch_module_autocast/custom_modules/custom_conv1d.py +++ b/invokeai/backend/model_manager/load/model_cache/torch_module_autocast/custom_modules/custom_conv1d.py @@ -12,9 +12,9 @@ from invokeai.backend.model_manager.load.model_cache.torch_module_autocast.custo class CustomConv1d(torch.nn.Conv1d, CustomModuleMixin): def _autocast_forward_with_patches(self, input: torch.Tensor) -> torch.Tensor: aggregated_param_residuals = self._aggregate_patch_parameters(self._patches_and_weights) - weight = add_nullable_tensors(self.weight, aggregated_param_residuals["weight"]) - bias = add_nullable_tensors(self.bias, aggregated_param_residuals["bias"]) - return torch.nn.functional.conv1d(input, weight, bias) + weight = add_nullable_tensors(self.weight, aggregated_param_residuals.get("weight", None)) + bias = add_nullable_tensors(self.bias, aggregated_param_residuals.get("bias", None)) + return self._conv_forward(input, weight, bias) def _autocast_forward(self, input: torch.Tensor) -> torch.Tensor: weight = cast_to_device(self.weight, input.device) diff --git a/invokeai/backend/model_manager/load/model_cache/torch_module_autocast/custom_modules/custom_conv2d.py b/invokeai/backend/model_manager/load/model_cache/torch_module_autocast/custom_modules/custom_conv2d.py index 6067cef594..98b6c52016 100644 --- a/invokeai/backend/model_manager/load/model_cache/torch_module_autocast/custom_modules/custom_conv2d.py +++ b/invokeai/backend/model_manager/load/model_cache/torch_module_autocast/custom_modules/custom_conv2d.py @@ -12,9 +12,9 @@ from invokeai.backend.model_manager.load.model_cache.torch_module_autocast.custo class CustomConv2d(torch.nn.Conv2d, CustomModuleMixin): def _autocast_forward_with_patches(self, input: torch.Tensor) -> torch.Tensor: aggregated_param_residuals = self._aggregate_patch_parameters(self._patches_and_weights) - weight = add_nullable_tensors(self.weight, aggregated_param_residuals["weight"]) - bias = add_nullable_tensors(self.bias, aggregated_param_residuals["bias"]) - return torch.nn.functional.conv2d(input, weight, bias) + weight = add_nullable_tensors(self.weight, aggregated_param_residuals.get("weight", None)) + bias = add_nullable_tensors(self.bias, aggregated_param_residuals.get("bias", None)) + return self._conv_forward(input, weight, bias) def _autocast_forward(self, input: torch.Tensor) -> torch.Tensor: weight = cast_to_device(self.weight, input.device)