提交 fc66c3fd authored 作者: lamblin's avatar lamblin

Merge pull request #1470 from nouiz/split_file

Split file
......@@ -727,12 +727,19 @@ copy_reg.pickle(Function, _pickle_Function)
###
class SanityCheckFunction(Function):
"""Deprecated. It is not used and not tested anywhere in Theano!
Also, we should remove the check_equal and related function in
this file, and use Type.values_equals() instead.
"""
def __init__(self, others, check_equal, *args, **kwargs):
super(SanityCheckFunction, self).__init__(*args, **kwargs)
self.others = others
self.check_equal = check_equal
# DEPRECATED? Is this just for DualLinker?
warnings.warn("SanityCheckFunction is deprecated")
def __setitem__(self, item, value):
super(SanityCheckFunction, self).__setitem__(item, value)
......
......@@ -78,4 +78,4 @@ from theano.gof.type import \
Type, Generic, generic
from theano.gof.utils import \
object2, MethodNotDefined
hashtype, object2, MethodNotDefined
......@@ -22,6 +22,11 @@ def hashgen():
hashgen.next = 0
def hashtype(self):
t = type(self)
return hash(t.__name__) ^ hash(t.__module__)
class MethodNotDefined(Exception):
"""
To be raised by functions defined as part of an interface.
......
......@@ -437,8 +437,8 @@ acceptable_ops = (theano.tensor.basic.Dot,
theano.tensor.basic.Shape,
theano.tensor.basic.SpecifyShape,
theano.tensor.basic.MaxAndArgmax,
theano.tensor.basic.Subtensor,
theano.tensor.basic.IncSubtensor,
theano.tensor.Subtensor,
theano.tensor.IncSubtensor,
theano.tensor.basic.Rebroadcast,
theano.tensor.basic.Alloc,
theano.tensor.elemwise.Elemwise,
......
......@@ -798,7 +798,7 @@ __global__ void k_take_3(const int d0, const int d1, const int d2,
// This prevent us from setting it to 0 before each use
static int* err_var = NULL;
// We try to be similat to the PyArray_TakeFrom function
// We try to be similar to the PyArray_TakeFrom function
//http://docs.scipy.org/doc/numpy/reference/c-api.array.html
//TODO: support other clip mode then raise(clip, wrap)
//self is the input that we copy data from.
......
......@@ -912,8 +912,9 @@ class T_Join_and_Split(theano.tensor.tests.test_basic.T_Join_and_Split):
self.shared = cuda.shared_constructor
import theano.tensor.tests.test_subtensor
# This is to don't duplicate test.
class T_subtensor(theano.tensor.tests.test_basic.T_subtensor):
class T_subtensor(theano.tensor.tests.test_subtensor.T_subtensor):
# This prevents nose from printing method docstrings instead of method
# names
......@@ -933,7 +934,7 @@ class T_subtensor(theano.tensor.tests.test_basic.T_subtensor):
cuda.GpuAdvancedSubtensor1, cuda.GpuAdvancedIncSubtensor1)
def __init__(self, name):
return super(theano.tensor.tests.test_basic.T_subtensor,
return super(theano.tensor.tests.test_subtensor.T_subtensor,
self).__init__(name)
def test_adv_sub1_fast(self):
......
......@@ -831,6 +831,8 @@ det = Det()
def trace(X):
"""
Returns the sum of diagonal elements of matrix X.
:note: work on GPU since 0.6rc4.
"""
return extract_diag(X).sum()
......
......@@ -691,7 +691,7 @@ class ScanSaveMem(gof.Optimizer):
break
# 2.2 non-subtensor nodes
#=> output needs all its intermediate values
elif not isinstance(cl.op, tensor.basic.Subtensor):
elif not isinstance(cl.op, tensor.Subtensor):
global_nsteps = None
slices[i] = None
break
......@@ -699,7 +699,7 @@ class ScanSaveMem(gof.Optimizer):
#=> output might need to store just a subset of its values
else:
# 2.3.1 extract idx list of subtensor
this_slice = tensor.basic.get_idx_list(cl.inputs,
this_slice = tensor.get_idx_list(cl.inputs,
cl.op.idx_list)
if this_slice is None:
# if unable to extract idx_list
......@@ -719,7 +719,7 @@ class ScanSaveMem(gof.Optimizer):
length = shape_of[out][0]
except KeyError:
length = out.shape[0]
cf_slice = tensor.basic.get_canonical_form_slice(
cf_slice = tensor.get_canonical_form_slice(
this_slice[0], length)
slices[i] += [(cf_slice, this_slice)]
......@@ -795,11 +795,11 @@ class ScanSaveMem(gof.Optimizer):
if type(cl) == str:
store_steps[i] = 0
break
elif not isinstance(cl.op, tensor.basic.Subtensor):
elif not isinstance(cl.op, tensor.Subtensor):
store_steps[i] = 0
break
else:
this_slice = tensor.basic.get_idx_list(cl.inputs,
this_slice = tensor.get_idx_list(cl.inputs,
cl.op.idx_list)
if this_slice is None:
store_steps[i] = 0
......@@ -817,7 +817,7 @@ class ScanSaveMem(gof.Optimizer):
length = shape_of[out][0]
except KeyError:
length = out.shape[0]
cf_slice = tensor.basic.get_canonical_form_slice(
cf_slice = tensor.get_canonical_form_slice(
this_slice[0], length)
if isinstance(cf_slice[0], slice):
......@@ -973,9 +973,9 @@ class ScanSaveMem(gof.Optimizer):
nw_slice = (fslice,) + tuple(old_slices[1:])
nw_pos = inv_compress_map[idx]
subtens = tensor.basic.Subtensor(nw_slice)
subtens = tensor.Subtensor(nw_slice)
# slice inputs
sl_ins = tensor.basic.Subtensor.collapse(
sl_ins = tensor.Subtensor.collapse(
nw_slice,
lambda entry: isinstance(entry,
tensor.Variable))
......@@ -1014,8 +1014,8 @@ class ScanSaveMem(gof.Optimizer):
nw_slice = (sanitize(position),) + \
tuple(old_slices[1:])
subtens = tensor.basic.Subtensor(nw_slice)
sl_ins = tensor.basic.Subtensor.collapse(
subtens = tensor.Subtensor(nw_slice)
sl_ins = tensor.Subtensor.collapse(
nw_slice,
lambda entry: isinstance(entry,
tensor.Variable))
......
......@@ -4,6 +4,8 @@ __docformat__ = "restructuredtext en"
import warnings
from theano.tensor.basic import *
from theano.tensor.subtensor import *
from theano.tensor.type_other import *
from theano.tensor import opt
from theano.tensor import opt_uncanonicalize
......
This source diff could not be displayed because it is too large. You can view the blob instead.
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论