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)
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)
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)
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)
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)
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)
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
def test_perform(self): self.with_linker(gof.PerformLinker())
def test_perform_inplace(self): self.with_linker_inplace(gof.PerformLinker(), self.op, self.type, self.rand_val)
def test_perform_inplace(self): self.with_linker_inplace(gof.PerformLinker())
'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)