diff --git a/ivy/utils/backend/handler.py b/ivy/utils/backend/handler.py index b1f51421199ea..1a91f47b41564 100644 --- a/ivy/utils/backend/handler.py +++ b/ivy/utils/backend/handler.py @@ -418,7 +418,8 @@ def set_backend(backend: str, dynamic: bool = False): if dynamic: convert_from_numpy_to_target_backend(variable_ids, numpy_objs, devices) - + for sub_backend in ivy.available_sub_backends: + ivy.set_sub_backend(sub_backend) if verbosity.level > 0: verbosity.cprint(f"backend stack: {backend_stack}") _handle_inplace_mode() diff --git a/ivy/utils/backend/sub_backend_handler.py b/ivy/utils/backend/sub_backend_handler.py index 16f7f91393d08..01b10dc44c634 100644 --- a/ivy/utils/backend/sub_backend_handler.py +++ b/ivy/utils/backend/sub_backend_handler.py @@ -278,7 +278,7 @@ def _unset_sub_backend_from_ivy( def clear_sub_backends(): if ivy.current_sub_backends: ivy.__dict__.update(original_backend_dict) - ivy.current_sub_backends = [] + ivy.current_sub_backends.clear() # This is only used in set_backend in handler.py @@ -286,7 +286,7 @@ def _clear_current_sub_backends(): global original_backend_dict original_backend_dict = None if ivy.current_sub_backends: - ivy.current_sub_backends = [] + ivy.current_sub_backends.clear() def find_available_sub_backends(sub_backends_loc):