rem stringlengths 0 322k | add stringlengths 0 2.05M | context stringlengths 8 228k |
|---|---|---|
return True except Errors.WindowActiveError: pass return False | except Errors.WindowActiveError: pass return True | def on_button_press(self, widget, event): from gui.editors import (EditPerson, EditEvent, EditFamily, EditSource, EditPlace, EditRepository, EditNote, EditMedia) # Here we intercept mouse clicks on selected items so that we can # drag multiple items without the click selecting only one target = self.get_path_at_pos(int... |
index = 0 | index = 1 | def read_image_metadata(self, obj): """ reads the image metadata after the pyexiv2.Image has been created """ |
Utils.open_file_with_default_application(zip_filename) | open_file_with_default_application(zip_filename) | def calc_url(self): """ Creates a file for use with GoogleEarth and launches GoogleEarth if in system """ home_dir = os.path.expanduser("~") default_filename = 'GrampsPlacesForGoogleEarth' filename = os.path.join(home_dir, default_filename) if not _GOOGLEEARTH_OK: qd2 = QuestionDialog2( _("GoogleEarth not installed!"),... |
Utils.open_file_with_default_application(full_filename) | open_file_with_default_application(full_filename) | def calc_url(self): """ Creates a file for use with GoogleEarth and launches GoogleEarth if in system """ home_dir = os.path.expanduser("~") default_filename = 'GrampsPlacesForGoogleEarth' filename = os.path.join(home_dir, default_filename) if not _GOOGLEEARTH_OK: qd2 = QuestionDialog2( _("GoogleEarth not installed!"),... |
"permissions, then please do it now." % basename)) | "permissions, then please do it now.") % basename) | def write_image_metadata(self, obj): """ saves the data fields to the image """ |
WarningDialog(_("The image file %(filename)s does NOT have read access/ " | WarningDialog(_("The image file %s does NOT have read access/ " | def read_image_metadata(self, obj): """ reads the image metadata after the pyexiv2.Image has been created """ |
"the permissions, then please do it now.")) % { 'filename' : basename} | "the permissions, then please do it now.") % basename) | def read_image_metadata(self, obj): """ reads the image metadata after the pyexiv2.Image has been created """ |
WarningDialog(_("The image file %(filename)s is missing. Please select another image or " "edit the media object to fix this problem.")) % {'filename' : basename} | WarningDialog(_("The image file %s is missing. Please select another image or " "edit the media object to fix this problem.") % basename) | def read_image_metadata(self, obj): """ reads the image metadata after the pyexiv2.Image has been created """ |
f = os.popen("xm domname %i"%domid) | f = os.popen("/usr/sbin/xm domname %i"%domid) | def domIdToName(domid): |
f = os.popen("xm domid %s"%domname) | f = os.popen("/usr/sbin/xm domid %s"%domname) | def domNameToId(domname): |
self.disktype = self.config.get('XenPV', 'defaultDiskType') | def __init__(self, config, dfs, cm): threading.Thread.__init__(self) self.config = config self.dfs = dfs self.cm = cm | |
diskname = self.transientDisk(a.id, i) | diskname = self.transientDisk(a.id, i, disktype) | def cron(self): |
image, macAddr, bridge, memory, cores, hints, id): | image, macAddr, netID, memory, cores, hints, id): bootstr = None diskconfig = None netconfig = None memconfig = None cpuconfig = None extraconfig = None | def createXenConfig(self, vmName, image, macAddr, bridge, memory, cores, hints, id): fn = os.path.join("/tmp", vmName) vmType = hints.get('vmtype', self.defaultVmType) print 'starting vm with type: ', vmType bootstr = '' if vmType == 'pvgrub': # FIXME: untested, requires Xen 3.3 bootstr = ''' |
bootstr = '' | try: disktype = self.config.get('XenPV', 'defaultDiskType') except: disktype = 'vhd' disk0 = 'tap:%s'%disktype diskU = 'xvda1' try: bridgeformat = self.config.get('XenPV', 'defaultBridgeFormat') except: bridgeformat = 'br%s' bridge = bridgeformat % netID | def createXenConfig(self, vmName, image, macAddr, bridge, memory, cores, hints, id): fn = os.path.join("/tmp", vmName) vmType = hints.get('vmtype', self.defaultVmType) print 'starting vm with type: ', vmType bootstr = '' if vmType == 'pvgrub': # FIXME: untested, requires Xen 3.3 bootstr = ''' |
kernel = '/usr/lib/xen/boot/pv-grub-x86_64.gz' | kernel = '/usr/lib/xen-default/boot/pv-grub-x86_64.gz' | def createXenConfig(self, vmName, image, macAddr, bridge, memory, cores, hints, id): fn = os.path.join("/tmp", vmName) vmType = hints.get('vmtype', self.defaultVmType) print 'starting vm with type: ', vmType bootstr = '' if vmType == 'pvgrub': # FIXME: untested, requires Xen 3.3 bootstr = ''' |
disk=['tap:qcow:%s,xvda1,w'] vif = [ 'bridge=br%s,mac=%s' ] memory=%i vcpus=%i root="/dev/xvda1" extra='xencons=tty' '''%(image, bridge, macAddr, memory, cores) | ''' | def createXenConfig(self, vmName, image, macAddr, bridge, memory, cores, hints, id): fn = os.path.join("/tmp", vmName) vmType = hints.get('vmtype', self.defaultVmType) print 'starting vm with type: ', vmType bootstr = '' if vmType == 'pvgrub': # FIXME: untested, requires Xen 3.3 bootstr = ''' |
disk=['tap:qcow:%s,xvda1,w'] vif = [ 'bridge=br%s,mac=%s' ] memory=%i vcpus=%i root="/dev/xvda1" extra='xencons=tty' '''%(kernel, ramdisk, image, bridge, macAddr, memory, cores) | '''%(kernel, ramdisk) | def createXenConfig(self, vmName, image, macAddr, bridge, memory, cores, hints, id): fn = os.path.join("/tmp", vmName) vmType = hints.get('vmtype', self.defaultVmType) print 'starting vm with type: ', vmType bootstr = '' if vmType == 'pvgrub': # FIXME: untested, requires Xen 3.3 bootstr = ''' |
kernel = '/usr/lib/xen/boot/hvmloader' | kernel = '/usr/lib/xen-default/boot/hvmloader' | def createXenConfig(self, vmName, image, macAddr, bridge, memory, cores, hints, id): fn = os.path.join("/tmp", vmName) vmType = hints.get('vmtype', self.defaultVmType) print 'starting vm with type: ', vmType bootstr = '' if vmType == 'pvgrub': # FIXME: untested, requires Xen 3.3 bootstr = ''' |
device_model='/usr/lib/xen/bin/qemu-dm' | device_model='/usr/lib/xen-default/bin/qemu-dm' | def createXenConfig(self, vmName, image, macAddr, bridge, memory, cores, hints, id): fn = os.path.join("/tmp", vmName) vmType = hints.get('vmtype', self.defaultVmType) print 'starting vm with type: ', vmType bootstr = '' if vmType == 'pvgrub': # FIXME: untested, requires Xen 3.3 bootstr = ''' |
disk=['tap:qcow:%s,hda,w'] vif = [ 'type=ioemu,bridge=br%s,mac=%s' ] memory=%i vcpus=%i root="/dev/xvda1" extra='xencons=tty' '''%(id, image, bridge, macAddr, memory, cores) | disk=['%s:%s,ioemu:%s,w'] '''(disk0, image, diskU) netconfig = ''' vif = [ 'type=ioemu,bridge=%s,mac=%s' ] '''(bridge, macAddr) | def createXenConfig(self, vmName, image, macAddr, bridge, memory, cores, hints, id): fn = os.path.join("/tmp", vmName) vmType = hints.get('vmtype', self.defaultVmType) print 'starting vm with type: ', vmType bootstr = '' if vmType == 'pvgrub': # FIXME: untested, requires Xen 3.3 bootstr = ''' |
def transientDisk(self, instanceId, disknum): | def transientDisk(self, instanceId, disknum, disktype): | def transientDisk(self, instanceId, disknum): newdisk = os.path.join(self.transientDir, 'tashi-%i-%i.qcow' %(instanceId, disknum)) return newdisk |
'tashi-%i-%i.qcow' %(instanceId, disknum)) | 'tashi-%i-%i.%s' %(instanceId, disknum, disktype)) | def transientDisk(self, instanceId, disknum): newdisk = os.path.join(self.transientDir, 'tashi-%i-%i.qcow' %(instanceId, disknum)) return newdisk |
newdisk = self.transientDisk(instance.id, i) cmd = '/usr/lib/xen-default/bin/qcow-create 0 %s %s' % (newdisk, imageLocal) | newdisk = self.transientDisk(instance.id, i, disktype) if disktype == 'qcow': cmd = '/usr/lib/xen-default/bin/qcow-create 0 %s %s' % (newdisk, imageLocal) elif disktype == 'vhd': cmd = '/usr/lib/xen-default/bin/vhd-tool create 0 %s %s' % (newdisk, imageLocal) else: raise Exception, "Unknown disktype in configuration: ... | def instantiateVm(self, instance): # FIXME: this is NOT the right way to get out hostId self.hostId = instance.hostId |
cmd = "xm create %s"%fn | cmd = "/usr/sbin/xm create %s"%fn | def instantiateVm(self, instance): # FIXME: this is NOT the right way to get out hostId self.hostId = instance.hostId |
cmd = "xm save %i %s"%(vmId, tmpfile) | cmd = "/usr/sbin/xm save %i %s"%(vmId, tmpfile) | def suspendVm(self, vmId, target, suspendCookie=None): # FIXME: don't use hardcoded /tmp for temporary data. # Get tmp location from config infofile = target + ".info" target = target + ".dat" tmpfile = os.path.join("/tmp", target) |
r = os.system("xm restore %s"%(tmpfile)) | r = os.system("/usr/sbin/xm restore %s"%(tmpfile)) | def resumeVm(self, source): infofile = source + ".info" source = source + ".dat" tmpfile = os.path.join("/tmp", source) # FIXME: errors infof = self.dfs.open(infofile, "r") instance = cPickle.load(infof) infof.close self.dfs.unlink(infofile) |
cmd = "xm migrate -l %i %s"%(vmId, target) | cmd = "/usr/sbin/xm migrate -l %i %s"%(vmId, target) | def migrateVm(self, vmId, target, transportCookie): cmd = "xm migrate -l %i %s"%(vmId, target) r = os.system(cmd) if r != 0: # FIXME: throw exception print "migrate failed for VM %i"%vmId raise Exception, "migrate failed for VM %i"%vmId self.newvms.pop(vmId) return vmId |
r = os.system("xm pause %i"%vmId) | r = os.system("/usr/sbin/xm pause %i"%vmId) | def pauseVm(self, vmId): r = os.system("xm pause %i"%vmId) if r != 0: print "xm pause failed for VM %i"%vmId raise Exception, "xm pause failed for VM %i"%vmId self.newvms[vmId].state = InstanceState.Paused return vmId |
r = os.system("xm unpause %i"%vmId) | r = os.system("/usr/sbin/xm unpause %i"%vmId) | def unpauseVm(self, vmId): r = os.system("xm unpause %i"%vmId) if r != 0: print "xm unpause failed for VM %i"%vmId raise Exception, "xm unpause failed for VM %i"%vmId self.newvms[vmId].state = InstanceState.Running return vmId |
r = os.system("xm shutdown %i"%vmId) | r = os.system("/usr/sbin/xm shutdown %i"%vmId) | def shutdownVm(self, vmId): r = os.system("xm shutdown %i"%vmId) if r != 0: print "xm shutdown failed for VM %i"%vmId raise Exception, "xm shutdown failed for VM %i"%vmId return vmId |
r = os.system("xm destroy %i"%vmId) | r = os.system("/usr/sbin/xm destroy %i"%vmId) | def destroyVm(self, vmId): r = os.system("xm destroy %i"%vmId) if r != 0: print "xm destroy failed for VM %i"%vmId raise Exception, "xm destroy failed for VM %i"%vmId return vmId |
memp = subprocess.Popen("xm info | awk '/^total_memory/ { print $3 }' ", | infopipe = subprocess.Popen("/usr/sbin/xm info", | def getHostInfo(self, service): host = Host() host.id = service.id host.name = socket.gethostname() memp = subprocess.Popen("xm info | awk '/^total_memory/ { print $3 }' ", shell = True, stdout = subprocess.PIPE) mems = memp.stdout.readline() host.memory = int(mems) corep = subprocess.Popen("xm info | awk '/^nr_cpus/ {... |
mems = memp.stdout.readline() host.memory = int(mems) corep = subprocess.Popen("xm info | awk '/^nr_cpus/ { print $3 }' ", shell = True, stdout = subprocess.PIPE) cores = corep.stdout.readline() host.cores = int(cores) | for line in infopipe.stdout.readline(): if line.startswith("total_memory"): host.memory = int((line.split(':'))[1]) if line.startswith("nr_cpus"): host.cores = int((line.split(':'))[1]) | def getHostInfo(self, service): host = Host() host.id = service.id host.name = socket.gethostname() memp = subprocess.Popen("xm info | awk '/^total_memory/ { print $3 }' ", shell = True, stdout = subprocess.PIPE) mems = memp.stdout.readline() host.memory = int(mems) corep = subprocess.Popen("xm info | awk '/^nr_cpus/ {... |
vif = [ 'bridge=%s,mac=%s' ] | vif = [ 'bridge=br%s,mac=%s' ] | def createXenConfig(self, vmName, image, macAddr, bridge, memory, cores, hints, id): fn = os.path.join("/tmp", vmName) vmType = hints.get('vmtype', self.defaultVmType) print 'starting vm with type: ', vmType bootstr = '' if vmType == 'pvgrub': # FIXME: untested, requires Xen 3.3 bootstr = ''' |
vif = [ 'type=ioemu,bridge=%s,mac=%s' ] | vif = [ 'type=ioemu,bridge=br%s,mac=%s' ] | def createXenConfig(self, vmName, image, macAddr, bridge, memory, cores, hints, id): fn = os.path.join("/tmp", vmName) vmType = hints.get('vmtype', self.defaultVmType) print 'starting vm with type: ', vmType bootstr = '' if vmType == 'pvgrub': # FIXME: untested, requires Xen 3.3 bootstr = ''' |
cmd = 'qcow-create 0 %s %s' % (newdisk, imageLocal) | cmd = '/usr/lib/xen-default/bin/qcow-create 0 %s %s' % (newdisk, imageLocal) | def instantiateVm(self, instance): # FIXME: this is NOT the right way to get out hostId self.hostId = instance.hostId |
f.write(rootconfig) | def createXenConfig(self, vmName, image, macAddr, netID, memory, cores, hints, id): bootstr = None rootconfig = None diskconfig = None netconfig = None memconfig = None cpuconfig = None extraconfig = None | |
if rootconfig is None: rootconfig = ''' root ='/dev/xvda1 ro' ''' | def createXenConfig(self, vmName, image, macAddr, netID, memory, cores, hints, id): bootstr = None diskconfig = None netconfig = None memconfig = None cpuconfig = None extraconfig = None | |
for (int i0 = threadIdx.x; i0 < d0; i0 += blockDim.x) { mysum += A[blockIdx.x * sA0 + i0 * sA1 + blockIdx.y * sA2]; | for (int i1 = threadIdx.x; i1 < d1; i1 += blockDim.x) { mysum += A[blockIdx.x * sA0 + i1 * sA1 + blockIdx.y * sA2]; | def c_support_code_apply(self, node, nodename): sio = StringIO.StringIO() nd_in = len(self.reduce_mask) if all(i==1 for i in self.reduce_mask): #this kernel is ok for up to a few thousand elements, but # it only runs on ONE multiprocessor reducebuf = self._k_reduce_buf('Z[0]') print >> sio, """ static __global__ void k... |
if True: gc.collect() | if False: gc.collect() | def f(): debug("starting a DebugMode call") for x in no_recycling: x[0] = None |
basictest(f, steps, sample_size, prefix='mrg cpu', inputs=input, allow_01=True, target_avg = mean) | basictest(f, steps, sample_size, prefix='mrg cpu', inputs=input, allow_01=True, target_avg = mean, mean_rtol=rtol) | def test_binomial(): |
basictest(f, steps, sample_size, prefix='mrg gpu', inputs=input, allow_01=True, target_avg = mean) | basictest(f, steps, sample_size, prefix='mrg gpu', inputs=input, allow_01=True, target_avg = mean, mean_rtol=rtol) | def test_binomial(): |
basictest(ff, steps, sample_size, prefix='numpy', allow_01=True, inputs=input, target_avg = mean) | basictest(ff, steps, sample_size, prefix='numpy', allow_01=True, inputs=input, target_avg = mean, mean_rtol=rtol) | def test_binomial(): |
basictest(f, steps, sample_size, target_avg=-5.0, target_std=2.0, prefix='mrg ', allow_01=True) | basictest(f, steps, sample_size, target_avg=-5.0, target_std=2.0, prefix='mrg ', allow_01=True, mean_rtol=rtol) | def test_normal0(): steps = 50 if mode in ['DEBUG_MODE','FAST_COMPILE']: sample_size = (99,30) else: sample_size = (999,50) print '' print 'ON CPU:' R = MRG_RandomStreams(234, use_cuda=False) n = R.normal(size=sample_size, avg=-5.0, std=2.0) f = theano.function([], n, mode=mode) theano.printing.debugprint(f) print '... |
basictest(f, steps, sample_size, target_avg=-5.0, target_std=2.0, prefix='gpu mrg ', allow_01=True) | basictest(f, steps, sample_size, target_avg=-5.0, target_std=2.0, prefix='gpu mrg ', allow_01=True, mean_rtol=rtol) | def test_normal0(): steps = 50 if mode in ['DEBUG_MODE','FAST_COMPILE']: sample_size = (99,30) else: sample_size = (999,50) print '' print 'ON CPU:' R = MRG_RandomStreams(234, use_cuda=False) n = R.normal(size=sample_size, avg=-5.0, std=2.0) f = theano.function([], n, mode=mode) theano.printing.debugprint(f) print '... |
basictest(ff, steps, sample_size, target_avg=-5.0, target_std=2.0, prefix='numpy ', allow_01=True) | basictest(ff, steps, sample_size, target_avg=-5.0, target_std=2.0, prefix='numpy ', allow_01=True, mean_rtol=rtol) | def test_normal0(): steps = 50 if mode in ['DEBUG_MODE','FAST_COMPILE']: sample_size = (99,30) else: sample_size = (999,50) print '' print 'ON CPU:' R = MRG_RandomStreams(234, use_cuda=False) n = R.normal(size=sample_size, avg=-5.0, std=2.0) f = theano.function([], n, mode=mode) theano.printing.debugprint(f) print '... |
corner_case = numpy.asarray([-2.5, -2., -1.5, -1., -0.5, -.51, -.49, 0., 0.49, 0.5, 0.9, 1, 1.5, 2, 2.5]) | corner_case = numpy.asarray([-2.5, -2., -1.5, -1., -0.5, -.51, -.49, 0, 0.49, 0.5, 0.9, 1, 1.5, 2, 2.5]) corner_case_grad = numpy.asarray([-2.5, -2., -1.5, -1., -0.5, -.51, -.49, 0.49, 0.5, 0.9, 1, 1.5, 2, 2.5]) | def inplace_check(inputs, outputs): # this used to be inputs[0] is output[0] # I changed it so that it was easier to satisfy by the DebugMode return numpy.all(inputs[0] == outputs[0]) |
corner_case = (corner_case,)) | corner_case = (corner_case_grad,)) | def inplace_check(inputs, outputs): # this used to be inputs[0] is output[0] # I changed it so that it was easier to satisfy by the DebugMode return numpy.all(inputs[0] == outputs[0]) |
good = _good_broadcast_unary_normal, grad = _grad_broadcast_unary_normal) | good = _good_broadcast_unary_normal) | def inplace_check(inputs, outputs): # this used to be inputs[0] is output[0] # I changed it so that it was easier to satisfy by the DebugMode return numpy.all(inputs[0] == outputs[0]) |
grad = _grad_broadcast_unary_normal, | def inplace_check(inputs, outputs): # this used to be inputs[0] is output[0] # I changed it so that it was easier to satisfy by the DebugMode return numpy.all(inputs[0] == outputs[0]) | |
_logger.warning('ERROR (%s): %s'% ( _logger_name, ' '.join(str(m) for m in msg))) | _logger.error('ERROR (%s): %s'% ( _logger_name, ' '.join(str(m) for m in msg))) | def error(*msg): _logger.warning('ERROR (%s): %s'% ( _logger_name, ' '.join(str(m) for m in msg))) |
_logger.warning('INFO (%s): %s'% ( _logger_name, ' '.join(str(m) for m in msg))) | _logger.info('INFO (%s): %s'% ( _logger_name, ' '.join(str(m) for m in msg))) | def info(*msg): _logger.warning('INFO (%s): %s'% ( _logger_name, ' '.join(str(m) for m in msg))) |
_logger.warning('DEBUG (%s): %s'% ( _logger_name, ' '.join(str(m) for m in msg))) | _logger.debug('DEBUG (%s): %s'% ( _logger_name, ' '.join(str(m) for m in msg))) | def debug(*msg): _logger.warning('DEBUG (%s): %s'% ( _logger_name, ' '.join(str(m) for m in msg))) |
_logger.warning("ERROR: Not using GPU. Initialisation of device %i failed. %s" %(device, e)) | _logger.error("ERROR: Not using GPU. Initialisation of device %i failed. %s" %(device, e)) | def use(device): global cuda_enabled, enabled_cuda if device.startswith('gpu'): device = int(device[3:]) elif device == 'cpu': device = -1 else: raise ValueError("Invalid device identifier", device) if use.device_number is None: # No successful call to use() has been made yet if device<0: return if device in [None,""]:... |
logging.getLogger('theano.sandbox.cuda').warning("WARNING: ignoring call to use(%s), GPU number %i is already in use." %(str(device), use.device_number)) | _logger.warning("WARNING: ignoring call to use(%s), GPU number %i is already in use." %(str(device), use.device_number)) | def use(device): global cuda_enabled, enabled_cuda if device.startswith('gpu'): device = int(device[3:]) elif device == 'cpu': device = -1 else: raise ValueError("Invalid device identifier", device) if use.device_number is None: # No successful call to use() has been made yet if device<0: return if device in [None,""]:... |
^ self.verbose \ | ^ hash(self.verbose) \ | def __hash__(self): # don't use hash(self.version) as hash(-1)==-2 and hash(-2)==-2 in python! return hash(type(self)) \ ^ hash(self.border_mode) \ ^ hash(self.subsample) \ ^ hash(self.logical_img_hw) \ ^ hash(self.logical_kern_hw) \ ^ hash(self.logical_kern_align_top) \ ^ self.version \ ^ self.verbose \ ^ hash(self.ks... |
assert len(f.maker.env.toposort()[0].env.toposort()[0].op.scalar_op.env.nodes)==4,len(f.maker.env.toposort()[0].env.toposort()[0].op.scalar_op.env.nodes) | assert len(f.maker.env.toposort()[0].env.toposort()[0].op.scalar_op.env.nodes)==2,len(f.maker.env.toposort()[0].env.toposort()[0].op.scalar_op.env.nodes) | def test_local_log_erfc(self): val = [-30,-27,-26,-11,-10,-3,-2,-1,0,1,2,3,10,11,26,27,28,30] if theano.config.mode in ["DebugMode", "DEBUG_MODE", "FAST_COMPILE"]: #python mode don't like the inv(0) val.remove(0) val = numpy.asarray(val) x = T.vector('x') |
axis = len(x.type.broadcastable) | axis = len(x.type.broadcastable)-1 | def max(x, axis=None): """ Return maximum elements obtained by iterating over given axis Default axis is the last one. :note: we return an error as numpy when we reduce a dim with a shape of 0 :note2: see MaxAndArgmax note for a difference between numpy and theano when axis==None """ if isinstance(axis,int) or axis i... |
m1.random = RandomStreams(234) | m1.random = RandomStreams(utt.fetch_seed()) | def test_ndim(self): """Test that the behaviour of 'ndim' optional parameter""" # 'ndim' is an optional integer parameter, specifying the length # of the 'shape', placed as first argument. |
m2.random = RandomStreams(234) | m2.random = RandomStreams(utt.fetch_seed()) | def test_ndim(self): """Test that the behaviour of 'ndim' optional parameter""" # 'ndim' is an optional integer parameter, specifying the length # of the 'shape', placed as first argument. |
m3.random = RandomStreams(234) | m3.random = RandomStreams(utt.fetch_seed()) | def test_ndim(self): """Test that the behaviour of 'ndim' optional parameter""" # 'ndim' is an optional integer parameter, specifying the length # of the 'shape', placed as first argument. |
def __lt__(self,other): return lt(self, other) def __le__(self,other): return le(self, other) def __gt__(self,other): return gt(self, other) def __ge__(self,other): return ge(self, other) | _is_nonzero = True def __lt__(self,other): rval = lt(self, other) rval._is_nonzero=False return rval def __le__(self,other): rval = le(self, other) rval._is_nonzero=False return rval def __gt__(self,other): rval = gt(self, other) rval._is_nonzero=False return rval def __ge__(self,other): rval = ge(self, other) rval._i... | def __lt__(self,other): return lt(self, other) |
mode._optimizer=mode._optimizer.including('local_elemwise_fusion') | mode._optimizer=mode._optimizer.including('local_elemwise_fusion','canonicalize') | def test_elemwise_fusion(self): shp=(5,5) #we need the optimisation enabled, debug do this. mode=cp(compile.mode.get_default_mode()) mode._optimizer=mode._optimizer.including('local_elemwise_fusion') self.do(mode, shared, shp) |
s=slice(0,10) | def speed_fusion(self, shared_fn = shared, gpu = False, s=None): """ param type s: a slice object param s: a slice to apply to the case to execute. If None, exec all case. """ shp=(3000,3000) | |
if mode in ['DEBUG_MODE','FAST_COMPILE']: | if mode in ['DEBUG_MODE','DebugMode','FAST_COMPILE']: | def test_uniform(): |
if mode in ['DEBUG_MODE','FAST_COMPILE']: | if mode in ['DEBUG_MODE','DebugMode','FAST_COMPILE']: | def test_binomial(): |
if mode in ['DEBUG_MODE','FAST_COMPILE']: | if mode in ['DEBUG_MODE','DebugMode','FAST_COMPILE']: | def test_normal0(): steps = 50 if mode in ['DEBUG_MODE','FAST_COMPILE']: sample_size = (25,30) rtol=.02 else: sample_size = (999,50) rtol=.01 sample_size_odd = (sample_size[0],sample_size[1]-1) x = tensor.matrix() for size,const_size,var_input,input in [(sample_size,sample_size,[],[]), (x.shape,sample_size,[x],[numpy.... |
a = numpy.empty(1e4, dtype="b1,f8")['f1'] b = numpy.empty(1e4, dtype="b1,f8")['f1'] | if config.floatX == 'float64': dtype="b1,f8" else: dtype="b1,f4" a = numpy.empty(1e4, dtype=dtype)['f1'] b = numpy.empty(1e4, dtype=dtype)['f1'] | def test_unalign(): a = numpy.empty(1e4, dtype="b1,f8")['f1'] b = numpy.empty(1e4, dtype="b1,f8")['f1'] assert not a.flags.aligned assert not b.flags.aligned a[:] = numpy.random.rand(len(a)) b[:] = numpy.random.rand(len(b)) out_numpy = 2*a + 3*b av,bv = tensor.vectors('ab') f = theano.function([av,bv],2*av+3*bv) f.mak... |
out[0][...] += v | out[0][...] = v | def perform(self, node, inputs, (out,)): v = inputs[0] sh = tuple([int(i) for i in inputs[1:]]) if out[0] is None or out[0].shape != sh: out[0] = numpy.zeros(sh, dtype=v.dtype) out[0][...] += v # broadcast v to fill us up |
if isinstance(x, float): | if isinstance(x, builtin_float): | def constant(x): if isinstance(x, float): for dtype in ['float32', 'float64']: x_ = theano._asarray(x, dtype=dtype) if numpy.all(x == x_): break x_ = None assert x_ is not None return ScalarConstant(Scalar(str(x_.dtype)), x) if isinstance(x, int): for dtype in ['int8', 'int16', 'int32', 'int64']: x_ = theano._asarray(x... |
if isinstance(x, int): | if isinstance(x, builtin_int): | def constant(x): if isinstance(x, float): for dtype in ['float32', 'float64']: x_ = theano._asarray(x, dtype=dtype) if numpy.all(x == x_): break x_ = None assert x_ is not None return ScalarConstant(Scalar(str(x_.dtype)), x) if isinstance(x, int): for dtype in ['int8', 'int16', 'int32', 'int64']: x_ = theano._asarray(x... |
if isinstance(x, complex): | if isinstance(x, builtin_complex): | def constant(x): if isinstance(x, float): for dtype in ['float32', 'float64']: x_ = theano._asarray(x, dtype=dtype) if numpy.all(x == x_): break x_ = None assert x_ is not None return ScalarConstant(Scalar(str(x_.dtype)), x) if isinstance(x, int): for dtype in ['int8', 'int16', 'int32', 'int64']: x_ = theano._asarray(x... |
} """ %locals() | } """ %locals() print >> sio, """ if (CudaNdarray_SIZE(%(z)s)) { """ % locals() | def c_code(self, node, name, (x,), (z,), sub): |
return (14,) | return (15,) | def c_code_cache_version(self): #return () return (14,) |
(fx*fy*fz*fw+fx+fy+fz+fw,(fw,fx,fy,fz),(fwv,fxv,fyv,fzv),2,fxv*fyv*fzv*fwv+fxv+fyv+fzv+fwv,'float32'), | (fx*fy*fz*fw+fx+fy+fz+fw,(fw,fx,fy,fz),(fwv,fxv,fyv,fzv),1,fxv*fyv*fzv*fwv+fxv+fyv+fzv+fwv,'float32'), | def my_init(shp, dtype='float64', num=0): #ret = theano._asarray(numpy.random.rand(*shp),dtype=dtype) ret = numpy.zeros(shp, dtype=dtype)+num return ret |
rval.append('-Xlinker,-rpath,'+t[2:]) | rval.append('-Wl,-rpath,'+t[2:]) | def ldflags(libs=True, flags=False, libs_dir=False, include_dir=False): """Return a list of libraries against which an Op's object file should be linked to benefit from a BLAS implementation. Default: ['blas'], but configuration variable config.blas.ldflags overrides this. """ rval = [] if libs_dir: found_dyn=False di... |
thing.name = name | def AddConfigVar(name, doc, thing, cls=TheanoConfigParser): if cls == TheanoConfigParser: thing.fullname = name if hasattr(TheanoConfigParser, name): raise ValueError('This name is already taken') parts = name.split('.') if len(parts) > 1: # set up a subobject if not hasattr(cls, parts[0]): class SubObj(object): pass s... | |
val_str = fetch_val_for_key(self.name) | val_str = fetch_val_for_key(self.fullname) | def __get__(self, *args): #print "GETTING PARAM", self.name, self, args if not hasattr(self, 'val'): try: val_str = fetch_val_for_key(self.name) except KeyError: val_str = self.default self.__set__(None, val_str) #print "RVAL", self.val return self.val |
% (val, self.name, self.all), val) | % (val, self.fullname, self.all), val) | def filter(val): if val in self.all: return val else: raise ValueError('Invalid value (%s) for configuration variable "%s". Legal options are %s' % (val, self.name, self.all), val) |
% (val, self.name), val) | % (val, self.fullname), val) | def filter(val): casted_val = mytype(val) if callable(is_valid): if is_valid(casted_val): return casted_val else: raise ValueError('Invalid value (%s) for configuration variable "%s".' % (val, self.name), val) return casted_val |
libs = ldflags() | l = ldflags() | def ldflags(libs=True, flags=False, libs_dir=False, include_dir=False): """Return a list of libraries against which an Op's object file should be linked to benefit from a BLAS implementation. Default: ['blas'], but configuration variable config.blas.ldflags overrides this. """ rval = [] if libs_dir: found_dyn=False di... |
if any([f.find(l)>=0 for l in libs]): | if any([f.find(l)>=0 for l in l]): | def ldflags(libs=True, flags=False, libs_dir=False, include_dir=False): """Return a list of libraries against which an Op's object file should be linked to benefit from a BLAS implementation. Default: ['blas'], but configuration variable config.blas.ldflags overrides this. """ rval = [] if libs_dir: found_dyn=False di... |
otimes = [(t/local_time, t, a, op_cimpl[a], op_call[a]) for a, t in op_time.items()] | otimes = [(t/local_time, t, a, op_cimpl.get(a, 0), op_call.get(a, 0)) for a, t in op_time.items()] | def print_summary_(fct_name, local_time, compile_time, fct_call_time, fct_call, apply_time, apply_call, op_cimpl, n_apply_to_print=15, n_ops_to_print=20, print_apply=True): """ do the actual printing of print_summary and print_diff_summary. |
sop_c[type(a)]=sop_c[type(a)] and op_cimpl[a] | sop_c[type(a)]=sop_c[type(a)] and op_cimpl.get(a, False) | def print_summary_(fct_name, local_time, compile_time, fct_call_time, fct_call, apply_time, apply_call, op_cimpl, n_apply_to_print=15, n_ops_to_print=20, print_apply=True): """ do the actual printing of print_summary and print_diff_summary. |
(fx-(fy%fz),(fx,fy,fz),(fxv,fyv,fzv),2,fxv-(fyv%fzv),'float32'), | (fx-(fy%fz),(fx,fy,fz),(fxv,fyv,fzv),1,fxv-(fyv%fzv),'float32'), | def my_init(shp, dtype='float64', num=0): #ret = theano._asarray(numpy.random.rand(*shp),dtype=dtype) ret = numpy.zeros(shp, dtype=dtype)+num return ret |
else: | elif self.imshp != self.imshp_logical or self.kshp != self.kshp_logical: | def c_code(self, node, name, (img2d, filtersflipped), (z, ), sub): if node.inputs[0].type.dtype != node.inputs[1].type.dtype: raise NotImplementedError() assert node.inputs[0].type.dtype == node.inputs[1].type.dtype d=locals() d.update(sub) |
f2 = theano.function([a],b) | f2 = theano.function([a],b, mode=mode_without_gpu) | def test_sum(): """ test sum pattern 1, 11, 10, 100, 110, 001, 111, 1011, 1111 TODO: test with broadcast """ for shape, pattern in [((5,),[0]), ((5,4),[0,1]),((5,4),[0]), ((5,4,3),[0]),((5,4,3),[0,1]),((5,4,3),[2]),((5,4,3),[0,1,2]), ((5,4,3,2),[0,1,2,3]), ((5,4,3,2),[0,2,3])]: a = tensor.TensorType('float32',(False,)... |
f = theano.function([a],b) | f = theano.function([a],b, mode=mode_without_gpu) | def test_sum(): """ test sum pattern 1, 11, 10, 100, 110, 001, 111, 1011, 1111 TODO: test with broadcast """ for shape, pattern in [((5,),[0]), ((5,4),[0,1]),((5,4),[0]), ((5,4,3),[0]),((5,4,3),[0,1]),((5,4,3),[2]),((5,4,3),[0,1,2]), ((5,4,3,2),[0,1,2,3]), ((5,4,3,2),[0,2,3])]: a = tensor.TensorType('float32',(False,)... |
f = theano.function([a], c) | f = theano.function([a], c, mode=mode_without_gpu) | def test_reshape(): a = tcn.CudaNdarrayType((False,))() b = tcn.CudaNdarrayType((False,False))() c = T.reshape(a, [2,3]) #basic f = theano.function([a], c) fv = f(cuda_ndarray.CudaNdarray(theano._asarray([0,1,2,3,4,5],dtype='float32'))) assert numpy.all(fv == numpy.asarray([[0,1,2], [3,4,5]])) #test that it works wi... |
f_sub = theano.function([a,b], c-b) | f_sub = theano.function([a,b], c-b, mode=mode_without_gpu) | def test_reshape(): a = tcn.CudaNdarrayType((False,))() b = tcn.CudaNdarrayType((False,False))() c = T.reshape(a, [2,3]) #basic f = theano.function([a], c) fv = f(cuda_ndarray.CudaNdarray(theano._asarray([0,1,2,3,4,5],dtype='float32'))) assert numpy.all(fv == numpy.asarray([[0,1,2], [3,4,5]])) #test that it works wi... |
a = tcn.shared_constructor(numpy.random.rand(4,4), 'a') | a = tcn.shared_constructor(theano._asarray(numpy.random.rand(4,4), dtype='float32'), 'a') | def test_elemwise0(): a = tcn.shared_constructor(numpy.random.rand(4,4), 'a') b = tensor.fmatrix() f = pfunc([b], [], updates=[(a, a+b)], mode=mode_with_gpu) a0 = a.value * 1.0 print 'BEFORE ADD', a.value for i, node in enumerate(f.maker.env.toposort()): print i, node f(numpy.ones((4,4))) print 'AFTER ADD', a.value... |
a = tcn.shared_constructor(numpy.random.rand(*shape)+0.5, 'a') | a = tcn.shared_constructor(theano._asarray(numpy.random.rand(*shape), dtype='float32')+0.5, 'a') | def test_elemwise1(): """ Several kinds of elemwise expressions with no broadcasting, non power-of-two shape """ shape = (3,4) a = tcn.shared_constructor(numpy.random.rand(*shape)+0.5, 'a') b = tensor.fmatrix() #let debugmode catch any mistakes print >> sys.stdout, "STARTING FUNCTION 1" f = pfunc([b], [], updates=[(a... |
f(numpy.random.rand(*shape)+0.3) | f(theano._asarray(numpy.random.rand(*shape), dtype='float32')+0.3) | def test_elemwise1(): """ Several kinds of elemwise expressions with no broadcasting, non power-of-two shape """ shape = (3,4) a = tcn.shared_constructor(numpy.random.rand(*shape)+0.5, 'a') b = tensor.fmatrix() #let debugmode catch any mistakes print >> sys.stdout, "STARTING FUNCTION 1" f = pfunc([b], [], updates=[(a... |
a = tcn.shared_constructor(rng.rand(*shape), name=None) | a = tcn.shared_constructor(theano._asarray(rng.rand(*shape),dtype='float32'), name=None) | def test_elemwise2(): """ Several kinds of elemwise expressions with dimension permutations """ rng = numpy.random.RandomState(int(time.time())) print 'random?', rng.rand(3) shape = (3,5) for pattern in [(0,1), (1,0)]: a = tcn.shared_constructor(rng.rand(*shape), name=None) b = tensor.Tensor(dtype='float32', broadcasta... |
f(rng.rand(*shape)*.3) | f(theano._asarray(rng.rand(*shape),dtype='float32')*.3) | def test_elemwise2(): """ Several kinds of elemwise expressions with dimension permutations """ rng = numpy.random.RandomState(int(time.time())) print 'random?', rng.rand(3) shape = (3,5) for pattern in [(0,1), (1,0)]: a = tcn.shared_constructor(rng.rand(*shape), name=None) b = tensor.Tensor(dtype='float32', broadcasta... |
a = tcn.shared_constructor(rng.rand(*shape), 'a') | a = tcn.shared_constructor(theano._asarray(rng.rand(*shape),dtype='float32'), 'a') | def test_elemwise2(): """ Several kinds of elemwise expressions with dimension permutations """ rng = numpy.random.RandomState(int(time.time())) print 'random?', rng.rand(3) shape = (3,5) for pattern in [(0,1), (1,0)]: a = tcn.shared_constructor(rng.rand(*shape), name=None) b = tensor.Tensor(dtype='float32', broadcasta... |
f(rng.rand(*shape)) | f(theano._asarray(rng.rand(*shape),dtype='float32')) | def test_elemwise2(): """ Several kinds of elemwise expressions with dimension permutations """ rng = numpy.random.RandomState(int(time.time())) print 'random?', rng.rand(3) shape = (3,5) for pattern in [(0,1), (1,0)]: a = tcn.shared_constructor(rng.rand(*shape), name=None) b = tensor.Tensor(dtype='float32', broadcasta... |
a = tcn.shared_constructor(numpy.random.rand(*shape), 'a') | a = tcn.shared_constructor(theano._asarray(numpy.random.rand(*shape), dtype='float32'), 'a') | def test_elemwise3(): """ Several kinds of elemwise expressions with dimension permutations and broadcasting""" shape = (3,4,5,6) a = tcn.shared_constructor(numpy.random.rand(*shape), 'a') b = tensor.fvector() print b.type print tensor.constant(1).type print (1 + b).type print (1 + b**a).type print tensor.exp((1 + b**... |
f(numpy.random.rand(6)) | f(theano._asarray(numpy.random.rand(6), dtype='float32')) | def test_elemwise3(): """ Several kinds of elemwise expressions with dimension permutations and broadcasting""" shape = (3,4,5,6) a = tcn.shared_constructor(numpy.random.rand(*shape), 'a') b = tensor.fvector() print b.type print tensor.constant(1).type print (1 + b).type print (1 + b**a).type print tensor.exp((1 + b**... |
a = tcn.shared_constructor(numpy.random.rand(*shape), 'a') | a = tcn.shared_constructor(theano._asarray(numpy.random.rand(*shape), dtype='float32'), 'a') | def test_elemwise4(): """ Test that two vectors can be broadcast to form an outer product (by performing rank-1 matrix update""" shape = (3,4) a = tcn.shared_constructor(numpy.random.rand(*shape), 'a') b = tensor.fvector() c = tensor.fvector() f = pfunc([b,c], [], updates=[(a, (a+b.dimshuffle('x', 0)*c.dimshuffle(0, '... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.