Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
5d31582f
提交
5d31582f
authored
12月 05, 2014
作者:
Frédéric Bastien
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #2315 from abergeron/fix_cdata_debug
Fix problems with CDataType in DebugMode
上级
a3870bb2
1f16340b
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
16 行增加
和
5 行删除
+16
-5
debugmode.py
theano/compile/debugmode.py
+4
-0
type.py
theano/gof/type.py
+12
-5
没有找到文件。
theano/compile/debugmode.py
浏览文件 @
5d31582f
...
@@ -874,8 +874,12 @@ def _lessbroken_deepcopy(a):
...
@@ -874,8 +874,12 @@ def _lessbroken_deepcopy(a):
"""
"""
# this exists because copy.deepcopy on numpy arrays is broken
# this exists because copy.deepcopy on numpy arrays is broken
# This logic is also in link.py
# This logic is also in link.py
from
theano.gof.type
import
CDataType
if
type
(
a
)
in
(
numpy
.
ndarray
,
numpy
.
memmap
):
if
type
(
a
)
in
(
numpy
.
ndarray
,
numpy
.
memmap
):
rval
=
a
.
copy
()
rval
=
a
.
copy
()
elif
type
(
a
)
is
CDataType
.
_cdata_type
:
# This is not copyable (and should be used for constant data).
rval
=
a
else
:
else
:
rval
=
copy
.
deepcopy
(
a
)
rval
=
copy
.
deepcopy
(
a
)
...
...
theano/gof/type.py
浏览文件 @
5d31582f
...
@@ -479,6 +479,15 @@ class CDataType(Type):
...
@@ -479,6 +479,15 @@ class CDataType(Type):
Represents opaque C data to be passed around. The intent is to
Represents opaque C data to be passed around. The intent is to
ease passing arbitrary data between ops C code.
ease passing arbitrary data between ops C code.
"""
"""
import
ctypes
if
PY3
:
_cdata_type
=
ctypes
.
py_object
.
from_address
(
ctypes
.
addressof
(
ctypes
.
pythonapi
.
PyCapsule_Type
))
.
value
else
:
_cdata_type
=
ctypes
.
py_object
.
from_address
(
ctypes
.
addressof
(
ctypes
.
pythonapi
.
PyCObject_Type
))
.
value
del
ctypes
def
__init__
(
self
,
ctype
,
freefunc
=
None
):
def
__init__
(
self
,
ctype
,
freefunc
=
None
):
"""
"""
Build a type made to represent a C pointer in theano.
Build a type made to represent a C pointer in theano.
...
@@ -504,11 +513,9 @@ class CDataType(Type):
...
@@ -504,11 +513,9 @@ class CDataType(Type):
return
hash
((
type
(
self
),
self
.
ctype
,
self
.
freefunc
))
return
hash
((
type
(
self
),
self
.
ctype
,
self
.
freefunc
))
def
filter
(
self
,
data
,
strict
=
False
,
allow_downcast
=
None
):
def
filter
(
self
,
data
,
strict
=
False
,
allow_downcast
=
None
):
if
data
is
not
None
:
if
data
is
not
None
and
not
isinstance
(
data
,
self
.
_cdata_type
):
raise
TypeError
(
"only None is valid"
)
raise
TypeError
(
"expected None or PyCObject/PyCapsule"
)
return
data
def
is_valid_value
(
self
,
a
):
return
a
is
None
def
c_declare
(
self
,
name
,
sub
,
check_input
=
True
):
def
c_declare
(
self
,
name
,
sub
,
check_input
=
True
):
return
"""
return
"""
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论