Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
8b7aeb6e
提交
8b7aeb6e
authored
7月 17, 2011
作者:
Pascal Lamblin
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add test demonstrating problem with current version of subtensor(alloc) opt.
上级
ad02dfbe
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
116 行增加
和
68 行删除
+116
-68
test_compute_test_value.py
theano/gof/tests/test_compute_test_value.py
+26
-0
test_opt.py
theano/tensor/tests/test_opt.py
+90
-68
没有找到文件。
theano/gof/tests/test_compute_test_value.py
浏览文件 @
8b7aeb6e
...
@@ -276,3 +276,29 @@ class TestComputeTestValue(unittest.TestCase):
...
@@ -276,3 +276,29 @@ class TestComputeTestValue(unittest.TestCase):
finally
:
finally
:
theano
.
config
.
compute_test_value
=
orig_compute_test_value
theano
.
config
.
compute_test_value
=
orig_compute_test_value
def
test_no_perform
(
self
):
pass
def
test_no_c_code
(
self
):
orig_compute_test_value
=
theano
.
config
.
compute_test_value
try
:
theano
.
config
.
compute_test_value
=
'raise'
# int_div has no C code for the moment
# If that changes, use another op with no C code here
i
=
T
.
iscalar
(
'i'
)
j
=
T
.
iscalar
(
'j'
)
i
.
tag
.
test_value
=
3
j
.
tag
.
test_value
=
2
o
=
i
//
j
# Check that the c_code function is not implemented
self
.
assertRaises
(
NotImplementedError
,
o
.
owner
.
op
.
c_code
,
o
.
owner
,
'o'
,
(
'x'
,
'y'
),
'z'
,
{
'fail'
:
''
})
assert
hasattr
(
o
.
tag
,
'test_value'
)
assert
o
.
tag
.
test_value
==
1
finally
:
theano
.
config
.
compute_test_value
=
orig_compute_test_value
theano/tensor/tests/test_opt.py
浏览文件 @
8b7aeb6e
...
@@ -1581,77 +1581,99 @@ class test_local_subtensor_merge(unittest.TestCase):
...
@@ -1581,77 +1581,99 @@ class test_local_subtensor_merge(unittest.TestCase):
for
s2
in
s2r
:
for
s2
in
s2r
:
f
(
x_val
,
b1
,
e1
,
s1
,
b2
,
e2
,
s2
)
f
(
x_val
,
b1
,
e1
,
s1
,
b2
,
e2
,
s2
)
class
Test_alloc_zero
(
unittest
.
TestCase
):
def
test_setsubtensor_allocs0
(
self
):
x
=
tensor
.
matrix
()
y
=
tensor
.
matrix
()
x0
=
tensor
.
zeros_like
(
x
)
y0
=
tensor
.
zeros_like
(
y
)
z
=
tensor
.
set_subtensor
(
x0
[:
4
],
y0
)
f
=
theano
.
function
([
x
,
y
],
z
)
assert
numpy
.
all
(
[
not
isinstance
(
x
.
op
,
tensor
.
IncSubtensor
)
for
x
in
f
.
maker
.
env
.
toposort
()
])
def
test_setsubtensor_allocs1
(
self
):
y
=
tensor
.
matrix
()
x0
=
tensor
.
constant
(
numpy
.
asarray
(
numpy
.
zeros_like
((
4
,
4
)),
dtype
=
config
.
floatX
))
y0
=
tensor
.
zeros_like
(
y
)
z
=
tensor
.
set_subtensor
(
x0
[:
4
],
y0
)
f
=
theano
.
function
([
y
],
z
)
assert
numpy
.
all
(
[
not
isinstance
(
x
.
op
,
tensor
.
IncSubtensor
)
for
x
in
f
.
maker
.
env
.
toposort
()
])
def
test_setsubtensor_allocs2
(
self
):
x
=
tensor
.
matrix
()
y0
=
tensor
.
constant
(
numpy
.
asarray
(
numpy
.
zeros_like
((
4
,
4
)),
dtype
=
config
.
floatX
))
x0
=
tensor
.
zeros_like
(
x
)
z
=
tensor
.
set_subtensor
(
x0
[:
4
],
y0
)
f
=
theano
.
function
([
x
],
z
)
assert
numpy
.
all
(
[
not
isinstance
(
x
.
op
,
tensor
.
IncSubtensor
)
for
x
in
f
.
maker
.
env
.
toposort
()
])
def
test_incsubtensor_allocs0
(
self
):
x
=
tensor
.
matrix
()
y
=
tensor
.
matrix
()
y0
=
tensor
.
zeros_like
(
y
)
z
=
tensor
.
inc_subtensor
(
x
[:
4
],
y0
)
f
=
theano
.
function
([
x
,
y
],
z
)
assert
numpy
.
all
(
[
not
isinstance
(
x
.
op
,
tensor
.
IncSubtensor
)
for
x
in
f
.
maker
.
env
.
toposort
()
])
def
test_incsubtensor_allocs1
(
self
):
x
=
tensor
.
matrix
()
y0
=
tensor
.
constant
(
numpy
.
asarray
(
numpy
.
zeros_like
((
4
,
4
)),
dtype
=
config
.
floatX
))
z
=
tensor
.
inc_subtensor
(
x
[:
4
],
y0
)
f
=
theano
.
function
([
x
],
z
)
assert
numpy
.
all
(
[
not
isinstance
(
x
.
op
,
tensor
.
IncSubtensor
)
for
x
in
f
.
maker
.
env
.
toposort
()
])
def
test_dot_allocs_0
(
self
):
v1
=
tensor
.
vector
(
'v1'
)
v2
=
tensor
.
vector
(
'v2'
)
m1
=
tensor
.
matrix
(
'm1'
)
m2
=
tensor
.
matrix
(
'm2'
)
vv
=
numpy
.
asarray
([
0
,
1
,
2
],
dtype
=
theano
.
config
.
floatX
)
vm
=
numpy
.
asarray
([[
1
,
2
,
3
],[
4
,
5
,
6
],[
7
,
8
,
9
]],
dtype
=
theano
.
config
.
floatX
)
for
_e1
in
[(
v1
,
vv
),(
m1
,
vm
)]:
for
_e2
in
[(
v2
,
vv
),(
m2
,
vm
)]:
for
p
in
[
0
,
1
]:
if
p
==
0
:
e1
=
tensor
.
zeros_like
(
_e1
[
0
])
e2
=
_e2
[
0
]
else
:
e1
=
_e1
[
0
]
e2
=
tensor
.
zeros_like
(
_e2
[
0
])
o
=
tensor
.
dot
(
e1
,
e2
)
f
=
theano
.
function
([
_e1
[
0
],
_e2
[
0
]],
o
)
f
(
_e1
[
1
],
_e2
[
1
])
assert
numpy
.
all
([
not
isinstance
(
x
.
op
,
tensor
.
Dot
)
for
x
in
f
.
maker
.
env
.
toposort
()
])
def
test_local_subtensor_alloc0
():
x
=
tensor
.
matrix
(
'x'
)
y
=
tensor
.
vector
(
'y'
)
def
test_setsubtensor_allocs0
():
# The rows of yx are copies of x
x
=
tensor
.
matrix
()
yx
=
tensor
.
alloc
(
y
,
x
.
shape
[
0
],
x
.
shape
[
1
])
y
=
tensor
.
matrix
()
x0
=
tensor
.
zeros_like
(
x
)
# Slice of each row
y0
=
tensor
.
zeros_like
(
y
)
z_mat
=
yx
[:,
3
:]
z
=
tensor
.
set_subtensor
(
x0
[:
4
],
y0
)
assert
z_mat
.
ndim
==
2
f
=
theano
.
function
([
x
,
y
],
z
)
assert
numpy
.
all
(
[
not
isinstance
(
x
.
op
,
tensor
.
IncSubtensor
)
for
x
in
# Only one column
f
.
maker
.
env
.
toposort
()
])
z_vec
=
yx
[:,
3
]
assert
z_vec
.
ndim
==
1
def
test_setsubtensor_allocs1
():
y
=
tensor
.
matrix
()
x0
=
tensor
.
constant
(
numpy
.
asarray
(
numpy
.
zeros_like
((
4
,
4
)),
dtype
=
config
.
floatX
))
y0
=
tensor
.
zeros_like
(
y
)
z
=
tensor
.
set_subtensor
(
x0
[:
4
],
y0
)
f
=
theano
.
function
([
y
],
z
)
assert
numpy
.
all
(
[
not
isinstance
(
x
.
op
,
tensor
.
IncSubtensor
)
for
x
in
f
.
maker
.
env
.
toposort
()
])
def
test_setsubtensor_allocs2
():
x
=
tensor
.
matrix
()
y0
=
tensor
.
constant
(
numpy
.
asarray
(
numpy
.
zeros_like
((
4
,
4
)),
dtype
=
config
.
floatX
))
x0
=
tensor
.
zeros_like
(
x
)
z
=
tensor
.
set_subtensor
(
x0
[:
4
],
y0
)
f
=
theano
.
function
([
x
],
z
)
assert
numpy
.
all
(
[
not
isinstance
(
x
.
op
,
tensor
.
IncSubtensor
)
for
x
in
f
.
maker
.
env
.
toposort
()
])
def
test_incsubtensor_allocs0
():
x
=
tensor
.
matrix
()
y
=
tensor
.
matrix
()
y0
=
tensor
.
zeros_like
(
y
)
z
=
tensor
.
inc_subtensor
(
x
[:
4
],
y0
)
f
=
theano
.
function
([
x
,
y
],
z
)
assert
numpy
.
all
(
[
not
isinstance
(
x
.
op
,
tensor
.
IncSubtensor
)
for
x
in
f
.
maker
.
env
.
toposort
()
])
def
test_incsubtensor_allocs1
():
x
=
tensor
.
matrix
()
y0
=
tensor
.
constant
(
numpy
.
asarray
(
numpy
.
zeros_like
((
4
,
4
)),
dtype
=
config
.
floatX
))
z
=
tensor
.
inc_subtensor
(
x
[:
4
],
y0
)
f
=
theano
.
function
([
x
],
z
)
assert
numpy
.
all
(
[
not
isinstance
(
x
.
op
,
tensor
.
IncSubtensor
)
for
x
in
f
.
maker
.
env
.
toposort
()
])
def
test_dot_allocs_0
():
v1
=
tensor
.
vector
(
'v1'
)
v2
=
tensor
.
vector
(
'v2'
)
m1
=
tensor
.
matrix
(
'm1'
)
m2
=
tensor
.
matrix
(
'm2'
)
vv
=
numpy
.
asarray
([
0
,
1
,
2
],
dtype
=
theano
.
config
.
floatX
)
vm
=
numpy
.
asarray
([[
1
,
2
,
3
],[
4
,
5
,
6
],[
7
,
8
,
9
]],
dtype
=
theano
.
config
.
floatX
)
for
_e1
in
[(
v1
,
vv
),(
m1
,
vm
)]:
for
_e2
in
[(
v2
,
vv
),(
m2
,
vm
)]:
for
p
in
[
0
,
1
]:
if
p
==
0
:
e1
=
tensor
.
zeros_like
(
_e1
[
0
])
e2
=
_e2
[
0
]
else
:
e1
=
_e1
[
0
]
e2
=
tensor
.
zeros_like
(
_e2
[
0
])
o
=
tensor
.
dot
(
e1
,
e2
)
f
=
theano
.
function
([
_e1
[
0
],
_e2
[
0
]],
o
)
f
(
_e1
[
1
],
_e2
[
1
])
assert
numpy
.
all
([
not
isinstance
(
x
.
op
,
tensor
.
Dot
)
for
x
in
f
.
maker
.
env
.
toposort
()
])
f
=
theano
.
function
([
x
,
y
],
z_mat
)
g
=
theano
.
function
([
x
,
y
],
z_vec
)
# DebugMode should detect if something goes wrong.
f
(
numpy
.
zeros
((
3
,
5
)),
numpy
.
arange
(
5
))
g
(
numpy
.
zeros
((
3
,
5
)),
numpy
.
arange
(
5
))
def
test_local_fill_useless
():
def
test_local_fill_useless
():
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论