Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
6d851334
提交
6d851334
authored
12月 04, 2013
作者:
Arnaud Bergeron
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add c_init_code_apply().
上级
03bb1866
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
25 行增加
和
3 行删除
+25
-3
cc.py
theano/gof/cc.py
+13
-3
op.py
theano/gof/op.py
+12
-0
没有找到文件。
theano/gof/cc.py
浏览文件 @
6d851334
...
@@ -484,6 +484,7 @@ class CLinker(link.Linker):
...
@@ -484,6 +484,7 @@ class CLinker(link.Linker):
self
.
consts
=
[]
self
.
consts
=
[]
c_support_code_apply
=
[]
c_support_code_apply
=
[]
c_init_code_apply
=
[]
symbol
=
{}
symbol
=
{}
...
@@ -630,7 +631,15 @@ class CLinker(link.Linker):
...
@@ -630,7 +631,15 @@ class CLinker(link.Linker):
# The following will be executed if the "try" block succeeds
# The following will be executed if the "try" block succeeds
assert
isinstance
(
c_support_code_apply
[
-
1
],
basestring
),
(
assert
isinstance
(
c_support_code_apply
[
-
1
],
basestring
),
(
str
(
node
.
op
)
+
str
(
node
.
op
)
+
" didn't returned a string for c_support_code_apply"
)
" didn't return a string for c_support_code_apply"
)
try
:
c_init_code_apply
.
append
(
op
.
c_init_code_apply
(
node
,
name
))
except
utils
.
MethodNotDefined
:
pass
else
:
assert
isinstance
(
c_init_code_apply
[
-
1
],
basestring
),
(
str
(
node
.
op
)
+
" didn't return a string for c_init_code_apply"
)
# emit c_code
# emit c_code
try
:
try
:
...
@@ -638,7 +647,7 @@ class CLinker(link.Linker):
...
@@ -638,7 +647,7 @@ class CLinker(link.Linker):
except
utils
.
MethodNotDefined
:
except
utils
.
MethodNotDefined
:
raise
NotImplementedError
(
"
%
s cannot produce C code"
%
op
)
raise
NotImplementedError
(
"
%
s cannot produce C code"
%
op
)
assert
isinstance
(
behavior
,
basestring
),
(
assert
isinstance
(
behavior
,
basestring
),
(
str
(
node
.
op
)
+
" didn't return
ed
a string for c_code"
)
str
(
node
.
op
)
+
" didn't return a string for c_code"
)
try
:
try
:
cleanup
=
op
.
c_code_cleanup
(
node
,
name
,
isyms
,
osyms
,
sub
)
cleanup
=
op
.
c_code_cleanup
(
node
,
name
,
isyms
,
osyms
,
sub
)
...
@@ -677,6 +686,7 @@ class CLinker(link.Linker):
...
@@ -677,6 +686,7 @@ class CLinker(link.Linker):
self
.
tasks
=
tasks
self
.
tasks
=
tasks
all_info
=
self
.
inputs
+
self
.
outputs
+
self
.
orphans
all_info
=
self
.
inputs
+
self
.
outputs
+
self
.
orphans
self
.
c_support_code_apply
=
c_support_code_apply
self
.
c_support_code_apply
=
c_support_code_apply
self
.
c_init_code_apply
=
c_init_code_apply
if
(
self
.
init_tasks
,
self
.
tasks
)
!=
self
.
get_init_tasks
():
if
(
self
.
init_tasks
,
self
.
tasks
)
!=
self
.
get_init_tasks
():
print
>>
sys
.
stderr
,
"init_tasks
\n
"
,
self
.
init_tasks
print
>>
sys
.
stderr
,
"init_tasks
\n
"
,
self
.
init_tasks
...
@@ -1292,7 +1302,7 @@ class CLinker(link.Linker):
...
@@ -1292,7 +1302,7 @@ class CLinker(link.Linker):
mod
.
add_function
(
instantiate
)
mod
.
add_function
(
instantiate
)
for
header
in
self
.
headers
():
for
header
in
self
.
headers
():
mod
.
add_include
(
header
)
mod
.
add_include
(
header
)
for
init_code_block
in
self
.
init_code
():
for
init_code_block
in
self
.
init_code
()
+
self
.
c_init_code_apply
:
mod
.
add_init_code
(
init_code_block
)
mod
.
add_init_code
(
init_code_block
)
return
mod
return
mod
...
...
theano/gof/op.py
浏览文件 @
6d851334
...
@@ -187,6 +187,18 @@ class CLinkerObject(object):
...
@@ -187,6 +187,18 @@ class CLinkerObject(object):
self
.
__class__
.
__name__
)
self
.
__class__
.
__name__
)
def
c_init_code_apply
(
self
,
node
,
name
):
"""
Optional: return a list of code snippets specific to the apply
to be inserted in module initialization.
:Exceptions:
- `MethodNotDefined`: the subclass does not override this method
"""
raise
utils
.
MethodNotDefined
(
"c_init_code_apply"
,
type
(
self
),
self
.
__class__
.
__name__
)
class
CLinkerOp
(
CLinkerObject
):
class
CLinkerOp
(
CLinkerObject
):
"""
"""
Interface definition for `Op` subclasses compiled by `CLinker`.
Interface definition for `Op` subclasses compiled by `CLinker`.
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论