def unset_framework(): if framework_stack: framework_stack.pop(-1) f_dict = framework_stack[ -1].__dict__ if framework_stack else ivy_original_dict for k, v in f_dict.items(): ivy.__dict__[k] = v if verbosity.level > 0: verbosity.cprint('framework stack: {}'.format(framework_stack))
def set_framework(f): if not framework_stack: global ivy_original_dict ivy_original_dict = ivy.__dict__.copy() if isinstance(f, str): f = importlib.import_module(_framework_dict[f]) framework_stack.append(f) for k, v in f.__dict__.items(): ivy.__dict__[k] = v if verbosity.level > 0: verbosity.cprint('framework stack: {}'.format(framework_stack))
def get_framework(*args, f=None, **kwargs): """Priorities: framework > global_framework > input's framework.""" if f: if verbosity.level > 0: verbosity.cprint('Using provided framework: {}'.format(f)) return f if framework_stack: f = framework_stack[-1] if verbosity.level > 0: verbosity.cprint('Using framework from stack: {}'.format(f)) return f f = _get_framework_from_args(list(args) + list(kwargs.values())) if f is None: raise ValueError( 'get_framework failed to find a valid library from the inputs: ' '{} {}'.format(args, kwargs)) if verbosity.level > 0: verbosity.cprint('Using framework from type: {}'.format(f)) return f
def unset_framework(): framework_stack.pop(-1) if verbosity.level > 0: verbosity.cprint('framework stack: {}'.format(framework_stack))
def set_framework(f): framework_stack.append(f) if verbosity.level > 0: verbosity.cprint('framework stack: {}'.format(framework_stack))
def __exit__(self, exc_type, exc_val, exc_tb): framework_stack.pop(-1) if verbosity.level > 0: verbosity.cprint('framework stack: {}'.format(framework_stack))
def __enter__(self): framework_stack.append(self.module) if verbosity.level > 0: verbosity.cprint('framework stack: {}'.format(framework_stack))