From 89481e710990beffb8c916be71eaf29b224c69a4 Mon Sep 17 00:00:00 2001 From: Shreyansh Bardia <104841983+ShreyanshBardia@users.noreply.github.com> Date: Tue, 26 Sep 2023 17:16:39 +0530 Subject: [PATCH] feat: set sub_backends by default if they are available (#25976) --- ivy/utils/backend/handler.py | 3 ++- ivy/utils/backend/sub_backend_handler.py | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) 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):