From c5f11a38f3688ad9a1cea3dcf7aff693a9a164cb Mon Sep 17 00:00:00 2001 From: ShreyanshBardia Date: Sun, 24 Sep 2023 00:57:51 +0530 Subject: [PATCH 1/2] setting subbackends by default --- ivy/utils/backend/sub_backend_handler.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ivy/utils/backend/sub_backend_handler.py b/ivy/utils/backend/sub_backend_handler.py index 571d7ee097c6a..c436b3c0f00f0 100644 --- a/ivy/utils/backend/sub_backend_handler.py +++ b/ivy/utils/backend/sub_backend_handler.py @@ -202,7 +202,7 @@ def set_sub_backend(sub_backend_str: str): ) set_sub_backend_to_specific_version(sub_backend) _set_sub_backend_as_ivy(ivy.__dict__.copy(), ivy, sub_backend) - ivy.current_backend().sub_backends._current_sub_backends.append(sub_backend_str) + ivy.current_sub_backends.append(sub_backend_str) # this is very similar to _set_backend_as_ivy in handler.py, with a minor change @@ -258,7 +258,7 @@ def unset_sub_backend(sub_backend_str: str): _unset_sub_backend_from_ivy( original_backend_dict, ivy, sub_backend, sub_backend.name ) - ivy.current_backend().sub_backends._current_sub_backends.remove(sub_backend_str) + ivy.current_sub_backends.remove(sub_backend_str) def _unset_sub_backend_from_ivy( @@ -289,7 +289,7 @@ def _unset_sub_backend_from_ivy( def clear_sub_backends(): if ivy.current_sub_backends: ivy.__dict__.update(original_backend_dict) - ivy.current_backend().sub_backends._current_sub_backends = [] + ivy.current_sub_backends.clear() # This is only used in set_backend in handler.py @@ -297,7 +297,7 @@ def _clear_current_sub_backends(): global original_backend_dict original_backend_dict = None if ivy.current_sub_backends: - ivy.current_backend().sub_backends._current_sub_backends = [] + ivy.current_sub_backends.clear() def find_available_sub_backends(sub_backends_loc): From a8ee6db277f9b4b42fae680b904c143d71d79eee Mon Sep 17 00:00:00 2001 From: ShreyanshBardia Date: Sun, 24 Sep 2023 00:58:48 +0530 Subject: [PATCH 2/2] updated variable names and avoid changing object reference --- ivy/utils/backend/handler.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ivy/utils/backend/handler.py b/ivy/utils/backend/handler.py index 3648455dabdd0..b7c3f96441331 100644 --- a/ivy/utils/backend/handler.py +++ b/ivy/utils/backend/handler.py @@ -426,7 +426,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()