提交 4ba730a0 authored 作者: Arnaud Bergeron's avatar Arnaud Bergeron

Some changes from review.

上级 4f59ff7b
......@@ -1282,15 +1282,6 @@ class CLinker(link.Linker):
return ((), sig)
return version, sig
def get_src_code(self):
"""
Returns the source code for the module represented by this linker.
"""
if not hasattr(self, '_source'):
mod = self.build_dynamic_module()
self._source = mod.code()
return self._source
def compile_cmodule(self, location=None):
"""
This compiles the source code for this linker and returns a
......@@ -1298,7 +1289,7 @@ class CLinker(link.Linker):
"""
if location is None:
location = cmodule.dlimport_workdir(config.compiledir)
mod = self.build_dynamic_module()
mod = self.get_dynamic_module()
c_compiler = self.c_compiler()
libs = self.libraries()
preargs = self.compile_args()
......@@ -1335,9 +1326,12 @@ class CLinker(link.Linker):
release_lock()
return module
def build_dynamic_module(self):
def get_dynamic_module(self):
"""Return a cmodule.DynamicModule instance full of the code
for our fgraph.
This method is cached on the first call so it can be called
multiple times without penalty.
"""
if not hasattr(self, '_mod'):
self.code_gen()
......
......@@ -618,6 +618,9 @@ class ModuleCache(object):
"""
def _get_module(self, name):
"""
Fetch a compiled module from the loaded cache or the disk.
"""
if name not in self.module_from_name:
_logger.debug('loading name %s', name)
self.module_from_name[name] = dlimport(name)
......@@ -688,7 +691,7 @@ class ModuleCache(object):
key_pkl)
rmtree(root, ignore_nocleanup=True,
msg="missing module file", level=logging.INFO)
continue
continue
if (time_now - last_access_time(entry)) < age_thresh_use:
_logger.debug('refresh adding %s', key_pkl)
......@@ -725,7 +728,7 @@ class ModuleCache(object):
# not yet been imported (e.g. when running two
# different Theano-based scripts). They are not
# necessarily broken, but we cannot load them
# here.
# now. They will be loaded later if needed.
pass
continue
......@@ -762,7 +765,7 @@ class ModuleCache(object):
rmtree(root, ignore_nocleanup=True,
msg='module file path mismatch',
level=logging.INFO)
continue
continue
# Find unversioned keys from other processes.
# TODO: check if this can happen at all
......@@ -923,8 +926,6 @@ class ModuleCache(object):
def _get_from_hash(self, module_hash, key, keep_lock=False):
if module_hash in self.module_hash_to_key_data:
_logger.debug("Duplicated module! Will re-use the "
"previous one")
key_data = self.module_hash_to_key_data[module_hash]
module = self._get_from_key(None, key_data)
with compilelock.lock_ctx(keep_lock=keep_lock):
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论