示例#1
0
 def test_perform(self):
     for dtype in self.dtypes + self.bin_dtypes:
         for op in self.reds:
             self.with_linker(gof.PerformLinker(),
                              op,
                              dtype=dtype,
                              pre_scalar_op=self.pre_scalar_op)
示例#2
0
 def test_perform_nan(self):
     for dtype in self.dtypes:
         for op in self.reds:
             self.with_linker(gof.PerformLinker(),
                              op,
                              dtype=dtype,
                              test_nan=True)
示例#3
0
 def test_perform_nan(self):
     for dtype in self.dtypes:
         if not dtype.startswith('float'):
             continue
         for op in self.reds:
             self.with_linker(gof.PerformLinker(), op, dtype=dtype,
                              test_nan=True,
                              pre_scalar_op=self.pre_scalar_op)
示例#4
0
 def test_perform(self):
     for dtype in ["floatX", "complex64", "complex128", "int8", "uint8"]:
         self.with_linker(gof.PerformLinker(), scalar.add, dtype=dtype)
         self.with_linker(gof.PerformLinker(), scalar.mul, dtype=dtype)
         self.with_linker(gof.PerformLinker(), scalar.maximum, dtype=dtype)
         self.with_linker(gof.PerformLinker(), scalar.minimum, dtype=dtype)
         self.with_linker(gof.PerformLinker(), scalar.and_, dtype=dtype,
                          tensor_op=tensor.all)
         self.with_linker(gof.PerformLinker(), scalar.or_, dtype=dtype,
                          tensor_op=tensor.any)
     for dtype in ["int8", "uint8"]:
         self.with_linker(gof.PerformLinker(), scalar.or_, dtype=dtype)
         self.with_linker(gof.PerformLinker(), scalar.and_, dtype=dtype)
         self.with_linker(gof.PerformLinker(), scalar.xor, dtype=dtype)
示例#5
0
 def test_perform(self):
     for dtype in ["floatX", "complex64", "complex128", "int8", "uint8"]:
         self.with_linker(gof.PerformLinker(), add, dtype=dtype)
         self.with_linker(gof.PerformLinker(), mul, dtype=dtype)
         self.with_linker(gof.PerformLinker(), maximum, dtype=dtype)
         self.with_linker(gof.PerformLinker(), minimum, dtype=dtype)
     for dtype in ["int8", "uint8"]:
         self.with_linker(gof.PerformLinker(), or_, dtype=dtype)
         self.with_linker(gof.PerformLinker(), and_, dtype=dtype)
         self.with_linker(gof.PerformLinker(), xor, dtype=dtype)
示例#6
0
 def test_perform_nan(self):
     for dtype in ["floatX", "complex64", "complex128"]:
         self.with_linker(gof.PerformLinker(),
                          add,
                          dtype=dtype,
                          test_nan=True)
         self.with_linker(gof.PerformLinker(),
                          mul,
                          dtype=dtype,
                          test_nan=True)
         self.with_linker(gof.PerformLinker(),
                          maximum,
                          dtype=dtype,
                          test_nan=True)
         self.with_linker(gof.PerformLinker(),
                          minimum,
                          dtype=dtype,
                          test_nan=True)
         self.with_linker(gof.PerformLinker(),
                          or_,
                          dtype=dtype,
                          test_nan=True)
         self.with_linker(gof.PerformLinker(),
                          and_,
                          dtype=dtype,
                          test_nan=True)
示例#7
0
文件: mode.py 项目: zmdfwh/Theano
import logging

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
示例#8
0
 def test_perform(self):
     self.with_linker(gof.PerformLinker())
示例#9
0
 def test_perform_inplace(self):
     self.with_linker_inplace(gof.PerformLinker(), self.op, self.type,
                              self.rand_val)
示例#10
0
 def test_perform_inplace(self):
     self.with_linker_inplace(gof.PerformLinker())
示例#11
0
                'performlinker': x,
                'clinker': y
            })
    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)