Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
6ad2afec
提交
6ad2afec
authored
9月 08, 2014
作者:
Arnaud Bergeron
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Multiple compilation fixes, wrong working branch was submitted.
上级
66e2fcef
隐藏空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
23 行增加
和
14 行删除
+23
-14
cc.py
theano/gof/cc.py
+6
-2
op.py
theano/gof/op.py
+6
-1
test_op.py
theano/gof/tests/test_op.py
+1
-1
dnn.py
theano/sandbox/cuda/dnn.py
+10
-10
没有找到文件。
theano/gof/cc.py
浏览文件 @
6ad2afec
...
@@ -333,7 +333,7 @@ def get_c_init(r, name, sub):
...
@@ -333,7 +333,7 @@ def get_c_init(r, name, sub):
def
get_c_extract
(
r
,
name
,
sub
):
def
get_c_extract
(
r
,
name
,
sub
):
"""Wrapper around c_extract that initializes py_name from storage."""
"""Wrapper around c_extract that initializes py_name from storage."""
if
any
([
getattr
(
c
.
op
,
'check_input'
,
config
.
check_input
)
for
(
c
,
_
)
in
if
any
([
getattr
(
c
.
op
,
'check_input'
,
config
.
check_input
)
for
(
c
,
_
)
in
r
.
clients
]):
r
.
clients
]):
c_extract
=
r
.
type
.
c_extract
(
name
,
sub
,
True
)
c_extract
=
r
.
type
.
c_extract
(
name
,
sub
,
True
)
...
@@ -634,6 +634,10 @@ class CLinker(link.Linker):
...
@@ -634,6 +634,10 @@ class CLinker(link.Linker):
sub
[
'struct_id'
]
=
id
+
1
sub
[
'struct_id'
]
=
id
+
1
sub
[
'fail'
]
=
failure_code
(
sub
)
sub
[
'fail'
]
=
failure_code
(
sub
)
sub_struct
=
dict
(
failure_var
=
failure_var
)
sub_struct
[
'id'
]
=
id
+
1
sub_struct
[
'fail'
]
=
failure_code
(
sub_struct
)
struct_support
=
""
struct_support
=
""
struct_init
=
""
struct_init
=
""
struct_cleanup
=
""
struct_cleanup
=
""
...
@@ -661,7 +665,7 @@ class CLinker(link.Linker):
...
@@ -661,7 +665,7 @@ class CLinker(link.Linker):
" didn't return a string for c_init_code_apply"
)
" didn't return a string for c_init_code_apply"
)
try
:
try
:
struct_init
=
op
.
c_init_code_struct
(
node
,
id
+
1
)
struct_init
=
op
.
c_init_code_struct
(
node
,
id
+
1
,
sub_struct
)
assert
isinstance
(
struct_init
,
basestring
),
(
assert
isinstance
(
struct_init
,
basestring
),
(
str
(
node
.
op
)
+
str
(
node
.
op
)
+
" didn't return a string for c_init_code_struct"
)
" didn't return a string for c_init_code_struct"
)
...
...
theano/gof/op.py
浏览文件 @
6ad2afec
...
@@ -319,7 +319,7 @@ class CLinkerOp(CLinkerObject):
...
@@ -319,7 +319,7 @@ class CLinkerOp(CLinkerObject):
raise
utils
.
MethodNotDefined
(
"c_init_code_apply"
,
type
(
self
),
raise
utils
.
MethodNotDefined
(
"c_init_code_apply"
,
type
(
self
),
self
.
__class__
.
__name__
)
self
.
__class__
.
__name__
)
def
c_init_code_struct
(
self
,
node
,
struct_id
):
def
c_init_code_struct
(
self
,
node
,
struct_id
,
sub
):
"""
"""
Optional: return a code string specific to the apply
Optional: return a code string specific to the apply
to be inserted in the struct initialization code.
to be inserted in the struct initialization code.
...
@@ -331,6 +331,11 @@ class CLinkerOp(CLinkerObject):
...
@@ -331,6 +331,11 @@ class CLinkerOp(CLinkerObject):
sub parameter named struct_id that will
sub parameter named struct_id that will
contain this name.
contain this name.
:param sub: a dictionary of values to substitute in the code.
Most notably it contains a 'fail' entry that you
should place in your code after setting a python
exception to indicate an error.
:Exceptions:
:Exceptions:
- `MethodNotDefined`: the subclass does not override this method
- `MethodNotDefined`: the subclass does not override this method
"""
"""
...
...
theano/gof/tests/test_op.py
浏览文件 @
6ad2afec
...
@@ -89,7 +89,7 @@ class StructOp(Op):
...
@@ -89,7 +89,7 @@ class StructOp(Op):
def
c_support_code_struct
(
self
,
node
,
struct_id
):
def
c_support_code_struct
(
self
,
node
,
struct_id
):
return
"npy_uint64 counter
%
d;"
%
(
struct_id
,)
return
"npy_uint64 counter
%
d;"
%
(
struct_id
,)
def
c_init_code_struct
(
self
,
node
,
struct_id
):
def
c_init_code_struct
(
self
,
node
,
struct_id
,
sub
):
return
"counter
%
d = 0;"
%
(
struct_id
,)
return
"counter
%
d = 0;"
%
(
struct_id
,)
def
c_code
(
self
,
node
,
name
,
input_names
,
outputs_names
,
sub
):
def
c_code
(
self
,
node
,
name
,
input_names
,
outputs_names
,
sub
):
...
...
theano/sandbox/cuda/dnn.py
浏览文件 @
6ad2afec
...
@@ -31,10 +31,10 @@ class GpuDnnConv(GpuOp):
...
@@ -31,10 +31,10 @@ class GpuDnnConv(GpuOp):
def
c_support_code_struct
(
self
,
node
,
struct_id
):
def
c_support_code_struct
(
self
,
node
,
struct_id
):
return
"""
return
"""
cudnnTensor4dDescript
ior_t input
%(id)
d = NULL
;
cudnnTensor4dDescript
or_t input
%(id)
d
;
cudnnTensor4dDescript
ior_t output
%(id)
d = NULL
;
cudnnTensor4dDescript
or_t output
%(id)
d
;
cudnnFilterDescriptor_t kerns
%(id)
d
= NULL
;
cudnnFilterDescriptor_t kerns
%(id)
d;
cudnnConvolutionDescriptor_t op
%(id)
d
= NULL
;
cudnnConvolutionDescriptor_t op
%(id)
d;
"""
%
dict
(
id
=
struct_id
)
"""
%
dict
(
id
=
struct_id
)
def
c_init_code_struct
(
self
,
node
,
struct_id
,
sub
):
def
c_init_code_struct
(
self
,
node
,
struct_id
,
sub
):
...
@@ -146,7 +146,7 @@ if (CudaNdarray_prep_output(&%(out)s, 4, out_dims) != 0) {
...
@@ -146,7 +146,7 @@ if (CudaNdarray_prep_output(&%(out)s, 4, out_dims) != 0) {
%(fail)
s
%(fail)
s
}
}
}
}
err
%(name)
s = cudnnSetTensor4DescriptorEx(
err
%(name)
s = cudnnSetTensor4
d
DescriptorEx(
output
%(id)
d, CUDNN_DATA_FLOAT,
output
%(id)
d, CUDNN_DATA_FLOAT,
CudaNdarray_HOST_DIMS(
%(out)
s)[0],
CudaNdarray_HOST_DIMS(
%(out)
s)[0],
CudaNdarray_HOST_DIMS(
%(out)
s)[1],
CudaNdarray_HOST_DIMS(
%(out)
s)[1],
...
@@ -166,14 +166,14 @@ dnn_handle,
...
@@ -166,14 +166,14 @@ dnn_handle,
input
%(id)
d, CudaNdarray_DEV_DATA(
%(img)
s),
input
%(id)
d, CudaNdarray_DEV_DATA(
%(img)
s),
kerns
%(id)
d, CudaNdarray_DEV_DATA(
%(kerns)
s),
kerns
%(id)
d, CudaNdarray_DEV_DATA(
%(kerns)
s),
op
%(id)
d,
op
%(id)
d,
out
%(id)
d, CudaNdarray_DEV_DATA(
%(out)
s),
out
put
%(id)
d, CudaNdarray_DEV_DATA(
%(out)
s),
CUDNN_RESULT_NO_ACCUMULATE
CUDNN_RESULT_NO_ACCUMULATE
);
);
if (err
%(name)
s != CUDNN_STATUS_SUCCESS) {
if (err
%(name)
s != CUDNN_STATUS_SUCCESS) {
PyErr_SetString(PyExc_RuntimeError, "error doing operation");
PyErr_SetString(PyExc_RuntimeError, "error doing operation");
%(fail)
s
%(fail)
s
}
}
"""
%
dict
(
img
=
img
,
kerns
=
kern
s
,
out
=
out
,
bmode
=
bmode
,
"""
%
dict
(
img
=
img
,
kerns
=
kern
,
out
=
out
,
bmode
=
bmode
,
fail
=
sub
[
'fail'
],
id
=
sub
[
'struct_id'
],
name
=
name
)
fail
=
sub
[
'fail'
],
id
=
sub
[
'struct_id'
],
name
=
name
)
from
theano.sandbox.cuda.opt
import
local_optimizer
,
gpu_contiguous
,
register_opt
from
theano.sandbox.cuda.opt
import
local_optimizer
,
gpu_contiguous
,
register_opt
...
@@ -181,9 +181,9 @@ from theano.sandbox.cuda.opt import local_optimizer, gpu_contiguous, register_op
...
@@ -181,9 +181,9 @@ from theano.sandbox.cuda.opt import local_optimizer, gpu_contiguous, register_op
@register_opt
()
@register_opt
()
@local_optimizer
([
GpuConv
])
@local_optimizer
([
GpuConv
])
def
local_conv_dnn
(
node
):
def
local_conv_dnn
(
node
):
if
(
isinstance
(
node
.
op
,
GpuConv
)
and
if
isinstance
(
node
.
op
,
GpuConv
):
node
.
op
.
border_mode
in
[
'full'
,
'valid'
]):
if
(
node
.
op
.
subsample
!=
(
1
,
1
)
or
if
node
.
op
.
subsample
!=
(
1
,
1
):
node
.
op
.
border_mode
not
in
[
'full'
,
'valid'
]
):
return
return
img
,
kern
=
node
.
inputs
img
,
kern
=
node
.
inputs
border_mode
=
node
.
op
.
border_mode
border_mode
=
node
.
op
.
border_mode
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论