예제 #1
0
import sys

import theano
from theano.compat import get_unbound_function
from theano.compile import optdb
from theano.gof import EquilibriumDB, SequenceDB
from theano.gof.cmodule import get_lib_extension
from theano.gof.compilelock import get_lock, release_lock
from theano.configparser import config, AddConfigVar, StrParam, BoolParam
import nvcc_compiler

# ignore_newtrees is to speed the optimization as this is the pattern
# we use for optimization. Otherwise, we can iterate 100s of time on
# the graph and apply only a few optimizations each time.
gpu_optimizer = EquilibriumDB(ignore_newtrees=False)
gpu_seqopt = SequenceDB()


def register_opt(*tags, **kwargs):
    if any([not isinstance(t, str) for t in tags]):
        raise RuntimeError(
            "Bad call to register_opt."
            " All tags must be strings.", tags)

    def f(local_opt):
        name = (kwargs and kwargs.pop('name')) or local_opt.__name__
        gpu_optimizer.register(name, local_opt, 'fast_run', 'fast_compile',
                               'gpu', *tags)
        return local_opt

    return f
예제 #2
0
import theano
from theano import config, gof
from six import integer_types
from theano.gof.cmodule import Compiler
from theano.sandbox.mkl.mkl_helper import header_text

from theano.gof import EquilibriumDB, SequenceDB

from theano.tensor.blas import ldflags

_logger_name = 'theano.sandbox.mkl'
_logger = logging.getLogger(_logger_name)

mkl_optimizer = EquilibriumDB(ignore_newtrees=False)
mkl_seqopt = SequenceDB()


def register_opt(*tags, **kwargs):
    if any([not isinstance(t, str) for t in tags]):
        raise RuntimeError(
            "Bad call to register_opt."
            " All tags must be strings.", tags)

    def f(local_opt):
        name = (kwargs and kwargs.pop('name')) or local_opt.__name__
        mkl_optimizer.register(name, local_opt, 'fast_run', 'fast_compile',
                               'mkl', *tags, **kwargs)
        return local_opt

    return f