Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
c4e182ab
提交
c4e182ab
authored
12月 16, 2013
作者:
Pascal Lamblin
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #1666 from nouiz/gh-1381
fix gh-1381 c linker crash with not used inputs.
上级
372685c8
bb9f30d3
显示空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
29 行增加
和
4 行删除
+29
-4
cc.py
theano/gof/cc.py
+14
-3
test_cc.py
theano/gof/tests/test_cc.py
+15
-1
没有找到文件。
theano/gof/cc.py
浏览文件 @
c4e182ab
...
@@ -450,8 +450,13 @@ class CLinker(link.Linker):
...
@@ -450,8 +450,13 @@ class CLinker(link.Linker):
fgraph
=
self
.
fgraph
fgraph
=
self
.
fgraph
self
.
inputs
=
fgraph
.
inputs
self
.
inputs
=
fgraph
.
inputs
self
.
outputs
=
fgraph
.
outputs
self
.
outputs
=
fgraph
.
outputs
# list(fgraph.variables)
# list(fgraph.variables)
self
.
variables
=
graph
.
variables
(
self
.
inputs
,
self
.
outputs
)
# We need to include the not used inputs in our variables,
# otherwise we can't pass them to the module.
self
.
variables
=
[
var
for
var
in
self
.
inputs
if
not
len
(
var
.
clients
)]
self
.
variables
+=
graph
.
variables
(
self
.
inputs
,
self
.
outputs
)
# The orphans field is listified to ensure a consistent order.
# The orphans field is listified to ensure a consistent order.
#list(fgraph.orphans.difference(self.outputs))
#list(fgraph.orphans.difference(self.outputs))
self
.
orphans
=
list
(
r
for
r
in
self
.
variables
self
.
orphans
=
list
(
r
for
r
in
self
.
variables
...
@@ -1042,8 +1047,9 @@ class CLinker(link.Linker):
...
@@ -1042,8 +1047,9 @@ class CLinker(link.Linker):
c_compiler
=
self
.
c_compiler
(),
c_compiler
=
self
.
c_compiler
(),
)
)
def
cmodule_key_
(
self
,
fgraph
,
no_recycling
,
compile_args
=
None
,
libraries
=
None
,
def
cmodule_key_
(
self
,
fgraph
,
no_recycling
,
compile_args
=
None
,
header_dirs
=
None
,
insert_config_md5
=
True
,
c_compiler
=
None
):
libraries
=
None
,
header_dirs
=
None
,
insert_config_md5
=
True
,
c_compiler
=
None
):
"""
"""
Do the actual computation of cmodule_key in a static method
Do the actual computation of cmodule_key in a static method
to allow it to be reused in scalar.Composite.__eq__
to allow it to be reused in scalar.Composite.__eq__
...
@@ -1180,6 +1186,11 @@ class CLinker(link.Linker):
...
@@ -1180,6 +1186,11 @@ class CLinker(link.Linker):
op_pos
[
node
]
=
node_pos
op_pos
[
node
]
=
node_pos
fgraph_computed_set
.
update
(
node
.
outputs
)
fgraph_computed_set
.
update
(
node
.
outputs
)
# Add not used input in the key
for
ipos
,
var
in
[(
i
,
var
)
for
i
,
var
in
enumerate
(
fgraph
.
inputs
)
if
not
len
(
var
.
clients
)]:
sig
.
append
((
var
.
type
,
in_sig
(
var
,
-
1
,
ipos
)))
#crystalize the signature and version
#crystalize the signature and version
sig
=
tuple
(
sig
)
sig
=
tuple
(
sig
)
version
=
tuple
(
version
)
version
=
tuple
(
version
)
...
...
theano/gof/tests/test_cc.py
浏览文件 @
c4e182ab
...
@@ -3,8 +3,9 @@ import unittest
...
@@ -3,8 +3,9 @@ import unittest
from
nose.plugins.skip
import
SkipTest
from
nose.plugins.skip
import
SkipTest
import
theano
from
theano.gof.link
import
PerformLinker
from
theano.gof.link
import
PerformLinker
from
theano.gof.cc
import
*
from
theano.gof.cc
import
CLinker
,
DualLinker
,
OpWiseCLinker
from
theano.gof.type
import
Type
from
theano.gof.type
import
Type
from
theano.gof.graph
import
Variable
,
Apply
,
Constant
from
theano.gof.graph
import
Variable
,
Apply
,
Constant
from
theano.gof.op
import
Op
from
theano.gof.op
import
Op
...
@@ -227,6 +228,18 @@ def test_clinker_dups():
...
@@ -227,6 +228,18 @@ def test_clinker_dups():
# note: for now the behavior of fn(2.0, 7.0) is undefined
# note: for now the behavior of fn(2.0, 7.0) is undefined
def
test_clinker_not_used_inputs
():
if
not
theano
.
config
.
cxx
:
raise
SkipTest
(
"G++ not available, so we need to skip this test."
)
# Testing that duplicate inputs are allowed.
x
,
y
,
z
=
inputs
()
e
=
add
(
x
,
y
)
lnk
=
CLinker
()
.
accept
(
Env
([
x
,
y
,
z
],
[
e
]))
fn
=
lnk
.
make_function
()
assert
fn
(
2.0
,
1.5
,
1.0
)
==
3.5
# note: for now the behavior of fn(2.0, 7.0) is undefined
def
test_clinker_dups_inner
():
def
test_clinker_dups_inner
():
if
not
theano
.
config
.
cxx
:
if
not
theano
.
config
.
cxx
:
raise
SkipTest
(
"G++ not available, so we need to skip this test."
)
raise
SkipTest
(
"G++ not available, so we need to skip this test."
)
...
@@ -253,6 +266,7 @@ def test_opwiseclinker_straightforward():
...
@@ -253,6 +266,7 @@ def test_opwiseclinker_straightforward():
# The python version of bad_sub always return -10.
# The python version of bad_sub always return -10.
assert
fn
(
2.0
,
2.0
,
2.0
)
==
-
6
assert
fn
(
2.0
,
2.0
,
2.0
)
==
-
6
def
test_opwiseclinker_constant
():
def
test_opwiseclinker_constant
():
x
,
y
,
z
=
inputs
()
x
,
y
,
z
=
inputs
()
x
=
Constant
(
tdouble
,
7.2
,
name
=
'x'
)
x
=
Constant
(
tdouble
,
7.2
,
name
=
'x'
)
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论