Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
520f92a4
提交
520f92a4
authored
8月 28, 2013
作者:
Pascal Lamblin
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add init_code mechanism to register code in module init fn
上级
82ccf7da
显示空白字符变更
内嵌
并排
正在显示
5 个修改的文件
包含
39 行增加
和
0 行删除
+39
-0
cop.txt
doc/extending/cop.txt
+5
-0
ctype.txt
doc/extending/ctype.txt
+5
-0
cc.py
theano/gof/cc.py
+17
-0
op.py
theano/gof/op.py
+11
-0
type.py
theano/tensor/type.py
+1
-0
没有找到文件。
doc/extending/cop.txt
浏览文件 @
520f92a4
...
@@ -57,6 +57,11 @@ There are less methods to define for an Op than for a Type:
...
@@ -57,6 +57,11 @@ There are less methods to define for an Op than for a Type:
Allows you to specify special g++ arguments to add/exclude
Allows you to specify special g++ arguments to add/exclude
.. method:: c_init_code()
Allows you to specify code that will be executed once when the
module is initialized, before anything else is executed.
.. method:: c_support_code()
.. method:: c_support_code()
Allows you to specify helper functions/structs that the
Allows you to specify helper functions/structs that the
...
...
doc/extending/ctype.txt
浏览文件 @
520f92a4
...
@@ -90,6 +90,11 @@ the most important ones:
...
@@ -90,6 +90,11 @@ the most important ones:
Allows to specify special compiler arguments to add/exclude.
Allows to specify special compiler arguments to add/exclude.
.. method:: c_init_code()
Allows you to specify code that will be executed once when the
module is initialized, before anything else is executed.
.. method:: c_support_code()
.. method:: c_support_code()
Allows to add helper functions/structs that the :ref:`type` needs.
Allows to add helper functions/structs that the :ref:`type` needs.
...
...
theano/gof/cc.py
浏览文件 @
520f92a4
...
@@ -774,6 +774,21 @@ class CLinker(link.Linker):
...
@@ -774,6 +774,21 @@ class CLinker(link.Linker):
pass
pass
return
utils
.
uniq
(
ret
)
return
utils
.
uniq
(
ret
)
def
init_code
(
self
):
"""
Return a list of code snippets that have to be inserted
in the module initialization code.
The return value will not contain duplicates.
"""
ret
=
[]
for
x
in
[
y
.
type
for
y
in
self
.
variables
]
+
[
y
.
op
for
y
in
self
.
node_order
]:
try
:
ret
+=
x
.
c_init_code
()
except
utils
.
MethodNotDefined
:
pass
return
utils
.
uniq
(
ret
)
def
c_compiler
(
self
):
def
c_compiler
(
self
):
c_compiler
=
None
c_compiler
=
None
for
x
in
[
y
.
type
for
y
in
self
.
variables
]
+
[
for
x
in
[
y
.
type
for
y
in
self
.
variables
]
+
[
...
@@ -1277,6 +1292,8 @@ class CLinker(link.Linker):
...
@@ -1277,6 +1292,8 @@ 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
():
mod
.
add_init_code
(
init_code_block
)
return
mod
return
mod
...
...
theano/gof/op.py
浏览文件 @
520f92a4
...
@@ -174,6 +174,17 @@ class CLinkerObject(object):
...
@@ -174,6 +174,17 @@ class CLinkerObject(object):
"""
"""
raise
utils
.
MethodNotDefined
(
"c_no_compile_args"
,
type
(
self
),
self
.
__class__
.
__name__
)
raise
utils
.
MethodNotDefined
(
"c_no_compile_args"
,
type
(
self
),
self
.
__class__
.
__name__
)
def
c_init_code
(
self
):
"""
Optional: return a list of code snippets to be inserted in module
initialization.
:Exceptions:
- `MethodNotDefined`: the subclass does not override this method
"""
raise
utils
.
MethodNotDefined
(
"c_init_code"
,
type
(
self
),
self
.
__class__
.
__name__
)
class
CLinkerOp
(
CLinkerObject
):
class
CLinkerOp
(
CLinkerObject
):
"""
"""
...
...
theano/tensor/type.py
浏览文件 @
520f92a4
...
@@ -7,6 +7,7 @@ import theano
...
@@ -7,6 +7,7 @@ import theano
from
theano
import
config
from
theano
import
config
from
theano.gof
import
Constant
,
hashtype
,
Type
,
Variable
from
theano.gof
import
Constant
,
hashtype
,
Type
,
Variable
from
theano.gof.python25
import
any
from
theano.gof.python25
import
any
from
theano.gof.utils
import
MethodNotDefined
from
theano
import
scalar
as
scal
from
theano
import
scalar
as
scal
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论