From 1a5a48d37dc8a38376d6aee9d6696d99aed2f7fa Mon Sep 17 00:00:00 2001 From: Jedrzej Kosinski Date: Thu, 4 Apr 2024 14:42:47 -0500 Subject: [PATCH] Account for use_motion being off --- adv_control/control_sparsectrl.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/adv_control/control_sparsectrl.py b/adv_control/control_sparsectrl.py index 2c91f68..60ffbcc 100644 --- a/adv_control/control_sparsectrl.py +++ b/adv_control/control_sparsectrl.py @@ -106,14 +106,16 @@ class SparseModelPatcher(ModelPatcher): else: patched_model = super().patch_model(device_to, patch_weights) try: - self.model.motion_wrapper.to(device=device_to) + if self.model.motion_wrapper is not None: + self.model.motion_wrapper.to(device=device_to) except Exception: - raise + pass return patched_model def unpatch_model(self, device_to=None, unpatch_weights=True): try: - self.model.motion_wrapper.to(device=device_to) + if self.model.motion_wrapper is not None: + self.model.motion_wrapper.to(device=device_to) except Exception: pass if unpatch_weights: