Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
4b63cf4a
提交
4b63cf4a
authored
6月 05, 2014
作者:
Hengjean
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Added check_input where missing and changed get_c_declare and get_c_extract.
上级
84935fcf
隐藏空白字符变更
内嵌
并排
正在显示
5 个修改的文件
包含
19 行增加
和
16 行删除
+19
-16
ops.py
theano/compile/ops.py
+6
-0
cc.py
theano/gof/cc.py
+9
-12
test_cc.py
theano/gof/tests/test_cc.py
+2
-2
type.py
theano/gof/type.py
+1
-1
test_tutorial.py
theano/tests/test_tutorial.py
+1
-1
没有找到文件。
theano/compile/ops.py
浏览文件 @
4b63cf4a
...
@@ -294,6 +294,7 @@ shape = Shape()
...
@@ -294,6 +294,7 @@ shape = Shape()
_shape
=
shape
# was used in the past, now use shape directly.
_shape
=
shape
# was used in the past, now use shape directly.
#pprint.assign(_shape, printing.MemberPrinter('shape'))
#pprint.assign(_shape, printing.MemberPrinter('shape'))
class
Shape_i
(
gof
.
Op
):
class
Shape_i
(
gof
.
Op
):
"""
"""
L{Op} to return the shape of a matrix.
L{Op} to return the shape of a matrix.
...
@@ -305,6 +306,8 @@ class Shape_i(gof.Op):
...
@@ -305,6 +306,8 @@ class Shape_i(gof.Op):
# the output variable is %(oname)s.
# the output variable is %(oname)s.
c_code_and_version
=
{}
c_code_and_version
=
{}
check_input
=
False
def
__init__
(
self
,
i
):
def
__init__
(
self
,
i
):
self
.
i
=
i
self
.
i
=
i
...
@@ -350,6 +353,9 @@ class Shape_i(gof.Op):
...
@@ -350,6 +353,9 @@ class Shape_i(gof.Op):
return
()
return
()
version
.
append
((
str
(
t
),
v
))
version
.
append
((
str
(
t
),
v
))
if
version
:
version
.
append
(
1
)
return
tuple
(
version
)
return
tuple
(
version
)
def
c_code
(
self
,
node
,
name
,
inames
,
onames
,
sub
):
def
c_code
(
self
,
node
,
name
,
inames
,
onames
,
sub
):
...
...
theano/gof/cc.py
浏览文件 @
4b63cf4a
...
@@ -306,13 +306,12 @@ def get_nothing(r, name, sub):
...
@@ -306,13 +306,12 @@ def get_nothing(r, name, sub):
return
""
return
""
def
get_c_declare
(
r
,
name
,
sub
):
def
get_c_declare
(
r
,
name
,
sub
,
check_input
=
True
):
"""Wrapper around c_declare that declares py_name"""
"""Wrapper around c_declare that declares py_name"""
if
r
.
owner
:
if
any
([
c
==
'output'
or
getattr
(
c
.
op
,
'check_input'
,
True
)
for
(
c
,
_
)
in
r
.
clients
]):
c_declare
=
r
.
type
.
c_declare
(
name
,
sub
,
getattr
(
r
.
owner
.
op
,
'check_input'
,
True
))
else
:
c_declare
=
r
.
type
.
c_declare
(
name
,
sub
,
True
)
c_declare
=
r
.
type
.
c_declare
(
name
,
sub
,
True
)
else
:
c_declare
=
r
.
type
.
c_declare
(
name
,
sub
,
False
)
pre
=
"""
pre
=
"""
PyObject* py_
%(name)
s;
PyObject* py_
%(name)
s;
"""
%
locals
()
"""
%
locals
()
...
@@ -330,11 +329,12 @@ def get_c_init(r, name, sub):
...
@@ -330,11 +329,12 @@ 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
r
.
owner
:
if
any
([
getattr
(
c
.
op
,
'check_input'
,
True
)
for
(
c
,
_
)
in
r
.
clients
]):
c_extract
=
r
.
type
.
c_extract
(
name
,
sub
,
c_extract
=
r
.
type
.
c_extract
(
name
,
sub
,
getattr
(
r
.
owner
.
op
,
'check_input'
,
True
)
)
True
)
else
:
else
:
c_extract
=
r
.
type
.
c_extract
(
name
,
sub
,
Tru
e
)
c_extract
=
r
.
type
.
c_extract
(
name
,
sub
,
Fals
e
)
pre
=
"""
pre
=
"""
py_
%(name)
s = PyList_GET_ITEM(storage_
%(name)
s, 0);
py_
%(name)
s = PyList_GET_ITEM(storage_
%(name)
s, 0);
...
@@ -345,11 +345,8 @@ def get_c_extract(r, name, sub):
...
@@ -345,11 +345,8 @@ def get_c_extract(r, name, sub):
def
get_c_extract_out
(
r
,
name
,
sub
):
def
get_c_extract_out
(
r
,
name
,
sub
):
"""Wrapper around c_extract_out that initializes py_name from storage."""
"""Wrapper around c_extract_out that initializes py_name from storage."""
if
r
.
owner
:
c_extract
=
r
.
type
.
c_extract_out
(
name
,
sub
,
c_extract
=
r
.
type
.
c_extract_out
(
name
,
sub
,
getattr
(
r
.
owner
.
op
,
'check_input'
,
True
))
getattr
(
r
.
owner
.
op
,
'check_input'
,
True
))
else
:
c_extract
=
r
.
type
.
c_extract_out
(
name
,
sub
,
True
)
pre
=
"""
pre
=
"""
py_
%(name)
s = PyList_GET_ITEM(storage_
%(name)
s, 0);
py_
%(name)
s = PyList_GET_ITEM(storage_
%(name)
s, 0);
...
...
theano/gof/tests/test_cc.py
浏览文件 @
4b63cf4a
...
@@ -22,7 +22,7 @@ class TDouble(Type):
...
@@ -22,7 +22,7 @@ class TDouble(Type):
def
filter
(
self
,
data
):
def
filter
(
self
,
data
):
return
float
(
data
)
return
float
(
data
)
def
c_declare
(
self
,
name
,
sub
):
def
c_declare
(
self
,
name
,
sub
,
check_input
=
True
):
return
"double
%(name)
s; void*
%(name)
s_bad_thing;"
%
locals
()
return
"double
%(name)
s; void*
%(name)
s_bad_thing;"
%
locals
()
def
c_init
(
self
,
name
,
sub
):
def
c_init
(
self
,
name
,
sub
):
...
@@ -35,7 +35,7 @@ class TDouble(Type):
...
@@ -35,7 +35,7 @@ class TDouble(Type):
def
c_literal
(
self
,
data
):
def
c_literal
(
self
,
data
):
return
str
(
data
)
return
str
(
data
)
def
c_extract
(
self
,
name
,
sub
):
def
c_extract
(
self
,
name
,
sub
,
check_input
=
True
):
return
"""
return
"""
if (!PyFloat_Check(py_
%(name)
s)) {
if (!PyFloat_Check(py_
%(name)
s)) {
PyErr_SetString(PyExc_TypeError, "not a double!");
PyErr_SetString(PyExc_TypeError, "not a double!");
...
...
theano/gof/type.py
浏览文件 @
4b63cf4a
...
@@ -444,7 +444,7 @@ class Generic(SingletonType):
...
@@ -444,7 +444,7 @@ class Generic(SingletonType):
%(name)
s = NULL;
%(name)
s = NULL;
"""
%
locals
()
"""
%
locals
()
def
c_extract
(
self
,
name
,
sub
):
def
c_extract
(
self
,
name
,
sub
,
check_input
=
True
):
return
"""
return
"""
Py_INCREF(py_
%(name)
s);
Py_INCREF(py_
%(name)
s);
%(name)
s = py_
%(name)
s;
%(name)
s = py_
%(name)
s;
...
...
theano/tests/test_tutorial.py
浏览文件 @
4b63cf4a
...
@@ -298,7 +298,7 @@ class T_extending(unittest.TestCase):
...
@@ -298,7 +298,7 @@ class T_extending(unittest.TestCase):
def
__str__
(
self
):
def
__str__
(
self
):
return
"double"
return
"double"
def
c_declare
(
self
,
name
,
sub
):
def
c_declare
(
self
,
name
,
sub
,
check_input
=
True
):
return
"""
return
"""
double
%(name)
s;
double
%(name)
s;
"""
%
dict
(
name
=
name
)
"""
%
dict
(
name
=
name
)
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论