Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
db8bf96d
提交
db8bf96d
authored
9月 30, 2011
作者:
Frederic
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
make dot22 work with complex.
上级
e41ee606
显示空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
15 行增加
和
8 行删除
+15
-8
blas.py
theano/tensor/blas.py
+4
-3
test_blas.py
theano/tensor/tests/test_blas.py
+11
-5
没有找到文件。
theano/tensor/blas.py
浏览文件 @
db8bf96d
...
@@ -1218,9 +1218,10 @@ class Dot22(GemmRelated):
...
@@ -1218,9 +1218,10 @@ class Dot22(GemmRelated):
This is a specialization of the more general Dot()
This is a specialization of the more general Dot()
"""
"""
def
make_node
(
self
,
x
,
y
):
def
make_node
(
self
,
x
,
y
):
if
x
.
type
.
ndim
!=
2
or
x
.
type
.
dtype
not
in
(
'float32'
,
'float64'
):
dtypes
=
(
'float32'
,
'float64'
,
'complex64'
,
'complex128'
)
if
x
.
type
.
ndim
!=
2
or
x
.
type
.
dtype
not
in
dtypes
:
raise
TypeError
(
x
)
raise
TypeError
(
x
)
if
y
.
type
.
ndim
!=
2
or
y
.
type
.
dtype
not
in
(
'float32'
,
'float64'
)
:
if
y
.
type
.
ndim
!=
2
or
y
.
type
.
dtype
not
in
dtypes
:
raise
TypeError
(
y
)
raise
TypeError
(
y
)
if
y
.
type
.
dtype
!=
x
.
type
.
dtype
:
if
y
.
type
.
dtype
!=
x
.
type
.
dtype
:
raise
TypeError
(
'dtype mismatch to Dot22'
)
raise
TypeError
(
'dtype mismatch to Dot22'
)
...
@@ -1301,7 +1302,7 @@ def local_dot_to_dot22(node):
...
@@ -1301,7 +1302,7 @@ def local_dot_to_dot22(node):
_logger
.
info
(
'Not optimizing dot with inputs
%
s
%
s
%
s
%
s'
,
x
,
y
,
x
.
type
,
y
.
type
)
_logger
.
info
(
'Not optimizing dot with inputs
%
s
%
s
%
s
%
s'
,
x
,
y
,
x
.
type
,
y
.
type
)
return
return
if
y
.
type
.
dtype
.
startswith
(
'float'
):
if
y
.
type
.
dtype
.
startswith
(
'float'
)
or
y
.
type
.
dtype
.
startswith
(
'complex'
)
:
if
x
.
ndim
==
2
and
y
.
ndim
==
2
:
if
x
.
ndim
==
2
and
y
.
ndim
==
2
:
#print "local_dot_to_dot22: MM"
#print "local_dot_to_dot22: MM"
return
[
_dot22
(
*
node
.
inputs
)]
return
[
_dot22
(
*
node
.
inputs
)]
...
...
theano/tensor/tests/test_blas.py
浏览文件 @
db8bf96d
...
@@ -674,17 +674,23 @@ def test_inplace1():
...
@@ -674,17 +674,23 @@ def test_inplace1():
assert
[
n
.
op
for
n
in
f
.
maker
.
env
.
nodes
]
==
[
gemm_no_inplace
]
assert
[
n
.
op
for
n
in
f
.
maker
.
env
.
nodes
]
==
[
gemm_no_inplace
]
def
test_dot22
():
def
test_dot22
():
a
=
T
.
matrix
()
for
dtype1
in
[
'float32'
,
'float64'
,
'complex64'
,
'complex128'
]:
b
=
T
.
matrix
()
a
=
T
.
matrix
(
dtype
=
dtype1
)
for
dtype2
in
[
'float32'
,
'float64'
,
'complex64'
,
'complex128'
]:
b
=
T
.
matrix
(
dtype
=
dtype2
)
f
=
theano
.
function
([
a
,
b
],
T
.
dot
(
a
,
b
),
mode
=
mode_blas_opt
)
f
=
theano
.
function
([
a
,
b
],
T
.
dot
(
a
,
b
),
mode
=
mode_blas_opt
)
topo
=
f
.
maker
.
env
.
toposort
()
topo
=
f
.
maker
.
env
.
toposort
()
assert
_dot22
in
[
x
.
op
for
x
in
topo
]
if
dtype1
==
dtype2
:
assert
_dot22
in
[
x
.
op
for
x
in
topo
],
(
dtype1
,
dtype2
)
else
:
assert
T
.
dot
in
[
x
.
op
for
x
in
topo
],
(
dtype1
,
dtype2
)
rng
=
numpy
.
random
.
RandomState
(
unittest_tools
.
fetch_seed
())
rng
=
numpy
.
random
.
RandomState
(
unittest_tools
.
fetch_seed
())
def
cmp
(
a_shp
,
b_shp
):
def
cmp
(
a_shp
,
b_shp
):
av
=
rng
.
uniform
(
size
=
a_shp
)
.
astype
(
config
.
floatX
)
av
=
rng
.
uniform
(
size
=
a_shp
)
.
astype
(
dtype1
)
bv
=
rng
.
uniform
(
size
=
b_shp
)
.
astype
(
config
.
floatX
)
bv
=
rng
.
uniform
(
size
=
b_shp
)
.
astype
(
dtype2
)
f
(
av
,
bv
)
f
(
av
,
bv
)
cmp
((
3
,
4
),(
4
,
5
))
cmp
((
3
,
4
),(
4
,
5
))
cmp
((
0
,
4
),(
4
,
5
))
cmp
((
0
,
4
),(
4
,
5
))
cmp
((
3
,
0
),(
0
,
5
))
cmp
((
3
,
0
),(
0
,
5
))
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论