Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
9950ce08
提交
9950ce08
authored
11月 06, 2013
作者:
Pascal Lamblin
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #1580 from nouiz/deprecated
[MRG]Deprecated
上级
1d639d66
7c42bebe
全部展开
隐藏空白字符变更
内嵌
并排
正在显示
23 个修改的文件
包含
98 行增加
和
85 行删除
+98
-85
MANIFEST.in
MANIFEST.in
+1
-0
fibby.txt
doc/extending/fibby.txt
+3
-3
basic.txt
doc/library/tensor/basic.txt
+32
-3
test_debugmode.py
theano/compile/tests/test_debugmode.py
+4
-4
cmodule.py
theano/gof/cmodule.py
+1
-1
lazylinker_c.c
theano/gof/lazylinker_c.c
+0
-0
lazylinker_c.py
theano/gof/lazylinker_c.py
+1
-4
check_blas.py
theano/misc/check_blas.py
+1
-0
basic_ops.py
theano/sandbox/cuda/basic_ops.py
+55
-70
rng_mrg.py
theano/sandbox/rng_mrg.py
+0
-0
scan_perform.c
theano/scan_module/scan_perform.c
+0
-0
scan_perform.pyx
theano/scan_module/scan_perform.pyx
+0
-0
scan_perform_ext.py
theano/scan_module/scan_perform_ext.py
+0
-0
basic.py
theano/sparse/basic.py
+0
-0
opt.py
theano/sparse/opt.py
+0
-0
basic.py
theano/tensor/basic.py
+0
-0
elemwise.py
theano/tensor/elemwise.py
+0
-0
nnet.py
theano/tensor/nnet/nnet.py
+0
-0
subtensor.py
theano/tensor/subtensor.py
+0
-0
test_blas.py
theano/tensor/tests/test_blas.py
+0
-0
test_inc_subtensor.py
theano/tensor/tests/test_inc_subtensor.py
+0
-0
type.py
theano/tensor/type.py
+0
-0
test_tutorial.py
theano/tests/test_tutorial.py
+0
-0
没有找到文件。
MANIFEST.in
浏览文件 @
9950ce08
global-include *.txt
global-include *.c
global-include *.cu
global-include *.cuh
global-include *.sh
...
...
doc/extending/fibby.txt
浏览文件 @
9950ce08
...
...
@@ -67,9 +67,9 @@ you should check the strides and alignment.
if (!%(y)s)
%(fail)s;
{//New scope needed to make compilation work
dtype_%(y)s * y = (dtype_%(y)s*)
%(y)s->data
;
dtype_%(x)s * x = (dtype_%(x)s*)
%(x)s->data
;
for (int i = 2; i <
%(x)s->dimensions
[0]; ++i)
dtype_%(y)s * y = (dtype_%(y)s*)
PyArray_DATA(%(y)s)
;
dtype_%(x)s * x = (dtype_%(x)s*)
PyArray_DATA(%(x)s)
;
for (int i = 2; i <
PyArray_DIMS(%(x)s)
[0]; ++i)
y[i] = y[i-1]*y[i-2] + x[i];
}
""" % locals()
...
...
doc/library/tensor/basic.txt
浏览文件 @
9950ce08
...
...
@@ -420,7 +420,9 @@ TensorVariable
.. class:: _tensor_py_operators(object)
This mix-in class adds convenient attributes, methods, and support for Python operators (see :ref:`tensor_operator_support`).
This mix-in class adds convenient attributes, methods, and support
to TensorVariable, TensorConstant and TensorSharedVariable for
Python operators (see :ref:`tensor_operator_support`).
.. attribute:: type
...
...
@@ -472,6 +474,10 @@ TensorVariable
See :func:`flatten`.
.. method:: ravel()
return self.flatten(). For NumPy compatibility.
.. attribute:: T
Transpose of this tensor.
...
...
@@ -485,8 +491,31 @@ TensorVariable
same vector! Use `reshape` or `dimshuffle` to turn your vector
into a row or column matrix.
.. method:: {any,all}(axis=None, keepdims=False)
.. method:: {sum,prod,mean}(axis=None, dtype=None, keepdims=False, acc_dtype=None)
.. method:: {var,std,min,max,argmin,argmax}(axis=None, keepdims=False),
.. method:: diagonal(offset=0, axis1=0, axis2=1)
.. method:: astype(dtype)
.. method:: take(indices, axis=None, mode='raise')
.. method:: copy()
.. method:: norm(L, axis=None)
.. method:: nonzero(self, return_matrix=False)
.. method:: nonzero_values(self)
.. method:: sort(self, axis=-1, kind='quicksort', order=None)
.. method:: argsort(self, axis=-1, kind='quicksort', order=None)
.. method:: clip(self, a_min, a_max)
.. method:: conf()
.. method:: repeat(repeats, axis=None)
.. method:: round(mode="half_away_from_zero")
.. method:: trace()
.. method:: get_scalar_constant_value()
.. method:: zeros_like(model, dtype=None)
All the above methods are equivalent to NumPy for Theano on the current tensor.
.. method:: __{abs,neg,lt,le,gt,ge,invert,and,or,add,sub,mul,div,truediv,floordiv}__
Those elemwise operation are supported via Python syntax.
Shaping and Shuffling
=====================
...
...
theano/compile/tests/test_debugmode.py
浏览文件 @
9950ce08
...
...
@@ -155,11 +155,11 @@ class WeirdBrokenOp(gof.Op):
prep_vars
=
"""
//the output array has size M x N
npy_intp M = PyArray_DIMS(
%(a)
s)[0];
npy_intp Sa =
%(a)
s->strides
[0] / PyArray_DESCR(
%(a)
s)->elsize;
npy_intp Sz =
%(z)
s->strides
[0] / PyArray_DESCR(
%(z)
s)->elsize;
npy_intp Sa =
PyArray_STRIDES(
%(a)
s)
[0] / PyArray_DESCR(
%(a)
s)->elsize;
npy_intp Sz =
PyArray_STRIDES(
%(z)
s)
[0] / PyArray_DESCR(
%(z)
s)->elsize;
npy_double * Da = (npy_double*)
%(a)
s->data
;
npy_double * Dz = (npy_double*)
%(z)
s->data
;
npy_double * Da = (npy_double*)
PyArray_BYTES(
%(a)
s)
;
npy_double * Dz = (npy_double*)
PyArray_BYTES(
%(z)
s)
;
//clear the output array
for (npy_intp m = 0; m < M; ++m)
...
...
theano/gof/cmodule.py
浏览文件 @
9950ce08
...
...
@@ -1693,7 +1693,7 @@ class GCC_compiler(object):
#to use the new API, but not everywhere. When finished, enable
#the following macro to assert that we don't bring new code
#that use the old API.
#
cxxflags.append("-D NPY_NO_DEPRECATED_API=NPY_1_7_API_VERSION")
cxxflags
.
append
(
"-D NPY_NO_DEPRECATED_API=NPY_1_7_API_VERSION"
)
numpy_ver
=
[
int
(
n
)
for
n
in
numpy
.
__version__
.
split
(
'.'
)[:
2
]]
# numpy 1.7 deprecated the following macro but the new one didn't
...
...
theano/gof/lazylinker_c.c
.txt
→
theano/gof/lazylinker_c.c
浏览文件 @
9950ce08
File moved
theano/gof/lazylinker_c.py
浏览文件 @
9950ce08
...
...
@@ -76,10 +76,7 @@ except ImportError:
except
ImportError
:
_logger
.
info
(
"Compiling new CVM"
)
dirname
=
'lazylinker_ext'
# We use a .txt extensions as otherwise it don't get
# included when we create a package to send to pypi
# This happen even if we tell to include *.c files
cfile
=
os
.
path
.
join
(
theano
.
__path__
[
0
],
'gof'
,
'lazylinker_c.c.txt'
)
cfile
=
os
.
path
.
join
(
theano
.
__path__
[
0
],
'gof'
,
'lazylinker_c.c'
)
code
=
open
(
cfile
)
.
read
()
loc
=
os
.
path
.
join
(
config
.
compiledir
,
dirname
)
if
not
os
.
path
.
exists
(
loc
):
...
...
theano/misc/check_blas.py
浏览文件 @
9950ce08
...
...
@@ -220,6 +220,7 @@ if __name__ == "__main__":
GTX 650 Ti 0.27s
GTX 460 0.37s 0.45s
GTX 285 0.42s 0.452s 0.452s 0.40s # cuda 3.0 seems faster? driver version?
750M 0.49s
GTX 550 Ti 0.57s
GT 520 2.68s 3.06s
520M 2.44s 3.19s # with bumblebee on Ubuntu 12.04
...
...
theano/sandbox/cuda/basic_ops.py
浏览文件 @
9950ce08
...
...
@@ -2223,12 +2223,6 @@ class GpuReshape(tensor.Reshape, GpuOp):
out
[
0
]
=
x
.
reshape
(
tuple
(
shp
))
# C Code shared by GpuSubtensor and GpuIncSubtensor
_define_set_data
=
"""
#define CudaNdarray_set_device_data2(obj, ptr, base)
\
CudaNdarray_set_device_data(obj, (float *)ptr, base)
"""
class
GpuSubtensor
(
GpuOp
,
tensor
.
Subtensor
):
"""
Implement subtensor on the gpu.
...
...
@@ -2276,16 +2270,27 @@ class GpuSubtensor(GpuOp, tensor.Subtensor):
view_ndim
=
node
.
outputs
[
0
]
.
ndim
fail
=
sub
[
'fail'
]
decl
=
"CudaNdarray* xview = NULL;"
get_xview
=
self
.
helper_c_code
(
node
,
name
,
inputs
,
outputs
,
sub
,
self
.
idx_list
,
view_ndim
=
view_ndim
,
c_prefix
=
'CudaNdarray'
,
strides_mul
=
4
,
)
build_view
=
"""
//TODO: give this Op a second output so that this view can be cached
//TODO: alternatively, fix the memory leak on failure
CudaNdarray*
xview = (CudaNdarray*) CudaNdarray_New(
%(view_ndim)
s);
xview = (CudaNdarray*) CudaNdarray_New(
%(view_ndim)
s);
if (!xview)
{
%(fail)
s;
}
if (CudaNdarray_set_device_data(xview, CudaNdarray_DEV_DATA(
%(x)
s),
(PyObject*) NULL))
if (CudaNdarray_set_device_data(
xview,
CudaNdarray_DEV_DATA(
%(x)
s) + xview_offset/4,
(PyObject*)
%(x)
s))
{
PyErr_Format(PyExc_RuntimeError,
"GpuSubtensor is not able to set the"
...
...
@@ -2294,43 +2299,24 @@ class GpuSubtensor(GpuOp, tensor.Subtensor):
%(fail)
s;
}
cnda_mark_dev_structure_dirty(xview);
"""
%
locals
()
get_xview
=
_define_set_data
+
\
self
.
helper_c_code
(
node
,
name
,
inputs
,
outputs
,
sub
,
self
.
idx_list
,
c_prefix
=
'CudaNdarray'
,
set_data
=
'CudaNdarray_set_device_data2'
,
set_dim
=
'CudaNdarray_set_dim'
,
set_stride
=
'CudaNdarray_set_stride'
,
update_flags
=
""
,
strides_mul
=
4
)
finish_view
=
""
#For broadcasted dimensions, set the strides to 0
#We can't do that only for broadcasted dimensions as this can happen for dimensions of size 0,
#That are rebroadcated later.
for
idx
in
range
(
node
.
outputs
[
0
]
.
ndim
):
finish_view
+=
"""
if(CudaNdarray_HOST_DIMS(xview)[
%(idx)
s]==1)
CudaNdarray_set_stride(xview,
%(idx)
s, 0);
"""
%
locals
()
finish_view
+=
"""
//Set the base only now
if(CudaNdarray_set_device_data(xview, CudaNdarray_DEV_DATA(xview),
%(x)
s)){
PyErr_Format(PyExc_RuntimeError,
"GpuSubtensor is not able to set"
" the base of the view array");
Py_XDECREF(xview);
%(fail)
s;
for(int idx=0;idx <
%(view_ndim)
s; idx++){
//For broadcasted dimensions, set the strides to 0
//We can't do that only for broadcasted dimensions as this can happen
//for dimensions of size 0. That are rebroadcated later.
if(xview_dims[idx]==1)
CudaNdarray_set_stride(xview, idx, 0);
else
CudaNdarray_set_stride(xview, idx, xview_strides[idx]);
CudaNdarray_set_dim(xview, idx, xview_dims[idx]);
}
"""
%
locals
()
finish_view
=
"""
Py_XDECREF(
%(z)
s);
%(z)
s = xview;
"""
%
locals
()
return
build_view
+
"{"
+
get_xview
+
"}"
+
finish_view
return
decl
+
get_xview
+
build_view
+
finish_view
def
c_code_cache_version
(
self
):
hv
=
self
.
helper_c_code_cache_version
()
...
...
@@ -2719,6 +2705,7 @@ class GpuAdvancedIncSubtensor1_dev20(GpuAdvancedIncSubtensor1):
"""
%
locals
()
class
GpuIncSubtensor
(
tensor
.
IncSubtensor
,
GpuOp
):
"""
Implement IncSubtensor on the gpu.
...
...
@@ -2756,6 +2743,9 @@ class GpuIncSubtensor(tensor.IncSubtensor, GpuOp):
"""
return
"""(CudaNdarray*) CudaNdarray_Copy(
%(x)
s)"""
%
locals
()
def
decl_view
(
self
):
return
"CudaNdarray* zview = NULL;"
def
make_view_array
(
self
,
x
,
view_ndim
):
"""
:param x: a string identifying an array to be viewed
...
...
@@ -2765,17 +2755,32 @@ class GpuIncSubtensor(tensor.IncSubtensor, GpuOp):
This doesn't need to actually set up the view with the
right indexing; we'll do that manually later.
"""
return
"""CudaNdarray* zview = (CudaNdarray*)
CudaNdarray_New(
%(view_ndim)
s)"""
%
locals
()
ret
=
"""zview = (CudaNdarray*) CudaNdarray_New(
%(view_ndim)
s);
if (CudaNdarray_set_device_data(
zview,
CudaNdarray_DEV_DATA(
%(x)
s) + xview_offset/4,
(PyObject*)
%(x)
s))
{
zview = NULL;
PyErr_Format(PyExc_RuntimeError,
"GpuSubtensor is not able to set the"
" devdata field of the view");
}else{
cnda_mark_dev_structure_dirty(zview);
for(int idx=0;idx <
%(view_ndim)
s; idx++){
if(xview_dims[idx]==1)
CudaNdarray_set_stride(zview, idx, 0);
else
CudaNdarray_set_stride(zview, idx, xview_strides[idx]);
CudaNdarray_set_dim(zview, idx, xview_dims[idx]);
}
}
"""
%
locals
()
return
ret
def
get_helper_c_code_args
(
self
):
""" Return a dictionary of arguments to use with helper_c_code"""
return
{
'update_flags'
:
""
,
'c_prefix'
:
'CudaNdarray'
,
'set_data'
:
'CudaNdarray_set_device_data2'
,
'set_dim'
:
'CudaNdarray_set_dim'
,
'set_stride'
:
'CudaNdarray_set_stride'
,
'update_flags'
:
""
,
return
{
'c_prefix'
:
'CudaNdarray'
,
'strides_mul'
:
4
}
...
...
@@ -2789,24 +2794,6 @@ class GpuIncSubtensor(tensor.IncSubtensor, GpuOp):
"""
return
"""CudaNdarray_CopyFromCudaNdarray(
%(view)
s,
%(source)
s)"""
%
locals
()
def
define_set_data
(
self
):
return
_define_set_data
def
link_view_array
(
self
,
x
,
fail
):
return
"""
if (CudaNdarray_set_device_data(zview, CudaNdarray_DEV_DATA(
%(x)
s),
(PyObject*) NULL))
{
PyErr_Format(PyExc_RuntimeError,
"GpuSubtensor is not able to set the"
" devdata field of the view");
Py_XDECREF(zview);
%(fail)
s;
}
cnda_mark_dev_structure_dirty(zview);
"""
%
locals
()
def
set_view_base
(
self
,
x
,
fail
):
return
"""
//Set the base only now
...
...
@@ -2823,9 +2810,8 @@ class GpuIncSubtensor(tensor.IncSubtensor, GpuOp):
def
add_to_zview
(
self
,
x
,
fail
):
return
"""
PyObject * add_result = CudaNdarray_inplace_add((PyObject *) zview,
(PyObject *) py_
%(x)
s);
PyObject * add_result = CudaNdarray_inplace_add((PyObject *) zview,
(PyObject *) py_
%(x)
s);
if (! add_result )
{
...
...
@@ -2839,7 +2825,6 @@ class GpuIncSubtensor(tensor.IncSubtensor, GpuOp):
"""
%
locals
()
def
c_code_cache_version
(
self
):
parent_version
=
super
(
GpuIncSubtensor
,
self
)
.
c_code_cache_version
()
if
parent_version
:
return
parent_version
+
(
0
,)
...
...
theano/sandbox/rng_mrg.py
浏览文件 @
9950ce08
差异被折叠。
点击展开。
theano/scan_module/scan_perform.c
.txt
→
theano/scan_module/scan_perform.c
浏览文件 @
9950ce08
This source diff could not be displayed because it is too large. You can
view the blob
instead.
theano/scan_module/scan_perform.pyx
浏览文件 @
9950ce08
差异被折叠。
点击展开。
theano/scan_module/scan_perform_ext.py
浏览文件 @
9950ce08
差异被折叠。
点击展开。
theano/sparse/basic.py
浏览文件 @
9950ce08
差异被折叠。
点击展开。
theano/sparse/opt.py
浏览文件 @
9950ce08
差异被折叠。
点击展开。
theano/tensor/basic.py
浏览文件 @
9950ce08
差异被折叠。
点击展开。
theano/tensor/elemwise.py
浏览文件 @
9950ce08
差异被折叠。
点击展开。
theano/tensor/nnet/nnet.py
浏览文件 @
9950ce08
差异被折叠。
点击展开。
theano/tensor/subtensor.py
浏览文件 @
9950ce08
差异被折叠。
点击展开。
theano/tensor/tests/test_blas.py
浏览文件 @
9950ce08
差异被折叠。
点击展开。
theano/tensor/tests/test_inc_subtensor.py
浏览文件 @
9950ce08
差异被折叠。
点击展开。
theano/tensor/type.py
浏览文件 @
9950ce08
差异被折叠。
点击展开。
theano/tests/test_tutorial.py
浏览文件 @
9950ce08
差异被折叠。
点击展开。
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论