Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
0a17cf8b
提交
0a17cf8b
authored
1月 23, 2012
作者:
Frederic
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Move a gemv test case inside the test class.
This make this test executed on the gpu too.
上级
8bdf37b9
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
32 行增加
和
23 行删除
+32
-23
test_blas.py
theano/tensor/tests/test_blas.py
+32
-23
没有找到文件。
theano/tensor/tests/test_blas.py
浏览文件 @
0a17cf8b
...
...
@@ -553,29 +553,6 @@ def test_gemm_factor():
assert
[(
1.0
,
X
),
(
1.0
,
Y
)]
==
_factor_canonicalized
([(
1.0
,
X
),
(
1.0
,
Y
)])
assert
[(
2.0
,
X
)]
==
_factor_canonicalized
([(
1.0
,
X
),(
1.0
,
X
)])
def
test_upcasting_scalar_nogemv
():
# Test that the optimization does not crash when the scale has an incorrect
# dtype, and forces upcasting of the result
v
=
T
.
fvector
(
'v'
)
w
=
T
.
fmatrix
(
'w'
)
t
=
T
.
fvector
(
't'
)
alpha
=
T
.
dscalar
(
'a'
)
rval
=
T
.
dot
(
w
,
v
)
*
alpha
+
t
f
=
theano
.
function
([
w
,
v
,
t
,
alpha
],
rval
,
mode
=
mode_blas_opt
)
# this function is currently optimized so that the gemv is done
# inplace on a temporarily allocated-buffer, which is then scaled by alpha
# and to t with a fused elemwise.
n_gemvs
=
0
#theano.printing.debugprint(f, print_type=True)
gemv_inplace
=
Gemv
(
inplace
=
True
)
for
node
in
f
.
maker
.
env
.
toposort
():
if
node
.
op
==
gemv_inplace
:
n_gemvs
+=
1
assert
node
.
outputs
[
0
]
.
dtype
==
'float32'
assert
n_gemvs
==
1
,
n_gemvs
def
test_upcasting_scalar_nogemm
():
# Test that the optimization does not crash when the scale has an incorrect
# dtype, and forces upcasting of the result
...
...
@@ -1167,6 +1144,38 @@ class BaseGemv(object):
oy_v
=
oy_func
()
assert_array_almost_equal
(
desired_oy
,
oy_v
)
def
test_upcasting_scalar_nogemv
(
self
):
# Test that the optimization does not crash when the scale has
# an incorrect dtype, and forces upcasting of the result
# We put this test in this class to test it on the gpu too.
vs
=
self
.
get_data
()
alpha_v
,
beta_v
,
a_v
,
x_v
,
y_v
=
vs
alpha_v
=
alpha_v
.
astype
(
"float64"
)
a_v
=
a_v
.
astype
(
"float32"
)
x_v
=
x_v
.
astype
(
"float32"
)
y_v
=
y_v
.
astype
(
"float32"
)
alpha
=
T
.
dscalar
(
'a'
)
a
=
T
.
fmatrix
(
'w'
)
x
=
T
.
fvector
(
'v'
)
y
=
T
.
fvector
(
't'
)
rval
=
T
.
dot
(
a
,
x
)
*
alpha
+
y
f
=
theano
.
function
([
a
,
x
,
y
,
alpha
],
rval
,
mode
=
self
.
mode
)
# this function is currently optimized so that the gemv is
# done inplace on a temporarily allocated-buffer, which is
# then scaled by alpha and to t with a fused elemwise.
n_gemvs
=
0
#theano.printing.debugprint(f, print_type=True)
for
node
in
f
.
maker
.
env
.
toposort
():
if
node
.
op
==
self
.
gemv_inplace
:
n_gemvs
+=
1
assert
node
.
outputs
[
0
]
.
dtype
==
'float32'
assert
n_gemvs
==
1
,
n_gemvs
self
.
assertFunctionContains1
(
f
,
self
.
gemv_inplace
)
f
(
a_v
,
x_v
,
y_v
,
alpha_v
)
class
TestSgemv
(
TestCase
,
BaseGemv
,
unittest_tools
.
TestOptimizationMixin
):
dtype
=
float32
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论