Exemple #1
0
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))
Exemple #2
0
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))
Exemple #3
0
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
Exemple #4
0
def unset_framework():
    framework_stack.pop(-1)
    if verbosity.level > 0:
        verbosity.cprint('framework stack: {}'.format(framework_stack))
Exemple #5
0
def set_framework(f):
    framework_stack.append(f)
    if verbosity.level > 0:
        verbosity.cprint('framework stack: {}'.format(framework_stack))
Exemple #6
0
 def __exit__(self, exc_type, exc_val, exc_tb):
     framework_stack.pop(-1)
     if verbosity.level > 0:
         verbosity.cprint('framework stack: {}'.format(framework_stack))
Exemple #7
0
 def __enter__(self):
     framework_stack.append(self.module)
     if verbosity.level > 0:
         verbosity.cprint('framework stack: {}'.format(framework_stack))