Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
d47169e0
提交
d47169e0
authored
11月 03, 2014
作者:
Frédéric Bastien
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #2233 from carriepl/COp_addon
Modified where COp looks for the external implementation
上级
43abc77b
98e759a6
显示空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
29 行增加
和
2 行删除
+29
-2
extending_theano_c.txt
doc/tutorial/extending_theano_c.txt
+2
-1
op.py
theano/gof/op.py
+27
-1
没有找到文件。
doc/tutorial/extending_theano_c.txt
浏览文件 @
d47169e0
...
@@ -827,7 +827,8 @@ this new version of the VectorTimesVector op :
...
@@ -827,7 +827,8 @@ this new version of the VectorTimesVector op :
on the filesystem of the C implementation of this op. To do this, it
on the filesystem of the C implementation of this op. To do this, it
gives the path of file containing the C code as well as the name of
gives the path of file containing the C code as well as the name of
the function, in that file, that should be called to perform the
the function, in that file, that should be called to perform the
computation.
computation. The path should be given as a relative path from the
folder where the descendant of the ``COp`` class is defined.
* ``make_node()`` : the ``make_node()`` method is absolutely identical to
* ``make_node()`` : the ``make_node()`` method is absolutely identical to
the one in our old example. Using the ``COp`` class doesn't change
the one in our old example. Using the ``COp`` class doesn't change
...
...
theano/gof/op.py
浏览文件 @
d47169e0
...
@@ -12,6 +12,7 @@ __contact__ = "theano-dev <theano-dev@googlegroups.com>"
...
@@ -12,6 +12,7 @@ __contact__ = "theano-dev <theano-dev@googlegroups.com>"
__docformat__
=
"restructuredtext en"
__docformat__
=
"restructuredtext en"
import
inspect
import
logging
import
logging
import
numpy
import
numpy
import
os
import
os
...
@@ -1000,10 +1001,35 @@ class COp(Op):
...
@@ -1000,10 +1001,35 @@ class COp(Op):
self
.
apply_code_marker
]
self
.
apply_code_marker
]
# Load the external C code
# Load the external C code
f
=
open
(
self
.
func_file
,
"r"
)
try
:
# Attempt to find the file self.func_file in the folder where the
# concrete type of the COp instance is defined
# Get the name of the folder where the concrete type of the COp is
# defined
path_concrete_type
=
inspect
.
getfile
(
self
.
__class__
)
folder_concrete_type
=
os
.
path
.
dirname
(
path_concrete_type
)
# Try to open the file from there
f
=
open
(
os
.
path
.
join
(
folder_concrete_type
,
self
.
func_file
),
"r"
)
self
.
func_code
=
f
.
read
()
self
.
func_code
=
f
.
read
()
f
.
close
()
f
.
close
()
except
IOError
:
# Add information to the exception message to inform the user
# on the locations in which the class COp will look for the
# specified file
message
=
(
"The path to the external C implementation should "
"be given as a relative path from the folder "
"where the Op is defined. "
)
# Can't update the exception's message by modifying e.args
# because IOErrors don't use their attribute args to generate
# their error message
e
.
strerror
=
message
+
e
.
strerror
raise
e
# Separate the contents of the file in sections and validate that at
# Separate the contents of the file in sections and validate that at
# lest one of the necessary code sections has been defined
# lest one of the necessary code sections has been defined
self
.
code_sections
=
self
.
parse_external_c_code
(
self
.
func_code
)
self
.
code_sections
=
self
.
parse_external_c_code
(
self
.
func_code
)
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论