Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
817d0cbd
提交
817d0cbd
authored
6月 08, 2011
作者:
Pascal Lamblin
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Do not return Gemm/Gemv candidates with the wrong dtype
上级
ad16bb64
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
39 行增加
和
6 行删除
+39
-6
blas.py
theano/tensor/blas.py
+10
-6
test_blas.py
theano/tensor/tests/test_blas.py
+29
-0
没有找到文件。
theano/tensor/blas.py
浏览文件 @
817d0cbd
...
@@ -822,9 +822,14 @@ def _factor_canonicalized(lst):
...
@@ -822,9 +822,14 @@ def _factor_canonicalized(lst):
# once i has touched a list element, it is permantent
# once i has touched a list element, it is permantent
lst
=
list
(
lst
)
lst
=
list
(
lst
)
#print 'FACTOR', lst
#print 'FACTOR', lst
#for (a,b) in lst:
#for t in lst:
#theano.printing.debugprint(a)
# if not isinstance(t, (list, tuple)):
#theano.printing.debugprint(b)
# t = (t,)
# for e in t:
# try:
# theano.printing.debugprint(e)
# except TypeError:
# print e, type(e)
i
=
0
i
=
0
while
i
<
len
(
lst
)
-
1
:
while
i
<
len
(
lst
)
-
1
:
try
:
try
:
...
@@ -904,9 +909,8 @@ def _gemm_from_node2(node):
...
@@ -904,9 +909,8 @@ def _gemm_from_node2(node):
lst
=
_factor_canonicalized
(
lst
)
lst
=
_factor_canonicalized
(
lst
)
rval
=
_gemm_from_factored_list
(
lst
)
rval
=
_gemm_from_factored_list
(
lst
)
#print "RVAL", rval
#print "RVAL", rval
if
rval
:
if
rval
and
(
rval
[
0
]
.
type
==
node
.
outputs
[
0
]
.
type
):
assert
rval
[
0
]
.
type
==
node
.
outputs
[
0
]
.
type
,
(
rval
[
0
]
.
type
,
node
.
outputs
[
0
]
.
type
)
return
rval
return
rval
class
GemmOptimizer
(
Optimizer
):
class
GemmOptimizer
(
Optimizer
):
"""Graph optimizer for inserting Gemm operations"""
"""Graph optimizer for inserting Gemm operations"""
...
...
theano/tensor/tests/test_blas.py
浏览文件 @
817d0cbd
...
@@ -479,6 +479,35 @@ def test_gemm_factor():
...
@@ -479,6 +479,35 @@ def test_gemm_factor():
assert
[(
1.0
,
X
),
(
1.0
,
Y
)]
==
_factor_canonicalized
([(
1.0
,
X
),
(
1.0
,
Y
)])
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
)])
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
)
t
=
f
.
maker
.
env
.
toposort
()
assert
numpy
.
sum
([
isinstance
(
n
.
op
,
Gemv
)
for
n
in
t
])
==
0
theano
.
printing
.
debugprint
(
f
,
print_type
=
True
)
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
v
=
T
.
fmatrix
(
'v'
)
w
=
T
.
fmatrix
(
'w'
)
t
=
T
.
fmatrix
(
't'
)
alpha
=
T
.
dscalar
(
'a'
)
rval
=
T
.
dot
(
w
,
v
)
*
alpha
+
t
f
=
theano
.
function
([
w
,
v
,
t
,
alpha
],
rval
)
t
=
f
.
maker
.
env
.
toposort
()
assert
numpy
.
sum
([
isinstance
(
n
.
op
,
Gemm
)
for
n
in
t
])
==
0
theano
.
printing
.
debugprint
(
f
,
print_type
=
True
)
def
test_gemm_nested
():
def
test_gemm_nested
():
X
,
Y
,
Z
,
a
,
b
=
T
.
dmatrix
(
'X'
),
T
.
dmatrix
(
'Y'
),
T
.
dmatrix
(
'Z'
),
T
.
dscalar
(
'a'
),
T
.
dscalar
(
'b'
)
X
,
Y
,
Z
,
a
,
b
=
T
.
dmatrix
(
'X'
),
T
.
dmatrix
(
'Y'
),
T
.
dmatrix
(
'Z'
),
T
.
dscalar
(
'a'
),
T
.
dscalar
(
'b'
)
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论