提交 b53a311f authored 作者: Frederic's avatar Frederic

Use the right mechanism to change the CDataType Constant signature

上级 fd7d0582
......@@ -1198,14 +1198,7 @@ class CLinker(link.Linker):
# It is important that a variable (i)
# yield a 'position' that reflects its role in code_gen()
if isinstance(i, graph.Constant): # orphans
if isinstance(i.type, theano.gof.type.CDataType):
# The Op can't access the data, so it can't change
# the code depending of it. So there is no need to
# put it in the signature. Also, under pytyon 2,
# PyCObject aren't pickable. So this putting it in
# the key would disable the cache for this module.
isig = "PyCObject"
elif id(i) not in constant_ids:
if id(i) not in constant_ids:
isig = (i.signature(), topological_pos, i_idx)
# If the Theano constant provides a strong hash
# (no collision for transpose, 2, 1, 0, -1, -2,
......
......@@ -595,3 +595,14 @@ if (py_%(name)s == NULL) { %(freefunc)s(%(name)s); }
def __str__(self):
return "%s{%s}" % (self.__class__.__name__, self.ctype)
class CDataTypeConstant(graph.Constant):
def signature(self):
# The Op.c_code* methoss can't access the data, so it can't
# change the code depending of it. So there is no need to put
# it in the signature. Also, under Python 2, PyCObject aren't
# pickable. So using the PyCObject in the signature would
# disable the c code cache for op that have it as an input.
return (self.type,)
CDataType.Constant = CDataTypeConstant
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论