Skip to content

Commit

Permalink
fix glob properties issue when a backend change occur (ivy-llc#19595)
Browse files Browse the repository at this point in the history
unsustaining property value fixed
  • Loading branch information
juliagsy authored Jul 19, 2023
1 parent 0272ab2 commit 7592479
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 16 deletions.
14 changes: 9 additions & 5 deletions ivy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -986,7 +986,9 @@ def vec_sig_fig(x, sig_fig=3):
return x


ivy.array_significant_figures = 10
ivy.array_significant_figures = (
array_significant_figures_stack[-1] if array_significant_figures_stack else 10
)


def set_array_significant_figures(sig_figs):
Expand Down Expand Up @@ -1025,7 +1027,9 @@ def _assert_array_decimal_values_formatting(dec_vals):
ivy.utils.assertions.check_greater(dec_vals, 0, allow_equal=True, as_array=False)


ivy.array_decimal_values = 8
ivy.array_decimal_values = (
array_decimal_values_stack[-1] if array_decimal_values_stack else 8
)


def set_array_decimal_values(dec_vals):
Expand All @@ -1052,7 +1056,7 @@ def unset_array_decimal_values():
ivy.__setattr__("array_decimal_values", dec_vals, True)


ivy.warning_level = "ivy_only"
ivy.warning_level = warning_level_stack[-1] if warning_level_stack else "ivy_only"


def set_warning_level(warn_level):
Expand Down Expand Up @@ -1085,7 +1089,7 @@ def warn(warning_message, stacklevel=0):


# nan policy #
ivy.nan_policy = "nothing"
ivy.nan_policy = nan_policy_stack[-1] if nan_policy_stack else "nothing"


def set_nan_policy(warn_level):
Expand Down Expand Up @@ -1119,7 +1123,7 @@ def unset_nan_policy():
# Dynamic Backend


ivy.dynamic_backend = True
ivy.dynamic_backend = dynamic_backend_stack[-1] if dynamic_backend_stack else True


def set_dynamic_backend(flag):
Expand Down
2 changes: 1 addition & 1 deletion ivy/functional/ivy/device.py
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ def print_all_ivy_arrays_on_dev(
[print(arr) for arr in arrs]


ivy.soft_device_mode = False
ivy.soft_device_mode = soft_device_mode_stack[-1] if soft_device_mode_stack else False


@handle_exceptions
Expand Down
26 changes: 16 additions & 10 deletions ivy/functional/ivy/general.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def __exit__(self, exc_type, exc_val, exc_tb):
return self


ivy.precise_mode = True
ivy.precise_mode = precise_mode_stack[-1] if precise_mode_stack else True


@handle_exceptions
Expand Down Expand Up @@ -417,7 +417,7 @@ def is_ivy_container(x: Any, /) -> bool:
return isinstance(x, ivy.Container)


ivy.array_mode = True
ivy.array_mode = array_mode_stack[-1] if array_mode_stack else True


@handle_exceptions
Expand Down Expand Up @@ -473,7 +473,7 @@ def unset_array_mode() -> None:
ivy.__setattr__("array_mode", mode, True)


ivy.nestable_mode = True
ivy.nestable_mode = nestable_mode_stack[-1] if nestable_mode_stack else True


@handle_exceptions
Expand Down Expand Up @@ -525,7 +525,9 @@ def unset_nestable_mode() -> None:
ivy.__setattr__("nestable_mode", mode, True)


ivy.exception_trace_mode = "full"
ivy.exception_trace_mode = (
exception_trace_mode_stack[-1] if exception_trace_mode_stack else "full"
)


@handle_exceptions
Expand Down Expand Up @@ -580,7 +582,11 @@ def unset_exception_trace_mode() -> None:
ivy.__setattr__("exception_trace_mode", mode, True)


ivy.show_func_wrapper_trace_mode = True
ivy.show_func_wrapper_trace_mode = (
show_func_wrapper_trace_mode_stack[-1]
if show_func_wrapper_trace_mode_stack
else True
)


@handle_exceptions
Expand Down Expand Up @@ -2105,7 +2111,7 @@ def einops_repeat(
return ret


ivy.min_denominator = 1e-12
ivy.min_denominator = min_denominator_stack[-1] if min_denominator_stack else 1e-12


@handle_exceptions
Expand Down Expand Up @@ -2160,7 +2166,7 @@ def unset_min_denominator() -> None:
ivy.__setattr__("min_denominator", val, True)


ivy.min_base = 1e-05
ivy.min_base = min_base_stack[-1] if min_base_stack else 1e-05


@handle_exceptions
Expand Down Expand Up @@ -2430,7 +2436,7 @@ def print_all_arrays_in_memory():
print(type(arr), arr.shape)


ivy.queue_timeout = 15.0
ivy.queue_timeout = queue_timeout_stack[-1] if queue_timeout_stack else 15.0


@handle_exceptions
Expand Down Expand Up @@ -2489,7 +2495,7 @@ def unset_queue_timeout() -> None:
ivy.__setattr__("queue_timeout", timeout, True)


ivy.tmp_dir = "/tmp"
ivy.tmp_dir = tmp_dir_stack[-1] if tmp_dir_stack else "/tmp"


@handle_exceptions
Expand Down Expand Up @@ -3623,7 +3629,7 @@ def shape(
return current_backend(x).shape(x, as_array=as_array)


ivy.shape_array_mode = False
ivy.shape_array_mode = shape_array_mode_stack[-1] if shape_array_mode_stack else False


@handle_exceptions
Expand Down

0 comments on commit 7592479

Please sign in to comment.