Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
97c269cd
提交
97c269cd
authored
2月 13, 2012
作者:
Pascal Lamblin
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
More gemm/dot22 tests.
上级
242fcbfb
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
28 行增加
和
6 行删除
+28
-6
test_blas.py
theano/sandbox/cuda/tests/test_blas.py
+28
-6
没有找到文件。
theano/sandbox/cuda/tests/test_blas.py
浏览文件 @
97c269cd
...
...
@@ -34,18 +34,25 @@ def my_rand(*shape):
def
test_dot22
():
def
cmp
(
a_shp
,
b_shp
):
a
=
tcn
.
shared_constructor
(
my_rand
(
*
a_shp
),
'a'
)
a0
=
my_rand
(
*
a_shp
)
a
=
tcn
.
shared_constructor
(
a0
,
'a'
)
b
=
tensor
.
fmatrix
()
f
=
pfunc
([
b
],
[],
updates
=
[(
a
,
tensor
.
dot
(
a
,
b
))],
mode
=
mode_with_gpu
)
a0
=
a
.
get_value
()
*
1.0
bval
=
my_rand
(
*
b_shp
)
f
(
bval
)
assert
numpy
.
allclose
(
numpy
.
dot
(
a0
,
bval
),
a
.
get_value
())
# Try with a matrix equal to a0, but with strides in both dims
a
.
set_value
(
a0
)
a
.
set_value
(
a
.
get_value
(
borrow
=
True
,
return_internal_type
=
True
)[::
-
1
,
::
-
1
],
borrow
=
True
)
f
(
bval
)
cmp
((
3
,
4
),(
4
,
5
))
cmp
((
0
,
4
),(
4
,
5
))
cmp
((
3
,
4
),(
4
,
0
))
...
...
@@ -90,7 +97,8 @@ def test_dot22scalar():
def
test_gemm
():
def
cmp
(
a_shp
,
b_shp
):
a
=
tcn
.
shared_constructor
(
my_rand
(
*
a_shp
),
'a'
)
a0
=
my_rand
(
*
a_shp
)
a
=
tcn
.
shared_constructor
(
a0
,
'a'
)
b
=
tensor
.
fmatrix
(
'b'
)
c
=
tensor
.
fmatrix
(
'c'
)
...
...
@@ -98,12 +106,19 @@ def test_gemm():
f
=
pfunc
([
b
,
c
],
[],
updates
=
[(
a
,
tensor
.
dot
(
a
,
b
)
+
tensor
.
exp
(
c
))],
mode
=
mode_with_gpu
)
assert
any
([
node
.
op
==
tcn
.
blas
.
gpu_gemm_inplace
for
node
in
f
.
maker
.
env
.
toposort
()])
a0
=
a
.
get_value
()
*
1.0
bval
=
my_rand
(
*
b_shp
)
cval
=
my_rand
(
a_shp
[
0
],
b_shp
[
1
])
f
(
bval
,
cval
)
assert
numpy
.
allclose
(
numpy
.
dot
(
a0
,
bval
)
+
numpy
.
exp
(
cval
),
a
.
get_value
())
# Try with a matrix equal to a0, but with strides in both dims
a
.
set_value
(
a0
)
a
.
set_value
(
a
.
get_value
(
borrow
=
True
,
return_internal_type
=
True
)[::
-
1
,
::
-
1
],
borrow
=
True
)
f
(
bval
,
cval
)
cmp
((
3
,
4
),(
4
,
5
))
cmp
((
0
,
4
),(
4
,
5
))
cmp
((
3
,
4
),(
4
,
0
))
...
...
@@ -114,7 +129,8 @@ def test_gemm():
def
test_gemm_no_inplace
():
def
cmp
(
a_shp
,
b_shp
):
a
=
tcn
.
shared_constructor
(
my_rand
(
*
a_shp
),
'a'
)
a0
=
my_rand
(
*
a_shp
)
a
=
tcn
.
shared_constructor
(
a0
,
'a'
)
cval
=
my_rand
(
a_shp
[
0
],
b_shp
[
1
])
c
=
tcn
.
shared_constructor
(
cval
.
copy
(),
'c'
)
...
...
@@ -123,7 +139,6 @@ def test_gemm_no_inplace():
f
=
pfunc
([
b
,
b2
],
[
tensor
.
dot
(
a
,
b2
)
+
c
],
updates
=
[(
a
,
tensor
.
dot
(
a
,
b
)
+
c
)],
mode
=
mode_with_gpu
)
a0
=
a
.
get_value
()
*
1.0
assert
any
([
node
.
op
==
tcn
.
blas
.
gpu_gemm_no_inplace
for
node
in
f
.
maker
.
env
.
toposort
()])
bval
=
my_rand
(
*
b_shp
)
bval2
=
my_rand
(
*
b_shp
)
...
...
@@ -132,6 +147,13 @@ def test_gemm_no_inplace():
assert
numpy
.
allclose
(
numpy
.
dot
(
a0
,
bval
)
+
cval
,
a
.
get_value
())
assert
numpy
.
allclose
(
numpy
.
dot
(
a0
,
bval2
)
+
cval
,
rval
)
# Try with a matrix equal to a0, but with strides in both dims
a
.
set_value
(
a0
)
a
.
set_value
(
a
.
get_value
(
borrow
=
True
,
return_internal_type
=
True
)[::
-
1
,
::
-
1
],
borrow
=
True
)
f
(
bval
,
bval2
)
cmp
((
3
,
4
),(
4
,
5
))
cmp
((
0
,
4
),(
4
,
5
))
cmp
((
3
,
4
),(
4
,
0
))
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论