提交 f9a54210 authored 作者: Brandon T. Willard's avatar Brandon T. Willard 提交者: Brandon T. Willard

Remove theano.gof.utils.hashtype

上级 e1d46639
...@@ -43,4 +43,4 @@ from theano.gof.toolbox import ( ...@@ -43,4 +43,4 @@ from theano.gof.toolbox import (
Validator, Validator,
) )
from theano.gof.type import CEnumType, EnumList, EnumType, Generic, Type, generic from theano.gof.type import CEnumType, EnumList, EnumType, Generic, Type, generic
from theano.gof.utils import MethodNotDefined, hashtype, object2 from theano.gof.utils import MethodNotDefined, object2
...@@ -69,8 +69,7 @@ def simple_extract_stack(f=None, limit=None, skips=None): ...@@ -69,8 +69,7 @@ def simple_extract_stack(f=None, limit=None, skips=None):
def add_tag_trace(thing, user_line=None): def add_tag_trace(thing, user_line=None):
""" """Add tag.trace to a node or variable.
Add tag.trace to an node or variable.
The argument is returned after being affected (inplace). The argument is returned after being affected (inplace).
...@@ -145,11 +144,6 @@ def get_variable_trace_string(v): ...@@ -145,11 +144,6 @@ def get_variable_trace_string(v):
return sio.getvalue() return sio.getvalue()
def hashtype(self):
t = type(self)
return hash(t.__name__) ^ hash(t.__module__)
# Object to mark that a parameter is undefined (useful in cases where # Object to mark that a parameter is undefined (useful in cases where
# None is a valid value with defined semantics) # None is a valid value with defined semantics)
undef = object() undef = object()
......
...@@ -10,7 +10,7 @@ import theano ...@@ -10,7 +10,7 @@ import theano
from theano import gof from theano import gof
from theano import scalar as scal from theano import scalar as scal
from theano.configdefaults import config from theano.configdefaults import config
from theano.gof import MethodNotDefined, ParamsType, hashtype from theano.gof import MethodNotDefined, ParamsType
from theano.gof.graph import Apply from theano.gof.graph import Apply
from theano.gof.op import COp, Op from theano.gof.op import COp, Op
from theano.gof.type import Type from theano.gof.type import Type
...@@ -1422,25 +1422,11 @@ class IncSubtensor(COp): ...@@ -1422,25 +1422,11 @@ class IncSubtensor(COp):
self.set_instead_of_inc = set_instead_of_inc self.set_instead_of_inc = set_instead_of_inc
def __hash__(self): def __hash__(self):
msg = [] idx_list = tuple(
for entry in self.idx_list: (entry.start, entry.stop, entry.step) if isinstance(entry, slice) else entry
if isinstance(entry, slice): for entry in self.idx_list
msg += [(entry.start, entry.stop, entry.step)]
else:
msg += [entry]
idx_list = tuple(msg)
# backport
# idx_list = tuple((entry.start, entry.stop, entry.step)
# if isinstance(entry, slice)
# else entry
# for entry in self.idx_list)
return (
hashtype(self)
^ hash(idx_list)
^ hash(self.inplace)
^ hash(self.set_instead_of_inc)
) )
return hash((type(self), idx_list, self.inplace, self.set_instead_of_inc))
def __str__(self): def __str__(self):
indices = [] indices = []
......
...@@ -6,7 +6,8 @@ import numpy as np ...@@ -6,7 +6,8 @@ import numpy as np
import theano import theano
from theano import scalar as scal from theano import scalar as scal
from theano.configdefaults import config from theano.configdefaults import config
from theano.gof import Type, Variable, hashtype from theano.gof.graph import Variable
from theano.gof.type import Type
from theano.misc.safe_asarray import _asarray from theano.misc.safe_asarray import _asarray
...@@ -343,8 +344,7 @@ class TensorType(Type): ...@@ -343,8 +344,7 @@ class TensorType(Type):
return values_eq_approx(a, b, allow_remove_inf, allow_remove_nan, rtol, atol) return values_eq_approx(a, b, allow_remove_inf, allow_remove_nan, rtol, atol)
def __hash__(self): def __hash__(self):
"""Hash equal for same kinds of TensorType""" return hash((type(self), self.dtype, self.broadcastable))
return hashtype(self) ^ hash(self.dtype) ^ hash(self.broadcastable)
ndim = property(lambda self: len(self.broadcastable), doc="number of dimensions") ndim = property(lambda self: len(self.broadcastable), doc="number of dimensions")
""" """
......
...@@ -5,7 +5,9 @@ ...@@ -5,7 +5,9 @@
import numpy as np import numpy as np
import theano import theano
from theano.gof import Apply, Constant, Generic, Op, Type, hashtype from theano.gof.graph import Apply, Constant
from theano.gof.op import Op
from theano.gof.type import Generic, Type
from theano.gradient import DisconnectedType from theano.gradient import DisconnectedType
...@@ -61,7 +63,7 @@ class SliceType(Type): ...@@ -61,7 +63,7 @@ class SliceType(Type):
return type(self) == type(other) return type(self) == type(other)
def __hash__(self): def __hash__(self):
return hashtype(self) return hash(type(self))
@staticmethod @staticmethod
def may_share_memory(a, b): def may_share_memory(a, b):
......
...@@ -8,7 +8,6 @@ import numpy as np ...@@ -8,7 +8,6 @@ import numpy as np
import theano import theano
from theano.configdefaults import config from theano.configdefaults import config
from theano.gof import Constant, Variable from theano.gof import Constant, Variable
from theano.gof.utils import hashtype
from theano.scalar import ComplexError, IntegerDivisionError from theano.scalar import ComplexError, IntegerDivisionError
from theano.tensor.type import TensorType from theano.tensor.type import TensorType
from theano.tensor.utils import hash_from_ndarray from theano.tensor.utils import hash_from_ndarray
...@@ -923,7 +922,7 @@ class TensorConstantSignature(tuple): ...@@ -923,7 +922,7 @@ class TensorConstantSignature(tuple):
def __hash__(self): def __hash__(self):
t, d = self t, d = self
return hashtype(self) ^ hash(t) ^ hash(d.shape) ^ hash(self.sum) return hash((type(self), t, d.shape, self.sum))
def theano_hash(self): def theano_hash(self):
_, d = self _, d = self
......
from theano import gof from theano.gof.type import Type
class TypedListType(gof.Type): class TypedListType(Type):
""" """
Parameters Parameters
...@@ -18,7 +18,7 @@ class TypedListType(gof.Type): ...@@ -18,7 +18,7 @@ class TypedListType(gof.Type):
if depth < 0: if depth < 0:
raise ValueError("Please specify a depth superior or" "equal to 0") raise ValueError("Please specify a depth superior or" "equal to 0")
if not isinstance(ttype, gof.Type): if not isinstance(ttype, Type):
raise TypeError("Expected a Theano Type") raise TypeError("Expected a Theano Type")
if depth == 0: if depth == 0:
...@@ -59,7 +59,7 @@ class TypedListType(gof.Type): ...@@ -59,7 +59,7 @@ class TypedListType(gof.Type):
return type(self) == type(other) and self.ttype == other.ttype return type(self) == type(other) and self.ttype == other.ttype
def __hash__(self): def __hash__(self):
return gof.hashtype(self) ^ hash(self.ttype) return hash((type(self), self.ttype))
def __str__(self): def __str__(self):
return "TypedList <" + str(self.ttype) + ">" return "TypedList <" + str(self.ttype) + ">"
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论