Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
ba320eeb
提交
ba320eeb
authored
3月 22, 2011
作者:
Pascal Lamblin
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Small refactoring of tests.
上级
dcfe260e
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
53 行增加
和
53 行删除
+53
-53
test_blas.py
theano/tensor/tests/test_blas.py
+53
-53
没有找到文件。
theano/tensor/tests/test_blas.py
浏览文件 @
ba320eeb
...
@@ -699,69 +699,69 @@ def test_dot_mv():
...
@@ -699,69 +699,69 @@ def test_dot_mv():
assert
sum
([
isinstance
(
node
.
op
,
T
.
Dot
)
for
node
in
assert
sum
([
isinstance
(
node
.
op
,
T
.
Dot
)
for
node
in
f
.
maker
.
env
.
toposort
()
])
==
1
f
.
maker
.
env
.
toposort
()
])
==
1
def
test_gemv1
():
class
TestGemv
(
TestCase
):
''' test vector1+dot(matrix,vector2) '''
def
test_gemv1
(
self
):
rng
=
numpy
.
random
.
RandomState
(
unittest_tools
.
fetch_seed
())
''' test vector1+dot(matrix,vector2) '''
v1
=
theano
.
shared
(
numpy
.
array
(
rng
.
uniform
(
size
=
(
2
,)),
dtype
=
'float32'
))
rng
=
numpy
.
random
.
RandomState
(
unittest_tools
.
fetch_seed
())
v2_orig
=
numpy
.
array
(
rng
.
uniform
(
size
=
(
2
,)),
dtype
=
'float32'
)
v1
=
theano
.
shared
(
numpy
.
array
(
rng
.
uniform
(
size
=
(
2
,)),
dtype
=
'float32'
))
v2
=
theano
.
shared
(
v2_orig
)
v2_orig
=
numpy
.
array
(
rng
.
uniform
(
size
=
(
2
,)),
dtype
=
'float32'
)
m
=
theano
.
shared
(
numpy
.
array
(
rng
.
uniform
(
size
=
(
2
,
2
)),
dtype
=
'float32'
))
v2
=
theano
.
shared
(
v2_orig
)
m
=
theano
.
shared
(
numpy
.
array
(
rng
.
uniform
(
size
=
(
2
,
2
)),
dtype
=
'float32'
))
f
=
theano
.
function
([],
v2
+
theano
.
dot
(
m
,
v1
),
mode
=
mode_blas_opt
)
f
=
theano
.
function
([],
v2
+
theano
.
dot
(
m
,
v1
),
mode
=
mode_blas_opt
)
# Assert they produce the same output
# Assert they produce the same output
assert
numpy
.
allclose
(
f
(),
assert
numpy
.
allclose
(
f
(),
numpy
.
dot
(
m
.
get_value
(),
v1
.
get_value
())
+
v2_orig
)
numpy
.
dot
(
m
.
get_value
(),
v1
.
get_value
())
+
v2_orig
)
topo
=
f
.
maker
.
env
.
toposort
()
topo
=
f
.
maker
.
env
.
toposort
()
assert
len
(
topo
)
==
1
assert
len
(
topo
)
==
1
assert
isinstance
(
topo
[
0
]
.
op
,
Gemv
)
assert
isinstance
(
topo
[
0
]
.
op
,
Gemv
)
assert
topo
[
0
]
.
op
.
inplace
==
False
assert
topo
[
0
]
.
op
.
inplace
==
False
#test the inplace version
#test the inplace version
f
=
theano
.
function
([],
[],
updates
=
{
v2
:
v2
+
theano
.
dot
(
m
,
v1
)}
f
=
theano
.
function
([],
[],
updates
=
{
v2
:
v2
+
theano
.
dot
(
m
,
v1
)}
,
mode
=
mode_blas_opt
)
,
mode
=
mode_blas_opt
)
# Assert they produce the same output
# Assert they produce the same output
f
()
f
()
assert
numpy
.
allclose
(
v2
.
get_value
(),
assert
numpy
.
allclose
(
v2
.
get_value
(),
numpy
.
dot
(
m
.
get_value
(),
v1
.
get_value
())
+
v2_orig
)
numpy
.
dot
(
m
.
get_value
(),
v1
.
get_value
())
+
v2_orig
)
topo
=
f
.
maker
.
env
.
toposort
()
topo
=
f
.
maker
.
env
.
toposort
()
assert
len
(
topo
)
==
1
assert
len
(
topo
)
==
1
assert
isinstance
(
topo
[
0
]
.
op
,
Gemv
)
assert
isinstance
(
topo
[
0
]
.
op
,
Gemv
)
if
config
.
mode
!=
'FAST_COMPILE'
:
if
config
.
mode
!=
'FAST_COMPILE'
:
assert
topo
[
0
]
.
op
.
inplace
==
True
assert
topo
[
0
]
.
op
.
inplace
==
True
def
test_gemv2
(
):
def
test_gemv2
(
self
):
''' test vector1+dot(vector2,matrix) '''
''' test vector1+dot(vector2,matrix) '''
rng
=
numpy
.
random
.
RandomState
(
unittest_tools
.
fetch_seed
())
rng
=
numpy
.
random
.
RandomState
(
unittest_tools
.
fetch_seed
())
v1
=
theano
.
shared
(
numpy
.
array
(
rng
.
uniform
(
size
=
(
2
,)),
dtype
=
'float32'
))
v1
=
theano
.
shared
(
numpy
.
array
(
rng
.
uniform
(
size
=
(
2
,)),
dtype
=
'float32'
))
v2_orig
=
numpy
.
array
(
rng
.
uniform
(
size
=
(
2
,)),
dtype
=
'float32'
)
v2_orig
=
numpy
.
array
(
rng
.
uniform
(
size
=
(
2
,)),
dtype
=
'float32'
)
v2
=
theano
.
shared
(
v2_orig
)
v2
=
theano
.
shared
(
v2_orig
)
m
=
theano
.
shared
(
numpy
.
array
(
rng
.
uniform
(
size
=
(
2
,
2
)),
dtype
=
'float32'
))
m
=
theano
.
shared
(
numpy
.
array
(
rng
.
uniform
(
size
=
(
2
,
2
)),
dtype
=
'float32'
))
f
=
theano
.
function
([],
v2
+
theano
.
dot
(
v1
,
m
),
mode
=
mode_blas_opt
)
f
=
theano
.
function
([],
v2
+
theano
.
dot
(
v1
,
m
),
mode
=
mode_blas_opt
)
# Assert they produce the same output
# Assert they produce the same output
assert
numpy
.
allclose
(
f
(),
assert
numpy
.
allclose
(
f
(),
numpy
.
dot
(
v1
.
get_value
(),
m
.
get_value
())
+
v2
.
get_value
())
numpy
.
dot
(
v1
.
get_value
(),
m
.
get_value
())
+
v2
.
get_value
())
topo
=
f
.
maker
.
env
.
toposort
()
topo
=
f
.
maker
.
env
.
toposort
()
assert
sum
(
isinstance
(
node
.
op
,
Gemv
)
for
node
in
topo
)
==
1
assert
sum
(
isinstance
(
node
.
op
,
Gemv
)
for
node
in
topo
)
==
1
assert
topo
[
-
1
]
.
op
.
inplace
==
False
assert
topo
[
-
1
]
.
op
.
inplace
==
False
#test the inplace version
#test the inplace version
f
=
theano
.
function
([],
[],
updates
=
{
v2
:
v2
+
theano
.
dot
(
v1
,
m
)}
f
=
theano
.
function
([],
[],
updates
=
{
v2
:
v2
+
theano
.
dot
(
v1
,
m
)}
,
mode
=
mode_blas_opt
)
,
mode
=
mode_blas_opt
)
# Assert they produce the same output
# Assert they produce the same output
f
()
f
()
assert
numpy
.
allclose
(
v2
.
get_value
(),
assert
numpy
.
allclose
(
v2
.
get_value
(),
numpy
.
dot
(
v1
.
get_value
(),
m
.
get_value
())
+
v2_orig
)
numpy
.
dot
(
v1
.
get_value
(),
m
.
get_value
())
+
v2_orig
)
topo
=
f
.
maker
.
env
.
toposort
()
topo
=
f
.
maker
.
env
.
toposort
()
assert
sum
(
isinstance
(
node
.
op
,
Gemv
)
for
node
in
topo
)
==
1
assert
sum
(
isinstance
(
node
.
op
,
Gemv
)
for
node
in
topo
)
==
1
if
config
.
mode
!=
'FAST_COMPILE'
:
if
config
.
mode
!=
'FAST_COMPILE'
:
assert
topo
[
-
1
]
.
op
.
inplace
==
True
assert
topo
[
-
1
]
.
op
.
inplace
==
True
class
TestGemv
(
TestCase
):
def
test_gemv_dimensions
(
self
):
def
test_gemv_dimensions
(
self
):
A
=
T
.
matrix
(
'A'
)
A
=
T
.
matrix
(
'A'
)
x
,
y
=
T
.
vectors
(
'x'
,
'y'
)
x
,
y
=
T
.
vectors
(
'x'
,
'y'
)
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论