Exemplo n.º 1
0
import theano
from theano import gof
import theano.gof.vm
from theano.configparser import config
from theano.compile.ops import _output_guard
from six import string_types

_logger = logging.getLogger('theano.compile.mode')

# If a string is passed as the linker argument in the constructor for
# Mode, it will be used as the key to retrieve the real linker in this
# dictionary
predefined_linkers = {
    'py': gof.PerformLinker(),  # Use allow_gc Theano flag
    'c': gof.CLinker(),  # Don't support gc. so don't check allow_gc
    'c|py': gof.OpWiseCLinker(),  # Use allow_gc Theano flag
    'c|py_nogc': gof.OpWiseCLinker(allow_gc=False),
    'vm': gof.vm.VM_Linker(use_cloop=False),  # Use allow_gc Theano flag
    'cvm': gof.vm.VM_Linker(use_cloop=True),  # Use allow_gc Theano flag
    'vm_nogc': gof.vm.VM_Linker(allow_gc=False, use_cloop=False),
    'cvm_nogc': gof.vm.VM_Linker(allow_gc=False, use_cloop=True)
}


def register_linker(name, linker):
    """Add a `Linker` which can be referred to by `name` in `Mode`."""
    if name in predefined_linkers:
        raise ValueError('Linker name already taken: %s' % name)
    predefined_linkers[name] = linker

Exemplo n.º 2
0
import theano.gof.vm
from theano import config, gof
from theano.compile.function.types import Supervisor
from theano.sandbox.jax_linker import JAXLinker


_logger = logging.getLogger("theano.compile.mode")


# If a string is passed as the linker argument in the constructor for
# Mode, it will be used as the key to retrieve the real linker in this
# dictionary
predefined_linkers = {
    "py": gof.PerformLinker(),  # Use allow_gc Theano flag
    "c": gof.CLinker(),  # Don't support gc. so don't check allow_gc
    "c|py": gof.OpWiseCLinker(),  # Use allow_gc Theano flag
    "c|py_nogc": gof.OpWiseCLinker(allow_gc=False),
    "vm": gof.vm.VM_Linker(use_cloop=False),  # Use allow_gc Theano flag
    "cvm": gof.vm.VM_Linker(use_cloop=True),  # Use allow_gc Theano flag
    "vm_nogc": gof.vm.VM_Linker(allow_gc=False, use_cloop=False),
    "cvm_nogc": gof.vm.VM_Linker(allow_gc=False, use_cloop=True),
    "jax": JAXLinker(),
}


def register_linker(name, linker):
    """Add a `Linker` which can be referred to by `name` in `Mode`."""
    if name in predefined_linkers:
        raise ValueError(f"Linker name already taken: {name}")
    predefined_linkers[name] = linker
Exemplo n.º 3
0
 def test_c_or_py(self):
     # Shape op don't have C code.
     # But This will test DimShuffle c code
     self.with_linker(gof.OpWiseCLinker())
Exemplo n.º 4
0
            })
    else:
        if x != y:
            raise Exception("Output mismatch.", {
                'performlinker': x,
                'clinker': y
            })


# If a string is passed as the linker argument in the constructor for
# Mode, it will be used as the key to retrieve the real linker in this
# dictionary
predefined_linkers = {
    'py': gof.PerformLinker(),
    'c': gof.CLinker(),
    'c|py': gof.OpWiseCLinker(),
    'c|py_nogc': gof.OpWiseCLinker(allow_gc=False),
    'c&py': gof.DualLinker(checker=check_equal),
    'vm': gof.vm.VM_Linker(use_cloop=False),
    'cvm': gof.vm.VM_Linker(use_cloop=True),
    'vm_nogc': gof.vm.VM_Linker(allow_gc=False, use_cloop=False),
    'cvm_nogc': gof.vm.VM_Linker(allow_gc=False, use_cloop=True),
}


def register_linker(name, linker):
    """Add a `Linker` which can be referred to by `name` in `Mode`."""
    if name in predefined_linkers:
        raise ValueError('Linker name already taken: %s' % name)
    predefined_linkers[name] = linker