Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
fe80ad1a
提交
fe80ad1a
authored
3月 14, 2008
作者:
Olivier Breuleux
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
added unpack_single option to Linker.make_function
上级
0ab3226d
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
14 行增加
和
4 行删除
+14
-4
cc.py
gof/cc.py
+5
-2
link.py
gof/link.py
+9
-2
没有找到文件。
gof/cc.py
浏览文件 @
fe80ad1a
...
...
@@ -441,7 +441,7 @@ class CLinker(Linker):
raise
error_storage
[
0
],
error_storage
[
1
]
+
" "
+
str
(
self
.
find_task
(
failure
-
1
))
return
execute
,
in_results
,
out_results
def
make_function
(
self
,
inplace
=
False
):
def
make_function
(
self
,
inplace
=
False
,
unpack_single
=
True
):
cthunk
,
in_results
,
out_results
,
error_storage
=
self
.
__compile__
(
inplace
)
# out_storage = [result._data for result in out_results]
...
...
@@ -451,7 +451,10 @@ class CLinker(Linker):
failure
=
cutils
.
run_cthunk
(
cthunk
)
if
failure
:
raise
error_storage
[
0
],
error_storage
[
1
]
+
" "
+
str
(
self
.
find_task
(
failure
-
1
))
return
utils
.
to_return_values
([
result
.
data
for
result
in
out_results
])
if
unpack_single
:
return
utils
.
to_return_values
([
result
.
data
for
result
in
out_results
])
else
:
return
[
result
.
data
for
result
in
out_results
]
# return utils.to_return_values([storage[0] for storage in out_storage])
return
execute
...
...
gof/link.py
浏览文件 @
fe80ad1a
...
...
@@ -30,7 +30,7 @@ class Linker:
"""
raise
AbstractFunctionError
()
def
make_function
(
self
,
inplace
=
False
):
def
make_function
(
self
,
inplace
=
False
,
unpack_single
=
True
):
"""
Returns a function that takes values corresponding to the inputs of the
env used by this Linker and returns values corresponding the the outputs
...
...
@@ -44,6 +44,10 @@ class Linker:
fn = MyLinker(env).make_function(inplace)
print fn(1.0, 2.0) # 3.0
print e.data # 3.0 iff inplace == True (else unknown)
If unpack_single is True (default) and that the function has only one
output, then that output will be returned. Else, a list or tuple of
length 1 will be returned.
"""
thunk
,
inputs
,
outputs
=
self
.
make_thunk
(
inplace
)
...
...
@@ -51,7 +55,10 @@ class Linker:
for
arg
,
result
in
zip
(
args
,
inputs
):
result
.
data
=
arg
thunk
()
return
utils
.
to_return_values
([
result
.
data
for
result
in
outputs
])
if
unpack_single
:
return
utils
.
to_return_values
([
result
.
data
for
result
in
outputs
])
else
:
return
[
result
.
data
for
result
in
outputs
]
return
execute
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论